Exemple #1
0
 public static void ChiTietChiTietDonHang_Update(InfoCT sv)
 {
     db1.ChiTietDonHang_Update(sv);
 }
Exemple #2
0
 public static void ChiTietDonHang_Insert(InfoCT sv)
 {
     db1.ChiTietDonHang_Insert(sv);
 }
Exemple #3
0
        private void btnLuuC_Click(object sender, EventArgs e)
        {
            try
            {
                if (kt2 == 1)
                {
                    InfoCT sv = new InfoCT();
                    sv.MaDonHang = int.Parse(txtMaDHC.Text);
                    sv.MaSach = int.Parse(txtMaSach.Text);
                    sv.SoLuong = int.Parse(txtSoLuong.Text);
                    btnLuuC.Enabled = false;
                    btnThemC.Enabled = true;
                    btnSuaC.Enabled = true;
                    btnXoaC.Enabled = true;
                    btnHuyC.Enabled = false;

                    try
                    {
                        SQLDataCT.ChiTietDonHang_Insert(sv);
                        MessageBox.Show("Thêm thành công");
                        EndCT(false);

                        grChiTiet.DataSource = TTBanSach.App_Code.ChiTietDonHang.SQLDataCT.ListByMaDH(txtMaDHC.Text);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Lỗi");

                    }
                    frmHoaDon_Load(sender, e);
                }
                else
                    if (kt2 == 0)
                    {
                        InfoCT sv = new InfoCT();
                        sv.MaDonHang = int.Parse(txtMaDHC.Text);
                        sv.MaSach = int.Parse(txtMaSach.Text);
                        sv.SoLuong = int.Parse(txtSoLuong.Text);
                        sv.DonGia = int.Parse(txtDonGia.Text);
                        btnLuuC.Enabled = false;
                        btnThemC.Enabled = true;
                        btnSuaC.Enabled = true;
                        btnXoaC.Enabled = true;
                        btnHuyC.Enabled = false;
                        try
                        {
                            SQLDataCT.ChiTietChiTietDonHang_Update(sv);
                            EndCT(false);
                            MessageBox.Show("Sửa Thành Công !");

                            frmHoaDon_Load(sender, e);
                            grChiTiet.DataSource = TTBanSach.App_Code.ChiTietDonHang.SQLDataCT.ListByMaDH(txtMaDHC.Text);
                        }
                        catch (Exception)
                        {

                            MessageBox.Show("Sửa Thất Bại !");
                            EndCT(true);
                        }
                    }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi");
                EndCT(true);
                txtMaDHC.Enabled = false;
            }
        }