Ejemplo n.º 1
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            CTPHIEUDATHANGNCC ctpdh = new CTPHIEUDATHANGNCC();

            ctpdh.SODONHANG = dgv_phieudathang.CurrentRow.Cells[0].Value.ToString();
            ctpdh.MASP      = txt_msp.Text.ToString();
            ctpdh.COSIZE    = Convert.ToInt32(txt_sizegiay.Text.ToString());
            ctpdh.SOLUONG   = Convert.ToInt32(txt_sldat.Text.ToString());
            if (ctpdh_bll.ktkc(ctpdh) == true)
            {
                if (ctpdh_bll.themctpdh(ctpdh) == true)
                {
                    MessageBox.Show("thêm thảnh công");
                    dgv_ctphieudathang.DataSource = ctpdh_bll.loadbang_ctphieudathang_maphieudat(dgv_phieudathang.CurrentRow.Cells[0].Value.ToString());
                }
                else
                {
                    MessageBox.Show("thất bại");
                }
            }
            else
            {
                MessageBox.Show("Đơn đặt hảng này đã tồn tại");
            }
        }
Ejemplo n.º 2
0
        private void buttonX3_Click(object sender, EventArgs e)
        {
            try
            {
                CTPHIEUDATHANGNCC ctpdh = new CTPHIEUDATHANGNCC();
                ctpdh.SODONHANG = dgv_phieudathang.CurrentRow.Cells[0].Value.ToString();
                ctpdh.MASP      = txt_msp.Text.ToString();
                ctpdh.COSIZE    = Convert.ToInt32(txt_sizegiay.Text.ToString());
                ctpdh.SOLUONG   = Convert.ToInt32(txt_sldat.Text.ToString());
                if (ctpdh_bll.ktkc(ctpdh) == true)
                {
                    MessageBox.Show("giá trị không tồn tại");
                    return;
                }

                if (ctpdh_bll.suactpdh(ctpdh) == true)
                {
                    MessageBox.Show("thành công");
                    dgv_ctphieudathang.DataSource = ctpdh_bll.loadbang_ctphieudathang_maphieudat(dgv_phieudathang.CurrentRow.Cells[0].Value.ToString());
                }
                else
                {
                    MessageBox.Show("xảy ra lỗi");
                }
            }
            catch
            {
                MessageBox.Show("xảy ra lỗi");
            }
        }
Ejemplo n.º 3
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            CTPHIEUDATHANGNCC ct = new CTPHIEUDATHANGNCC();

            if (sODONHANGTextEdit.Text == "" || sANPHAMComboBox.Text == "" || txtsl.Text == "" || txtdongia.Text == "")
            {
                MessageBox.Show("không được để trống");
                return;
            }
            var kt = from s in db.CTPHIEUDATHANGNCCs where s.SODONHANG == sODONHANGTextEdit.Text.ToString() && s.MASP == sANPHAMComboBox.Text select s;

            if (kt.Count() > 0)
            {
                MessageBox.Show("trùng khóa chính");
                return;
            }

            ct.SODONHANG = sODONHANGTextEdit.Text;
            ct.MASP      = sANPHAMComboBox.Text;
            ct.SOLUONG   = Convert.ToInt32(txtsl.Text);
            ct.DONGIA    = Convert.ToDouble(txtdongia.Text);
            db.CTPHIEUDATHANGNCCs.InsertOnSubmit(ct);
            db.SubmitChanges();
            frm_ThemDDH_Load(sender, e);
            insert();
            MessageBox.Show("thành công");
        }
