Ejemplo 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  = chuyenKhoBUS.XoaChuyenKhoBUS(ref err, CK);
                    bool f1 = false;
                    if (f == true)
                    {
                        DataTable dtChiTietCK = new DataTable();
                        dtChiTietCK = chiTietChuyenKhoBUS.GetAllChiTietChuyenKhoByMaPhieuChuyenBUS(CTCK);
                        f1          = chiTietChuyenKhoBUS.XoaChiTietChuyenKhoByMaPhieuChuyenBUS(ref err, CTCK);
                        MessageBox.Show("Xoa thanh cong chuyen kho");
                        if (f1 == true)
                        {
                            foreach (DataRow r in dtChiTietCK.Rows)
                            {
                                TK.MaHangHoa = r[2].ToString();
                                TK.MaKho     = CK.MaKhoChuyen;
                                TK.SoLuong   = Convert.ToInt32(r[3]);
                                bool f2 = tonKhoBUS.CongSoLuongTonKhoBUS(ref err, TK);
                                if (f2 == true)
                                {
                                    MessageBox.Show("Cong thanh cong kho:" + TK.MaKho + ",MaHangHoa:" + TK.MaHangHoa + ", So luong:" + TK.SoLuong);
                                }
                                TK.MaKho = CK.MaKhoNhan;
                                bool f3 = tonKhoBUS.TruSoLuongTonKho(ref err, TK);
                                if (f3 == true)
                                {
                                    MessageBox.Show("Tru thanh cong kho:" + TK.MaKho + ",MaHangHoa:" + TK.MaHangHoa + ", So luong:" + TK.SoLuong);
                                }
                            }

                            MessageBox.Show("Xoa thanh cong chitietmuahang, ma phieu:" + CTCK.MaPhieuChuyen);
                        }
                        loadData();
                    }
                    else
                    {
                        MessageBox.Show("Khong Xoa duoc chuyenkho. Loi: " + err);
                    }
                }
                catch (SqlException)
                {
                    MessageBox.Show("Khong Xoa duoc. Loi: " + err);
                }
            }
        }
Ejemplo n.º 2
0
 void LayChiTietPhieuChuyenKhoByMaPhieu(ChuyenKhoO ck)
 {
     CTCK.MaPhieuChuyen = CK.MaPhieuChuyen;
     dt = chiTietChuyenKhoBUS.GetAllChiTietChuyenKhoByMaPhieuChuyenBUS(CTCK);
     gridControlChuyenKho.DataSource = dt;
 }