Example #1
0
        public static List <PhieuGuiDTO> LoadPhieuGui()
        {
            string sQuery = @"SELECT * FROM PhieuGui, CoQuan WHERE PhieuGui.MaCQ = CoQuan.MaCQ";

            con = DataProvider.Connect();
            DataTable dt = DataProvider.LayDataTable(sQuery, con);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            List <PhieuGuiDTO> lstpg = new List <PhieuGuiDTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PhieuGuiDTO pg = new PhieuGuiDTO();
                pg.IMaPG     = int.Parse(dt.Rows[i]["MaPG"].ToString());
                pg.DtNgayGui = DateTime.Parse(dt.Rows[i]["NgayGui"].ToString());
                pg.SNguoiGui = dt.Rows[i]["NguoiGui"].ToString();
                pg.IMaCQ     = int.Parse(dt.Rows[i]["MaCQ"].ToString());
                pg.STenCQ    = dt.Rows[i]["TenCQ"].ToString();
                lstpg.Add(pg);
            }
            DataProvider.CloseConnect(con);
            return(lstpg);
        }
Example #2
0
        public static bool SuaPhieuGui(PhieuGuiDTO pgDTO)
        {
            string sQuery = string.Format("UPDATE PhieuGui SET NgayGui=N'{0}', NguoiGui=N'{1}', MaCQ={2} WHERE MaPG={3}", pgDTO.DtNgayGui, pgDTO.SNguoiGui, pgDTO.IMaCQ, pgDTO.IMaPG);

            con = DataProvider.Connect();
            try
            {
                DataProvider.ExecuteQueriesNonQuery(sQuery, con);
                DataProvider.CloseConnect(con);
                return(true);
            }
            catch (Exception ex) { DataProvider.CloseConnect(con); return(false); }
        }
Example #3
0
        public static bool XoaPhieuGui(PhieuGuiDTO pgDTO)
        {
            string sQuery = string.Format("DELETE FROM PhieuGui WHERE MapG={0}", pgDTO.IMaPG);

            con = DataProvider.Connect();
            try
            {
                DataProvider.ExecuteQueriesNonQuery(sQuery, con);
                DataProvider.CloseConnect(con);
                return(true);
            }
            catch (Exception ex) { DataProvider.CloseConnect(con); return(false); }
        }
Example #4
0
        public static bool ThemPhieuGui(PhieuGuiDTO pgDTO)
        {
            string sQuery = string.Format(@"INSERT INTO PhieuGui VALUES (N'{0}', N'{1}', {2})", pgDTO.DtNgayGui, pgDTO.SNguoiGui, pgDTO.IMaCQ);

            con = DataProvider.Connect();
            try
            {
                DataProvider.ExecuteQueriesNonQuery(sQuery, con);
                DataProvider.CloseConnect(con);
                return(true);
            }
            catch (Exception ex) { DataProvider.CloseConnect(con); return(false); }
        }
Example #5
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            PhieuGuiDTO pgDTO = new PhieuGuiDTO();

            pgDTO.IMaPG     = int.Parse(txtMaPG.Text);
            pgDTO.DtNgayGui = DateTime.Parse(dtpNgayGui.Text);
            pgDTO.SNguoiGui = txtNguoiGui.Text;
            pgDTO.IMaCQ     = int.Parse(cbCoQuan.SelectedValue.ToString());
            if (PhieuGuiBLL.SuaPhieuGui(pgDTO))
            {
                MessageBox.Show("Sửa thành công.", "Thông báo!");
                LoadPhieuGui();
                return;
            }
            MessageBox.Show("Sửa thất bại.", "Thông báo!");
        }
Example #6
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (txtMaPG.Text == "")
            {
                MessageBox.Show("Hãy chọn đơn vị nhận cần xóa.", "Thông báo!");
                return;
            }
            PhieuGuiDTO pgDTO = new PhieuGuiDTO();

            pgDTO.IMaPG = int.Parse(txtMaPG.Text);
            if (PhieuGuiBLL.XoaPhieuGui(pgDTO))
            {
                MessageBox.Show("Xóa thành công.", "Thông báo!");
                LoadPhieuGui();
                return;
            }
            MessageBox.Show("Xóa thất bại.", "Thông báo!");
        }
Example #7
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtNguoiGui.Text == "")
            {
                MessageBox.Show("Bạn phải nhập đày đủ thông tin.", "Thông báo!");
                return;
            }
            PhieuGuiDTO pgDTO = new PhieuGuiDTO();

            pgDTO.DtNgayGui = DateTime.Parse(dtpNgayGui.Text);
            pgDTO.SNguoiGui = txtNguoiGui.Text;
            pgDTO.IMaCQ     = int.Parse(cbCoQuan.SelectedValue.ToString());
            if (PhieuGuiBLL.ThemPhieuGui(pgDTO))
            {
                MessageBox.Show("Thêm thành công.", "Thông báo!");
                LoadPhieuGui();
                return;
            }
            MessageBox.Show("Thêm thất bại.", "Thông báo!");
        }
Example #8
0
 public static bool SuaPhieuGui(PhieuGuiDTO pgDTO)
 {
     return(PhieuGuiDAL.SuaPhieuGui(pgDTO));
 }
Example #9
0
 public static bool ThemPhieuGui(PhieuGuiDTO pgDTO)
 {
     return(PhieuGuiDAL.ThemPhieuGui(pgDTO));
 }