示例#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.BillOutDetail> myBillOutDetailList = new List <BillOutDetail>();

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

            Connector.insertBillOut(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 readBillOutDetailList(string _id, List <Model.BillOutDetail> _myList)
 {
     try {
         openConnection();
         string        strCmd   = string.Format("select * from CTHDB where MAHDB = '{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.BillOutDetail b = new BillOutDetail(_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);
     }
 }