Пример #1
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            if (isPay)
            {
                if (MessageBox.Show("Hóa đơn đã thanh toán, bạn có muốn xuất file Excel?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    exportToExcel();
                }
                return;
            }
            // Nhấn nút sẽ cập nhật dữ liệu vào csdl
            List <Model.BillInDetail> myBillInDetailList = new List <BillInDetail>();

            foreach (DataRow dr in dtDgv.Rows)
            {
                Model.BillInDetail b = new BillInDetail(curBillID, dr["id"].ToString(), int.Parse(dr["outPrice"].ToString()), int.Parse(dr["num"].ToString()));
                myBillInDetailList.Add(b);
            }
            BillIn bill = new BillIn(System.DateTime.Today.Date, CurEmployee.IdString, curProvider.IdString, truePrice, myBillInDetailList);

            Connector.insertBillIn(bill);
            isPay = true;
            // Hiện hộp thoại hỏi có xuất file excel hay không?
            if (MessageBox.Show("Thanh toán thành công, bạn có muốn xuất file Excel?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                exportToExcel();
            }
        }
Пример #2
0
 public static bool readBillInDetailList(string _id, List <Model.BillInDetail> _myList)
 {
     try {
         openConnection();
         string        strCmd   = string.Format("select * from CTHDN where MAHDN = '{0}'", _id);
         SqlCommand    myCmd    = new SqlCommand(strCmd, conn);
         SqlDataReader myReader = myCmd.ExecuteReader();
         while (myReader.Read())
         {
             string             idItem = myReader.GetString(1);
             int                cost   = myReader.GetInt32(2);
             int                count  = myReader.GetInt32(3);
             Model.BillInDetail b      = new BillInDetail(_id, idItem, cost, count);
             _myList.Add(b);
         }
         closeConnection();
         return(true);
     }
     catch (Exception ex) {
         System.Windows.Forms.MessageBox.Show("Lỗi ở đọc cthd bán " + ex.Message);
         return(false);
     }
 }