Beispiel #1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         ePhieuQLiKho newpNk = new ePhieuQLiKho();
         newpNk._maNV       = comboboxMaNV.Text;
         newpNk._maKho      = comboBoxMaKho.Text;
         newpNk._maPhieuQli = txtmphieu.Text;
         newpNk._tinhTrang  = comboTinhTrang.Text;
         newpNk._ngayLapQLi = dtpNgayLap.Value;
         int kq = bllpqlk.AddAllPhieuQLK(newpNk);
         if (kq == 1)
         {
             MessageBox.Show("Thêm thành công!!!");
         }
         else
         {
             MessageBox.Show("Trùng mã phiếu!!");
         }
         listpqlk = bllpqlk.getAllPQLKho();
         //listtp = blltp.getthuephongbymaphong(txtmaphong.Text);
         duadulieulendgvCTPQL(dgvPQLK, listpqlk);
         chedobutton(true);
         chedotextbox(false);
         btnthem.Text = "Thêm";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 public bool DeletePhieuQLK(ePhieuQLiKho delid)
 {
     try
     {
         Tbl_PhieuQLKho deletema = DB.Tbl_PhieuQLKhos.Single(x => x.maPhieuQL == delid._maPhieuQli);
         DB.Tbl_PhieuQLKhos.DeleteOnSubmit(deletema);
         DB.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public List <ePhieuQLiKho> getAllPQLKho()
        {
            var dspqlk             = DB.Tbl_PhieuQLKhos.ToList();
            List <ePhieuQLiKho> ls = new List <ePhieuQLiKho>();

            foreach (Tbl_PhieuQLKho temppqlk in dspqlk)
            {
                ePhieuQLiKho pqlk = new ePhieuQLiKho();
                pqlk._maPhieuQli = temppqlk.maPhieuQL;
                pqlk._ngayLapQLi = Convert.ToString(temppqlk.ngayLapQL);
                pqlk._maNV       = temppqlk.maNV;
                pqlk._maKho      = temppqlk.msKho;
                pqlk._tinhTrang  = temppqlk.tinhTrang;
                ls.Add(pqlk);
            }
            return(ls);
        }
Beispiel #4
0
        public int AddAllPhieuQLK(ePhieuQLiKho newpqlk)
        {
            if (Kiemtrasutontai(newpqlk._maPhieuQli))
            {
                return(0);
            }
            Tbl_PhieuQLKho pqlk = new Tbl_PhieuQLKho();

            pqlk.maPhieuQL = newpqlk._maPhieuQli;
            pqlk.ngayLapQL = newpqlk._ngayLapQLi;
            pqlk.maNV      = newpqlk._maNV;
            pqlk.tinhTrang = newpqlk._tinhTrang;
            pqlk.msKho     = newpqlk._maKho;
            DB.Tbl_PhieuQLKhos.InsertOnSubmit(pqlk);
            DB.SubmitChanges();
            return(1);
        }
 public bool UpDatePhieuQLK(ePhieuQLiKho updatepqlk)
 {
     try
     {
         Tbl_PhieuQLKho pqlk = DB.Tbl_PhieuQLKhos.Single(x => x.maPhieuQL == updatepqlk._maPhieuQli);
         pqlk.maPhieuQL = updatepqlk._maPhieuQli;
         pqlk.maNV      = updatepqlk._maNV;
         pqlk.ngayLapQL = Convert.ToDateTime(updatepqlk._ngayLapQLi);
         pqlk.tinhTrang = updatepqlk._tinhTrang;
         pqlk.msKho     = updatepqlk._maKho;
         DB.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public bool AddAllPhieuQLK(ePhieuQLiKho newpqlk)
 {
     try
     {
         Tbl_PhieuQLKho pqlk = DB.Tbl_PhieuQLKhos.Single(x => x.maPhieuQL == newpqlk._maPhieuQli);
         pqlk.maPhieuQL = newpqlk._maPhieuQli;
         pqlk.ngayLapQL = Convert.ToDateTime(newpqlk._ngayLapQLi);
         pqlk.maNV      = newpqlk._maNV;
         pqlk.tinhTrang = newpqlk._tinhTrang;
         DB.Tbl_PhieuQLKhos.InsertOnSubmit(pqlk);
         DB.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        private void btnxoa_Click(object sender, EventArgs e)
        {
            ePhieuQLiKho qlk = new ePhieuQLiKho();

            qlk._maPhieuQli = txtmphieu.Text;
            qlk._ngayLapQLi = txtngaylap.Text;
            qlk._maNV       = txtmanv.Text;
            qlk._maKho      = txtmakho.Text;
            qlk._tinhTrang  = txttinhtrang.Text;
            bool kq = pqlkBLL.DeletePhieuQLK(qlk);

            if (kq == false)
            {
                MessageBox.Show("Không có mã để xóa!", "Thông báo!");
            }
            else
            {
                MessageBox.Show("Xóa thành công!", "Thông báo!");
                dataPQLK.DataSource = pqlkBLL.getAllPQLKho();
            }
        }