本文整理匯總了C#中System.Data.DataTable.Init方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.Init方法的具體用法?C# DataTable.Init怎麽用?C# DataTable.Init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Data.DataTable
的用法示例。
在下文中一共展示了DataTable.Init方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: btnPayback_Click
private void btnPayback_Click(object sender, EventArgs e)
{
if(nudAmt.Value == 0)
{
MessageBox.Show("金額不能0");
return;
}
if(tbMark.Text.Trim() == "")
{
MessageBox.Show("備注不能為空");
return;
}
//MessageBox.Show(_id);
GlobalVar.DBHelper.AddInsert("debtdetail", "main_seqnbr,billseq,opr,type,amount,mark,seqnbr");
DataTable tbl = new DataTable();
tbl.Init("debtdetail", "main_seqnbr,billseq,opr,type,amount,mark,seqnbr");
DataRow r = tbl.NewRow();
r.SetField<long>("seqnbr", DateTime.Now.Ticks);
r.SetField<string>("opr", GlobalVar.LogInfo.WorkCode);
r.SetField<string>("type", "B");//還款
r.SetField<string>("billseq", "");
r.SetField<string>("main_seqnbr", _mainseqnbr);
r.SetField<string>("mark", tbMark.Text.Trim());
r.SetField<string>("amount", nudAmt.Value.ToString());
tbl.Rows.Add(r);
GlobalVar.DBHelper.Update(tbl);
DialogResult = DialogResult.OK;
}
示例2: btnAdd_Click
private void btnAdd_Click(object sender, EventArgs e)
{
DataTable tbl = new DataTable();
string fields = "productid,name,innerid,price,cost,colornum,position,storenum,packagenum,size,opr";
tbl.Init("products", fields);
DataRow row = tbl.NewRow();
if (IntiRow(row) == false)
return;
tbl.Rows.Add(row);
GlobalVar.DBHelper.AddInsert(tbl.TableName, fields);
if(GlobalVar.DBHelper.Update(tbl) == 1)
{
MessageBox.Show("添加成功");
DialogResult = DialogResult.OK;
}else
{
MessageBox.Show("添加失敗,請檢查日誌!", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例3: DoAction
public void DoAction(StrDictionary sd)
{
int num = Convert.ToInt32(sd["num"]);
string fields = "mark,num,seqnbr,type,productid,finalstore,opr,customer";
GlobalVar.DBHelper.AddInsert("storenumhistory", fields);
GlobalVar.DBHelper.AddUpdate("products", "id,storenum", "id");
DefaultAction.StoreChangeFrm frm = new DefaultAction.StoreChangeFrm(num);
if (frm.ShowDialog() == DialogResult.OK)
{
DataTable his = new DataTable();
DataTable upt = new DataTable();
his.Init("storenumhistory", fields);
upt.Init("products", "id,storenum,actcnt");
//Products表更新
DataRow r = upt.NewRow();
decimal final = frm.Value;
if (frm.OprType == 'I')//進貨
final = num + frm.Value;
else if (frm.OprType == 'O')//出貨
final = num - frm.Value;
r.SetField<string>("id", sd["data"]);
r.SetField<decimal>("storenum", final);
upt.Rows.Add(r);
r.AcceptChanges();
r.SetModified();
DataSet ds = new DataSet();
int want = 2;//理想影響條數
r = his.NewRow();
//storenumhistory 表增加記錄
r.SetField<string>("mark", frm.Mark);
r.SetField<decimal>("finalstore", final);
if (frm.OprType == 'M')
r.SetField<decimal>("num", num);
else
r.SetField<decimal>("num", frm.Value);
r.SetField<long>("seqnbr", DateTime.Now.Ticks);
r.SetField<char>("type", frm.OprType);
r.SetField<string>("productid", sd["data"]);
r.SetField<string>("opr", GlobalVar.LogInfo.WorkCode);
r.SetField<string>("customer", frm.Customer);
his.Rows.Add(r);
ds.Tables.Add(his);
ds.Tables.Add(upt);
int rst = GlobalVar.DBHelper.Update(ds, "storenumhistory,products");
try
{
GlobalVar.DBHelper.ExcuteNonQuery("update products set actcnt=actcnt+1 where id=" + sd["data"]);
}
catch (Exception) { }
GlobalVar.Container.InvokeScript("updateStoreNum", new object[] { final, rst == want });
}
}
示例4: FilterForsingle
private DataTable FilterForsingle(DataTable tbl)
{
DataTable rst = new DataTable();
StrDictionary sd = new StrDictionary();
rst.Init("", "item,price");
foreach (DataRow r in tbl.Rows)
{
string item = r.Field<string>("innerid");
if (String.IsNullOrEmpty(item))
item = r.Field<string>("productid");
item += " - ";
item += r.Field<string>("colornum");
if (sd.ContainsKey(item) == false)
{
sd[item] = "";
DataRow nr = rst.NewRow();
nr.SetField<string>("item", item);
nr.SetField<decimal>("price", r.Field<decimal>("saleprice"));
rst.Rows.Add(nr);
}
}
return rst;
}