Ejemplo n.º 4
0
 private void btnxoa_Click(object sender, EventArgs e)
 {
     try
     {
         PHIEUDATHANGNCC pdh = new PHIEUDATHANGNCC();
         pdh.SODONHANG = dgv_phieudathang.CurrentRow.Cells[0].Value.ToString();
         if (dathang_bll.ktkc(pdh) == true)
         {
             MessageBox.Show("giá trị không tồn tại");
             return;
         }
         if (dathang_bll.xoapdh(pdh) == true)
         {
             MessageBox.Show("thành công");
             dgv_phieudathang.DataSource = dathang_bll.loadbang_phieudathang();
         }
         else
         {
             if (dathang_bll.xoapdh(pdh) == false)
             {
                 DialogResult dr = MessageBox.Show("Hệ thống phát hiện thực hiện thao tác này sẽ xóa tất cả dữ liệu chi tiết đặt hàng?", "Xác nhận hủy", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                 if (dr == DialogResult.Yes)
                 {
                     try
                     {
                         CTPHIEUDATHANGNCC ctpdh = new CTPHIEUDATHANGNCC();
                         ctpdh.SODONHANG = dgv_ctphieudathang.CurrentRow.Cells[1].Value.ToString();
                         if (ctpdh_bll.xoactpdh_maphieudathang(ctpdh) == true)
                         {
                             if (dathang_bll.xoapdh(pdh) == true)
                             {
                                 dgv_ctphieudathang.DataSource = ctpdh_bll.loadbang_ctphieudathang();
                                 dgv_phieudathang.DataSource   = dathang_bll.loadbang_phieudathang();
                             }
                         }
                         else
                         {
                             MessageBox.Show("xảy ra lỗi");
                         }
                     }
                     catch
                     {
                         MessageBox.Show("xảy ra lỗi");
                     }
                 }
                 else
                 {
                     return;
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("xảy ra lỗi");
     }
 }
Ejemplo n.º 5
0
 public bool xoa_tatcactpd(CTPHIEUDATHANGNCC pmh)
 {
     try
     {
         CTPHIEUDATHANGNCC mh = da.CTPHIEUDATHANGNCCs.Where(t => t.SODONHANG == pmh.SODONHANG.ToString()).FirstOrDefault();
         da.CTPHIEUDATHANGNCCs.DeleteOnSubmit(mh);
         da.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 6
0
 public bool them(CTPHIEUDATHANGNCC pmh)
 {
     try
     {
         da.CTPHIEUDATHANGNCCs.InsertOnSubmit(pmh);
         da.SubmitChanges();
         da.Refresh(RefreshMode.OverwriteCurrentValues, pmh);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
 public bool sua(CTPHIEUDATHANGNCC pmh)
 {
     try
     {
         CTPHIEUDATHANGNCC thanhvien = da.CTPHIEUDATHANGNCCs.Where(t => t.SODONHANG == pmh.SODONHANG.ToString() && t.MASP == pmh.MASP && t.COSIZE == pmh.COSIZE).FirstOrDefault();
         thanhvien.SOLUONG = pmh.SOLUONG;
         da.SubmitChanges();
         da.Refresh(RefreshMode.OverwriteCurrentValues, thanhvien);
         da.Refresh(RefreshMode.OverwriteCurrentValues, pmh);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 8
0
        public bool ktkc(CTPHIEUDATHANGNCC pmh)
        {
            int r = da.CTPHIEUDATHANGNCCs.Count(t => t.SODONHANG == pmh.SODONHANG.ToString() && t.MASP == pmh.MASP && t.COSIZE == pmh.COSIZE);

            try
            {
                if (r == 0)
                {
                    return(true);
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
 public bool xoactpdh_maphieudathang(CTPHIEUDATHANGNCC n)
 {
     return(dl.xoa_tatcactpd(n));
 }
Ejemplo n.º 10
0
 public bool suactpdh(CTPHIEUDATHANGNCC n)
 {
     return(dl.sua(n));
 }
Ejemplo n.º 11
0
 public bool xoactpdh(CTPHIEUDATHANGNCC n)
 {
     return(dl.xoa(n));
 }
Ejemplo n.º 12
0
 public bool themctpdh(CTPHIEUDATHANGNCC n)
 {
     return(dl.them(n));
 }
Ejemplo n.º 13
0
 public bool ktkc(CTPHIEUDATHANGNCC n)
 {
     return(dl.ktkc(n));
 }