Exemplo n.º 1
0
        private void btBill_Click(object sender, EventArgs e)
        {
            DTO_HoaDon HoaDonFinal = (from DataRow dr in busBan.dtHoaDonTam(busBan.curBan(lbViTriBan.Text)).Rows
                                      where string.Compare(dr[0].ToString(), hd.MaHD, true) == 0
                                      select new DTO_HoaDon(dr[0].ToString(), NV.MaNV, (int)dr[1], float.Parse(dr[3].ToString()), dr[4].ToString())).FirstOrDefault();

            HoaDonFinal.ThanhTien = (busBan.TongTienHDTam(hd) - busBan.TongTienHDTam(hd) * hd.KhuyenMai / 100);
            if (string.IsNullOrWhiteSpace(HoaDonFinal.SDT_KH))
            {
                busBan.ThemHDFinalNoneKH(HoaDonFinal);
            }
            else
            {
                busBan.ThemHoaDonFinal(HoaDonFinal);
            }

            foreach (DataRow dr in busBan.dtHDCTFinal(hd.MaHD).Rows)
            {
                DTO_CTHD cthd = new DTO_CTHD(dr[0].ToString(), dr[1].ToString(), int.Parse(dr[2].ToString()));

                DTO_Ban Ban = busBan.curBan(lbViTriBan.Text);
                if (busBan.ThemCTHDFinal(cthd))
                {
                    busBan.UpdateTrangThaiBan(Ban, 0);
                    (flpkvBan.Controls[IndexBan].Controls[0] as PictureBox).Image = Image.FromFile(startupPath + @"\image\banDong.png");
                }
            }
            crtBaoCao();
            busBan.ClearTemp(hd.MaHD);
            txtSDTKH.Text = null;
            FormKhuVucBan_Load(sender, e);
        }
Exemplo n.º 2
0
        private void btOK_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Gộp " + OldBan.TenBan + " vào " + cbBan.Text + "?", "Confirm",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                DTO_HoaDon oldHD  = busBan.curhd(OldBan);
                DTO_Ban    NewBan = busBan.curBan(cbBan.Text);
                DTO_HoaDon newHD  = busBan.curhd(NewBan);

                DataTable dtCTHDOld = busBan.CTHDtheoMaHD(oldHD.MaHD);
                foreach (DataRow dr in dtCTHDOld.Rows)
                {
                    DTO_CTHD cthd = new DTO_CTHD(newHD.MaHD, dr[1].ToString(), (int)dr[2]);

                    busBan.ThemCTHDTam(cthd).ToString();
                    busBan.DeleteCTHDSoluong(dr[0].ToString(), dr[1].ToString(), (int)dr[2]);
                }
                FormKhuVucBan.IndexBan = NewBan.IdBan - 1;
                busBan.UpdateTrangThaiBan(OldBan, 0);
                busBan.ClearTemp(oldHD.MaHD);


                this.Close();
            }
        }