本文整理汇总了C#中DB.SelectTable方法的典型用法代码示例。如果您正苦于以下问题:C# DB.SelectTable方法的具体用法?C# DB.SelectTable怎么用?C# DB.SelectTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.SelectTable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get_Category_Properties
public static DataTable Get_Category_Properties(object cat_id)
{
try
{
DB db = new DB();
db.AddCondition("prp_cat_id", cat_id);
return db.SelectTable("select * from properties where [email protected]_cat_id or prp_cat_id is null ");
}
catch
{
return null;
}
}
示例2: Fill_Outcome
private void Fill_Outcome()
{
try
{
DB db2 = new DB();
db2.AddCondition("out_date", From_DTP.Value.Value.Date, false, ">=", "SD");
db2.AddCondition("out_date", To_DTP.Value.Value.Date, false, "<=", "ED");
DataTable dt = db2.SelectTable(@"select * from outcome o join outcome_types ot on o.out_ott_id=ot.ott_id where out_date>[email protected] and out_date<[email protected]");
dt.Rows.Add(null, null, dt.Compute("Sum(out_value)", ""), "الاجمالى");
Outcome_DG.ItemsSource = dt.DefaultView;
}
catch
{
}
}
示例3: Fill_Bank
private void Fill_Bank()
{
try
{
DB db2 = new DB();
db2.AddCondition("bnk_date", From_DTP.Value.Value.Date, false, ">=", "SD");
db2.AddCondition("bnk_date", To_DTP.Value.Value.Date, false, "<=", "ED");
DataTable dt = db2.SelectTable(@"select bnk_id,bnk_date,if(bnk_trn_id=9,bnk_value,null) value1,if(bnk_trn_id=10,bnk_value,null) value2, bnk_description from bank");
dt.Rows.Add(null, null, dt.Compute("Sum(value1)", ""), dt.Compute("Sum(value2)", ""), "الإجمالي");
Bank_DG.ItemsSource = dt.DefaultView;
}
catch
{
}
}
示例4: Fill_DG
private void Fill_DG()
{
try
{
DB db = new DB();
db.AddCondition("trs_date", From_DTP.Value.Value.Date, false, ">=", "SD");
db.AddCondition("trs_date", To_DTP.Value.Value.Date, false, "<=", "ED");
DataTable dt = db.SelectTable(@"select trs_no,trn_name,per_name,trs_date,trs_paid from transactions join transactions_names
on trs_trn_id =trn_id left join persons on trs_id_1=per_id where trn_id in(2,5,7) ");
dt.Rows.Add(null, "الاجمالى", null, null, dt.Compute("Sum(trs_paid)", ""));
Income_DG.ItemsSource = dt.DefaultView;
}
catch
{
}
}
示例5: Get_Transactions_Details
private void Get_Transactions_Details()
{
try
{
DB DB = new DB();
DB.AddCondition("trd_trs_id", Transactions_LB.SelectedValue);
DataTable dt = DB.SelectTable(@"select trd_pro_id,pro_name,trd_amount,trd_price,trd_amount*trd_price trd_total
from transactions_Details join products on pro_id=trd_pro_id");
Transactions_Details.Rows.Clear();
Pro_IDS.Clear();
foreach (DataRow row in dt.Rows)
{
Transactions_Details.Rows.Add(row.ItemArray);
Pro_IDS.Add(row["trd_pro_id"].ToString());
}
Details_DG.ItemsSource = Transactions_Details.DefaultView;
}
catch
{
}
}
示例6: Fill_DG_Payments
private void Fill_DG_Payments()
{
DB db = new DB();
try
{
decimal total_payments = 0, total_bills = 0, total_paid = 0 ;
DataTable dt2 = new DataTable();
dt2.Columns.Add("date");
dt2.Columns.Add("type");
dt2.Columns.Add("paid_to_him");
dt2.Columns.Add("suppose");
db.AddCondition("pay_per_id", ((DataRowView)LB.SelectedItem)["per_id"]);
DataTable ds = db.SelectTable(@"select * from payments");
foreach (DataRow row2 in ds.Rows)
{
total_payments += decimal.Parse(row2["pay_value"].ToString());
dt2.Rows.Add(row2["pay_date"], row2["قسط"], row2["pay_value"], row2[" "]);
}
DB db2 = new DB();
db2.AddCondition("supplier_id", LB.SelectedValue);
DataTable dt = db.SelectTable(@"select * from buy");
foreach (DataRow row in dt.Rows)
{
total_bills += decimal.Parse(row["total"].ToString());
total_paid += decimal.Parse(row["paid"].ToString());
dt2.Rows.Add(row["date"], row["فاتوره شراء"], row["paid"], row["total"]);
}
dt2.Rows.Add("", "الرصيد", (total_bills - (total_paid + total_payments)), "");
//Payment_DG.ItemsSource = db.SelectTableView(@"select * from payments p");
}
catch
{
}
}
示例7: Get_Accounts
private void Get_Accounts()
{
try
{
DB db = new DB();
db.AddCondition("trs_date", From_DTP.Value.Value.Date, false, ">=", "SD");
db.AddCondition("trs_date", To_DTP.Value.Value.Date, false, "<=", "ED");
db.AddCondition("sup_id", LB.SelectedValue);
db.AddCondition("per_id", ((DataRowView)LB.SelectedItem)["per_id"]);
DataTable dt;
if(Table == "customers")
{
dt = db.SelectTable(@"select trs_total Debtor,trs_paid Creditor,0 balance,'بيع' des,trs_no,trs_date from transactions
where trs_trn_id = 5 and [email protected]_id and trs_date>[email protected] and trs_date<[email protected] union
Select 0,trs_paid,0 balance,'قسط',trs_no,trs_date from transactions
where trs_trn_id = 7 and [email protected]_id and trs_date>[email protected] and trs_date<[email protected]");
}
else
{
dt = db.SelectTable(@"select trs_paid Debtor,trs_total Creditor,0 balance,'شراء' des,trs_no,trs_date from transactions
where trs_trn_id = 1 and [email protected]_id and trs_date>[email protected] and trs_date<[email protected] union
Select trs_paid,0,0 balance,'قسط',trs_no,trs_date from transactions
where trs_trn_id = 8 and [email protected]_id and trs_date>[email protected] and trs_date<[email protected]");
}
DataRow dr = dt.NewRow();
decimal balance = Get_Balance();
dr["balance"] = balance;
foreach(DataRow Row in dt.Rows)
{
balance -= decimal.Parse(Row[0].ToString());
balance += decimal.Parse(Row[1].ToString());
Row["balance"] = balance;
}
dt.Rows.InsertAt(dr, 0);
Account_DG.ItemsSource = dt.DefaultView;
}
catch
{
}
}
示例8: Create_Properties_Controls
private void Create_Properties_Controls()
{
try
{
Properties_WP.Children.RemoveRange(1, Properties_WP.Children.Count - 1);
object Prp_Id;
DB db = new DB();
db.AddCondition("prp_cat_id", ((DataRowView)Categories_CB.SelectedItem)[0]);
foreach(DataRow property in db.SelectTable("select * from properties where [email protected]_cat_id or prp_cat_id is null ").Rows)
{
Prp_Id = property[0];
TextBlock Property_Name = new TextBlock();
Property_Name.Style = FindResource("Label_TextBlock") as Style;
Property_Name.Text = property["prp_name"].ToString() + " :";
Properties_WP.Children.Add(Property_Name);
ComboBox CB = new ComboBox();
CB.Style = FindResource("Edit_ComboBox") as Style;
CB.Name = "CB_" + Prp_Id;
CB.IsEditable = true;
CB.SelectionChanged += new SelectionChangedEventHandler(ComboBox_SelectionChanged);
CB.Width = 120;
Properties_WP.Children.Add(CB);
}
}
catch
{
}
}
示例9: Get_Stock
private void Get_Stock()
{
try
{
DB db = new DB();
db.AddCondition("stk_pon_id", Points_LB.SelectedValue);
DataTable dt = db.SelectTable(@"SELECT pro_id, COALESCE(SUM(stk_amount),0) pro_amount, CASE
WHEN COALESCE(stk_amount,0)-pro_limit>0 THEN 1
WHEN COALESCE(stk_amount,0)-pro_limit<0 THEN -1
ELSE 0 END pro_status FROM products
left JOIN stock ON stk_pro_id=pro_id and [email protected]_pon_id
GROUP BY pro_id");
foreach(DataRow row in ((DataView)Stock_DG.ItemsSource).Table.Rows)
{
row["pro_amount"] = dt.Rows.OfType<DataRow>().Where(r => r["pro_id"].ToString() == row["pro_id"].ToString()).Single<DataRow>()["pro_amount"];
row["pro_status"] = dt.Rows.OfType<DataRow>().Where(r => r["pro_id"].ToString() == row["pro_id"].ToString()).Single<DataRow>()["pro_status"];
}
}
catch
{
}
}
示例10: Fill_Transactions_DG
private void Fill_Transactions_DG()
{
try
{
Dictionary<string, decimal> stock = Get_Products_Stock();
DB db = new DB();
db.AddCondition("trs_date", From_DTP.Value.Value.Date, false, ">=", "SD");
db.AddCondition("trs_date", To_DTP.Value.Value.Date, false, "<=", "ED");
db.AddCondition("trs_id", Points_LB.SelectedValue);
DataTable dt = db.SelectTable(@"select trs_no,trs_date,trn_name,0 income ,0 outcome,0 balance, trd_serial,pro_name,trd_amount,trn_id,trs_id_1,pro_id from transactions
join transactions_names on trs_trn_id= trn_id
join transactions_details on trd_trs_id = trs_id
join products on trd_pro_id = pro_id where ([email protected]_id or [email protected]_id)" + Get_Products());
foreach(DataRow row in dt.Rows)
{
switch(int.Parse(row["trn_id"].ToString()))
{
case 1:
case 6:
row["income"] = row["trd_amount"];
stock[row["pro_id"].ToString()] += decimal.Parse(row["trd_amount"].ToString());
break;
case 2:
case 4:
case 5:
row["outcome"] = row["trd_amount"];
stock[row["pro_id"].ToString()] -= decimal.Parse(row["trd_amount"].ToString());
break;
case 3:
if(row["trs_id_1"].ToString() == Points_LB.SelectedValue.ToString())
{
row["outcome"] = row["trd_amount"];
stock[row["pro_id"].ToString()] -= decimal.Parse(row["trd_amount"].ToString());
}
else
{
row["income"] = row["trd_amount"];
stock[row["pro_id"].ToString()] += decimal.Parse(row["trd_amount"].ToString());
}
break;
}
row["balance"] = stock[row["pro_id"].ToString()];
}
Transactions_DG.ItemsSource = dt.DefaultView;
}
catch
{
}
}
示例11: Get_Products_Stock
private Dictionary<string, decimal> Get_Products_Stock()
{
Dictionary<string, decimal> stock = new Dictionary<string, decimal>();
int i = 2;
try
{
string query = "select pro_id from products join products_properties p1 on psp_pro_id=pro_id";
DB db = new DB();
db.AddCondition("pro_name", Product_TB.Text, false, " like ");
db.AddCondition("pro_Serial", Serial_TB.Text, false, " like ");
db.AddCondition("pro_cat_id", Categories_CB.SelectedValue, Categories_CB.SelectedIndex < 1);
foreach(ComboBox cb in Properties_WP.Children.OfType<ComboBox>().Where(c => c is ComboBox && c.SelectedIndex > 0))
{
db.AddCondition("p" + i + ".psp_value", cb.SelectedValue, cb.SelectedIndex < 1, "=", "psp_value_" + i);
db.AddCondition("p" + i + ".psp_prp_id", cb.Name.Split('_')[1], cb.SelectedIndex < 1, "=", "psp_prp_id" + i);
query += " join products_properties p" + i + " on p1.psp_pro_id = p" + i + ".psp_pro_id ";
i++;
}
DataTable dt = db.SelectTable(query + "group by pro_id");
db = new DB();
db.AddCondition("trs_date", From_DTP.Value.Value.Date, false, "<", "SD");
db.AddCondition("trs_id", Points_LB.SelectedValue);
db.AddCondition("pro_id", Points_LB.SelectedValue);
foreach(DataRow row in dt.Rows)
{
db.Conditions[2].Value = row[0];
stock.Add(row[0].ToString(), decimal.Parse(
db.Select(@"SELECT COALESCE(SUM(trd_amount),0) - (SELECT COALESCE(SUM(trd_amount),0) FROM transactions_details JOIN transactions ON trs_id= trd_trs_id
WHERE [email protected]_id AND trs_date<@SD AND ((trs_trn_id IN (2,4,5) AND [email protected]_id) OR(trs_trn_id = 3 AND [email protected]_id)))
FROM transactions_details JOIN transactions ON trs_id= trd_trs_id WHERE [email protected]_id AND trs_date<@SD AND
trs_trn_id IN (1,3,6) AND [email protected]_id").ToString()));
}
}
catch
{
}
return stock;
}
示例12: Get_Products
private string Get_Products()
{
int i = 2;
StringBuilder sb = new StringBuilder();
sb.Append("And pro_id ");
try
{
string query = "select pro_id from products join products_properties p1 on psp_pro_id=pro_id";
DB db = new DB();
db.AddCondition("pro_name", Product_TB.Text, false, " like ");
db.AddCondition("pro_Serial", Serial_TB.Text, false, " like ");
db.AddCondition("pro_cat_id", Categories_CB.SelectedValue, Categories_CB.SelectedIndex < 1);
foreach(ComboBox cb in Properties_WP.Children.OfType<ComboBox>().Where(c => c is ComboBox && c.SelectedIndex > 0))
{
db.AddCondition("p" + i + ".psp_value", cb.SelectedValue, cb.SelectedIndex < 1, "=", "psp_value_" + i);
db.AddCondition("p" + i + ".psp_prp_id", cb.Name.Split('_')[1], cb.SelectedIndex < 1, "=", "psp_prp_id" + i);
query += " join products_properties p" + i + " on p1.psp_pro_id = p" + i + ".psp_pro_id ";
i++;
}
DataTable dt = db.SelectTable(query + "group by pro_id");
if(dt.Rows.Count == 1)
{
sb.Append("=");
sb.Append(dt.Rows[0][0]);
}
else
{
sb.Append("in (");
foreach(DataRow row in dt.Rows)
{
sb.Append(row[0]);
sb.Append(" ,");
}
if(sb.ToString().EndsWith(","))
{
sb.Remove(sb.Length - 2, 2);
sb.Append(")");
}
else
{
sb.Clear();
}
}
}
catch
{
}
return sb.ToString();
}