Example #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();
            }
        }
Example #2
0
        public static bool readBillInList(List <Model.BillIn> _myList)
        {
            try {
                openConnection();
                string        strCmd   = string.Format("select * from HD_NHAP");
                SqlCommand    myCmd    = new SqlCommand(strCmd, conn);
                SqlDataReader myReader = myCmd.ExecuteReader();
                while (myReader.Read())
                {
                    string   id         = myReader.GetString(0);
                    DateTime date       = myReader.GetDateTime(1);
                    string   employId   = myReader.GetString(2);
                    string   provId     = myReader.GetString(3);
                    int      totalPrice = myReader.GetInt32(4);

                    Model.BillIn b = new BillIn(id, date, employId, provId, totalPrice);
                    _myList.Add(b);
                }
                closeConnection();
                return(true);
            }
            catch (Exception) {
                return(false);
            }
        }
        public async Task <IActionResult> PutAsync(int id, [FromBody] BillIn resource)
        {
            var result = await _billinRepository.UpdateAsync(id, resource);


            return(Ok(result));
        }
        public async Task <IActionResult> DeleteWithName([FromBody] BillIn resource)
        {
            var result = await _billinRepository.DeleteWithName(resource.Tenvtnhap);


            return(Ok(result));
        }
        public async Task <IActionResult> PostAsync([FromBody] BillIn resource)
        {
            var result = await _billinRepository.SaveAsync(resource);


            return(Ok(result));
        }
Example #6
0
        public async Task <BillIn> SaveAsync(BillIn _obj)
        {
            await _context.BillIns.AddAsync(_obj);

            await _context.SaveChangesAsync();

            return(_obj);
        }
Example #7
0
        public async Task <BillIn> UpdateAsync(int id, BillIn resource)
        {
            var _obj = await _context.BillIns.Where(o => o.Id == id).FirstOrDefaultAsync();

            if (_obj != null)
            {
                _obj.Tenvtnhap   = resource.Tenvtnhap;
                _obj.Ngaynhap    = resource.Ngaynhap;
                _obj.Soluongnhap = resource.Soluongnhap;
                _obj.Dongianhap  = resource.Dongianhap;
                _obj.Tinhtrang   = resource.Tinhtrang;

                await _context.SaveChangesAsync();
            }
            return(_obj);
        }