Esempio n. 1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Bạn có muốn xóa không?",
                                                  "Question",
                                                  MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                string err = "";
                try
                {
                    bool f        = muaHangBUS.XoaMuaHangBUS(ref err, MH);
                    bool f1       = false;
                    int  demXoaTK = 0;
                    if (f == true)
                    {
                        DataTable dtChiTietPMH = new DataTable();
                        dtChiTietPMH = chiTietPhieuMuaHangBUS.GetAllChiTietPhieuMuaHangByMaPhieuBUS(CTPMH);
                        f1           = chiTietPhieuMuaHangBUS.XoaChiTietPhieuMuaHangByMaPhieuBUS(ref err, CTPMH);
                        MessageBox.Show("Xoa thanh cong muahang");
                        if (f1 == true)
                        {
                            MessageBox.Show("Xoa thanh cong chitietphieumuahang");
                            loadData();
                            foreach (DataRow r in dtChiTietPMH.Rows)
                            {
                                TK.MaHangHoa = r[2].ToString();
                                TK.MaKho     = MH.MaKho;
                                TK.SoLuong   = Convert.ToInt32(r[3]);
                                bool f2 = tonKhoBUS.XuatTonKhoBUS(ref err, TK);
                                if (f2 == true)
                                {
                                    demXoaTK++;
                                }
                            }

                            MessageBox.Show("Xoa thanh cong chitietmuahang, ma phieu:" + CTPMH.MaPhieu);
                        }

                        if (demXoaTK == dtChiTietPMH.Rows.Count)
                        {
                            MessageBox.Show("Xuat thanh cong ton kho,Soluong" + demXoaTK);
                        }
                        loadData();
                    }
                    else
                    {
                        MessageBox.Show("Khong Xoa duoc mua hang. Loi: " + err);
                    }
                }
                catch (SqlException)
                {
                    MessageBox.Show("Khong Xoa duoc. Loi: " + err);
                }
            }
        }
Esempio n. 2
0
 void LayChiTietPhieuMuaHangByMaPhieu(MuaHangO mh)
 {
     CTPMH.MaPhieu = mh.MaPhieu;
     dt            = chiTietPhieuMuaHangBUS.GetAllChiTietPhieuMuaHangByMaPhieuBUS(CTPMH);
     gridControlMuaHang.DataSource = dt;
 }