📄 tellermanagement.cs
字号:
using System;
using System.Data;
using System.Data.OleDb;
namespace SupermarketProject
{
/// <summary>
/// Summary description for TellerManagement.
/// </summary>
public class TellerManagement
{
public TellerManagement()
{
}
public void SaveBill(DataSet ds)
{
string str;
int count= ds.Tables[0].Rows.Count;
DataTable dtBill = ds.Tables[0];
DataRow drBill = dtBill.Rows[count-1]; //get the last added row in the dataset
//add the content of that row into Bills table
str = "Insert into Bills (BillNo, Billdate, Usrid, TotalBillAmt,PaymentMode) values ("+drBill["BillNo"]+",#"+drBill["BillDate"]+"#,'"+drBill["UsrId"]+"',"+drBill["TotalBillAmt"]+",'"+drBill["PaymentMode"]+"')";
Console.WriteLine (str);
DataConnection.commnd.CommandText = str;
DataConnection.commnd.ExecuteNonQuery ();
//add into BillDetails table
DataTable dtBillDet = ds.Tables[1];
foreach(DataRow drBillDet in dtBillDet.Rows)
{
str="Insert into Billdetails values ("+drBillDet["BillNo"]+","+drBillDet["StockId"]+",'"+drBillDet["Quantity"]+"',"+drBillDet["SalePrice"]+")";
Console.WriteLine (str);
DataConnection.commnd.CommandText = str;
if (DataConnection.commnd.ExecuteNonQuery ()>0)
Console.WriteLine ("已添加");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -