Exemplo n.º 1
0
 private void btnThemPX_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult result;
         result = MessageBox.Show("Bạn Có Muốn Thêm" +
                                  " Phiếu Xuất  ?",
                                  "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
         if (result == DialogResult.Yes)
         {
             if (cboMaKH.SelectedIndex != -1)
             {
                 string   mapx    = "PX";
                 string   makh    = cboMaKH.SelectedValue.ToString();
                 string   manv    = nv.MANV;
                 DateTime ngaylap = DateTime.Now;
                 px_bll.ThemPhieuXuat(mapx, makh, nv.MANV, ngaylap);
                 MessageBox.Show("Tạo Thành Công Phiếu Nhập " + mapx + "Thông báo");
                 clear_PX();
                 loadDataPX();
                 loadCBO_PX();
             }
         }
         else
         {
             MessageBox.Show("Có Thông Tin Còn Bỏ Trống", "Thông báo");
         }
         loadDataPX();
         loadCBO_PX();
     }
     catch
     {
         MessageBox.Show("Lỗi", "Thông báo");
     }
 }
        private void ktThemPX()
        {
            try
            {
                PhieuXuat_DTO px = new PhieuXuat_DTO();
                px.MaPX       = txtMaPX.Text.Trim();
                px.NgayXuat   = DateTime.Parse(dtpNgayXuat.Text.ToString());
                px.NguoiNhan  = txtNguoiNhan.Text.Trim();
                px.DiaChi     = txtDiaChi.Text.Trim();
                px.GhiChuXuat = txtGhiChuXuat.Text.Trim();
                kiemtra_rong();

                if (pxBLL.ThemPhieuXuat(px))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Load_PhieuXuat();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }