Exemplo n.º 1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            PHIEUDATHANGNCC pdh = new PHIEUDATHANGNCC();
            int             b   = 0;

            for (int i = 1; i <= dgv_phieudathang.RowCount; i++)
            {
                b = i;
            }
            pdh.SODONHANG       = "DH" + (b + 1).ToString();
            pdh.MANCC           = cb_ncc.SelectedValue.ToString();
            pdh.MANV            = txt_nvlap.Text.ToString();
            pdh.NGAYLAP         = Convert.ToDateTime(dateEdit_NgayLap.Text.ToString());
            pdh.TONGSOLUONGNHAP = Convert.ToInt32(txt_tongslnhap.Text.ToString());
            pdh.TINHTRANGHANG   = "Chưa giao hàng";
            if (dathang_bll.ktkc(pdh) == true)
            {
                if (dathang_bll.thempdh(pdh) == true)
                {
                    MessageBox.Show("thêm thành công");
                    dgv_phieudathang.DataSource = dathang_bll.loadbang_phieudathang();
                }
                else
                {
                    MessageBox.Show("thất bại");
                }
            }
            else
            {
                MessageBox.Show("Đơn đặt hảng này đã tồn tại");
            }
        }
Exemplo n.º 2
0
        private void buttonX3_Click(object sender, EventArgs e)
        {
            if (txtSodonhang.Text == "" || cboNCC.Text == "" || txtnhanvien.Text == "" || datengaylap.Text == "" || txtTongtiennhap.Text == "" ||
                txttinhtrang.Text == "" || txttientratruoc.Text == "")
            {
                MessageBox.Show("không được để trống");
                return;
            }
            PHIEUDATHANGNCC ct = new PHIEUDATHANGNCC();
            var             kt = from s in db.PHIEUDATHANGNCCs where s.SODONHANG == txtSodonhang.Text.ToString() select s;

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

            ct.SODONHANG      = txtSodonhang.Text;
            ct.MANCC          = cboNCC.Text;
            ct.MANV           = txtnhanvien.Text;
            ct.NGAYLAP        = Convert.ToDateTime(datengaylap.Text);
            ct.TONGTIENNHAP   = Convert.ToDouble(txtTongtiennhap.Text);
            ct.TINHTRANGHANG  = txttinhtrang.Text;
            ct.SOTIENTRATRUOC = Convert.ToDouble(txttientratruoc.Text);
            db.PHIEUDATHANGNCCs.InsertOnSubmit(ct);
            db.SubmitChanges();
            frm_ThemDDH_Load(sender, e);
            insert();
            MessageBox.Show("thành công");
        }
Exemplo n.º 3
0
        private void btnsua_Click(object sender, EventArgs e)
        {
            try
            {
                PHIEUDATHANGNCC pdh = new PHIEUDATHANGNCC();
                pdh.SODONHANG       = txt_madh.Text.ToString();
                pdh.MANCC           = cb_ncc.SelectedValue.ToString();
                pdh.MANV            = txt_nvlap.Text.ToString();
                pdh.NGAYLAP         = Convert.ToDateTime(dateEdit_NgayLap.Text.ToString());
                pdh.TONGSOLUONGNHAP = Convert.ToInt32(txt_tongslnhap.Text.ToString());
                pdh.TINHTRANGHANG   = txt_tinhtranghang.Text.ToString();
                if (dathang_bll.ktkc(pdh) == true)
                {
                    MessageBox.Show("giá trị không tồn tại");
                    return;
                }

                if (dathang_bll.suapdh(pdh) == true)
                {
                    MessageBox.Show("thành công");
                    dgv_phieudathang.DataSource = dathang_bll.loadbang_phieudathang();
                }
                else
                {
                    MessageBox.Show("xảy ra lỗi");
                }
            }
            catch
            {
                MessageBox.Show("xảy ra lỗi");
            }
        }
Exemplo 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");
     }
 }
Exemplo n.º 5
0
 public bool them(PHIEUDATHANGNCC pmh)
 {
     try
     {
         da.PHIEUDATHANGNCCs.InsertOnSubmit(pmh);
         da.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 6
0
 public bool xoa(PHIEUDATHANGNCC pmh)
 {
     try
     {
         PHIEUDATHANGNCC mh = da.PHIEUDATHANGNCCs.Where(t => t.SODONHANG == pmh.SODONHANG.ToString()).FirstOrDefault();
         da.PHIEUDATHANGNCCs.DeleteOnSubmit(mh);
         da.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 7
0
        public bool ktkc(PHIEUDATHANGNCC ma)
        {
            int r = da.PHIEUDATHANGNCCs.Count(t => t.SODONHANG == ma.SODONHANG.ToString());

            try
            {
                if (r == 0)
                {
                    return(true);
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 8
0
 public bool sua(PHIEUDATHANGNCC pmh)
 {
     try
     {
         PHIEUDATHANGNCC thanhvien = da.PHIEUDATHANGNCCs.Where(t => t.SODONHANG == pmh.SODONHANG.ToString()).FirstOrDefault();
         thanhvien.MANCC           = pmh.MANCC;
         thanhvien.MANV            = pmh.MANV;
         thanhvien.NGAYLAP         = pmh.NGAYLAP;
         thanhvien.TONGSOLUONGNHAP = pmh.TONGSOLUONGNHAP;
         thanhvien.TINHTRANGHANG   = "Chưa giao hàng";
         da.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 9
0
 public bool suapdh(PHIEUDATHANGNCC n)
 {
     return(dl.sua(n));
 }
Exemplo n.º 10
0
 public bool xoapdh(PHIEUDATHANGNCC n)
 {
     return(dl.xoa(n));
 }
Exemplo n.º 11
0
 public bool thempdh(PHIEUDATHANGNCC n)
 {
     return(dl.them(n));
 }
Exemplo n.º 12
0
 public bool ktkc(PHIEUDATHANGNCC n)
 {
     return(dl.ktkc(n));
 }