示例#1
0
 public static int DeletePhieuNhap(PhieuNhapObjTr ctd)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@mapn", ctd.MaPN)
     };
     return(ConnectToSQLTr.ExecuteNonQuery("XoaPhieuNhap", para));
 }
示例#2
0
 public static int UpdatePhieuNhap(PhieuNhapObjTr ctd)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@mapn", ctd.MaPN),
         new SqlParameter("@ngaynhap", ctd.NgayNhap),
         new SqlParameter("@manv", ctd.MaNV),
         new SqlParameter("@mancc ", ctd.MaNCC),
         new SqlParameter("@tongtien", ctd.TongTien)
     };
     return(ConnectToSQLTr.ExecuteNonQuery("SuaPhieuNhap", para));
 }
示例#3
0
        private void lblMaPN_TextChanged(object sender, EventArgs e)
        {
            PhieuNhapObjTr hddvobj = new PhieuNhapObjTr();

            hddvobj.MaPN = label.Text.Trim();
        }
示例#4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_chucnang == "them")
                {
                    if (lblMaPN.Text == "" || cmbNhanVien.Text == "" || cmbNhaCC.Text == "")
                    {
                        MessageBox.Show("Chưa chọn thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        PhieuNhapObjTr hddvobj = new PhieuNhapObjTr();
                        hddvobj.MaPN     = lblMaPN.Text.Trim();
                        hddvobj.TongTien = float.Parse(lbltongtien.Text.Trim());
                        hddvobj.NgayNhap = dtpNgayLap.Value;
                        hddvobj.MaNV     = cmbNhanVien.SelectedValue.ToString();
                        hddvobj.MaNCC    = cmbNhaCC.SelectedValue.ToString();

                        if (MessageBox.Show(string.Format("Thêm Phiếu Nhập Hàng Có Mã Số Hóa Đơn {0}", hddvobj.MaPN), "Thông Báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            if (PhieuNhapCtrlTr.InsertPhieuNhap(hddvobj) > 0)
                            {
                                for (int i = 0; i < dtvChiTietPhieuNhap.Rows.Count; i++)
                                {
                                    ChiTietPhieuNhapObjTr cthddvobj = new ChiTietPhieuNhapObjTr();

                                    cthddvobj.MaSP      = dtvChiTietPhieuNhap.Rows[i].Cells[1].Value.ToString().Trim();
                                    cthddvobj.MaPN      = lblMaPN.Text;
                                    cthddvobj.ChungLoai = dtvChiTietPhieuNhap.Rows[i].Cells[3].Value.ToString().Trim();
                                    cthddvobj.SoLuong   = int.Parse(dtvChiTietPhieuNhap.Rows[i].Cells[4].Value.ToString());
                                    cthddvobj.DonGia    = float.Parse(dtvChiTietPhieuNhap.Rows[i].Cells[5].Value.ToString());
                                    cthddvobj.ThanhTien = float.Parse(dtvChiTietPhieuNhap.Rows[i].Cells[6].Value.ToString());
                                    ChiTietPhieuNhapCtrlTr.InsertPhieuNhap(cthddvobj);
                                }

                                MessageBox.Show("Thêm Phiếu Nhập thành công.", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                                this.cmbSanPham.Enabled         = false;
                                this.cmbChungLoai.Enabled       = false;
                                this.nudSoluong.Enabled         = false;
                                this.btnSanPham.Visible         = false;
                                this.btnLuu.Visible             = false;
                                this.btnHuy.Visible             = false;
                                this.btnThem.Visible            = true;
                                this.btnSua.Visible             = true;
                                this.btnXoa.Visible             = false;
                                this.btnIn.Visible              = true;
                                this.btntrolai.Visible          = true;
                                this.cmbNhanVien.DropDownStyle  = ComboBoxStyle.DropDownList;
                                this.cmbNhaCC.DropDownStyle     = ComboBoxStyle.DropDownList;
                                this.cmbChungLoai.DropDownStyle = ComboBoxStyle.DropDownList;
                                this.cmbNhaCC.Enabled           = false;
                                this.cmbNhanVien.Enabled        = false;
                                this.cmbChungLoai.Enabled       = false;
                                frmNhapHang_Load(sender, e);
                            }
                            else
                            {
                                MessageBox.Show("Mã Phiếu Nhập Đã Có,Vui Lòng Nhập Lại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                if (m_chucnang == "sua")
                {
                    if (lblMaPN.Text == "" || cmbNhanVien.Text == "" || cmbNhaCC.Text == "")
                    {
                        MessageBox.Show("Chưa chọn thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        PhieuNhapObjTr hddvobj = new PhieuNhapObjTr();
                        hddvobj.MaPN     = lblMaPN.Text.Trim();
                        hddvobj.TongTien = float.Parse(lbltongtien.Text.Trim());
                        hddvobj.NgayNhap = dtpNgayLap.Value;
                        hddvobj.MaNV     = cmbNhanVien.SelectedValue.ToString();
                        hddvobj.MaNCC    = cmbNhaCC.SelectedValue.ToString();
                        if (MessageBox.Show(string.Format("Sửa Phiếu Nhập Có Mã Số Hóa Đơn {0}", hddvobj.MaPN), "Thông Báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            if (PhieuNhapCtrlTr.UpdatePhieuNhap(hddvobj) > 0)
                            {
                                MessageBox.Show("Sửa thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                this.cmbSanPham.Enabled         = false;
                                this.cmbChungLoai.Enabled       = false;
                                this.nudSoluong.Enabled         = false;
                                this.btnSanPham.Visible         = false;
                                this.btnLuu.Visible             = false;
                                this.btnHuy.Visible             = false;
                                this.btnThem.Visible            = true;
                                this.btnSua.Visible             = true;
                                this.btnXoa.Visible             = false;
                                this.btnIn.Visible              = true;
                                this.btntrolai.Visible          = true;
                                this.cmbNhanVien.DropDownStyle  = ComboBoxStyle.DropDownList;
                                this.cmbNhaCC.DropDownStyle     = ComboBoxStyle.DropDownList;
                                this.cmbChungLoai.DropDownStyle = ComboBoxStyle.DropDownList;
                                this.cmbNhaCC.Enabled           = false;
                                this.cmbNhanVien.Enabled        = false;
                                this.cmbChungLoai.Enabled       = false;
                            }
                            else
                            {
                                MessageBox.Show("Không Sửa Được!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#5
0
 public static int DeletePhieuNhap(PhieuNhapObjTr ctd)
 {
     return(PhieuNhapTrMod.DeletePhieuNhap(ctd));
 }
示例#6
0
 public static int UpdatePhieuNhap(PhieuNhapObjTr ctd)
 {
     return(PhieuNhapTrMod.UpdatePhieuNhap(ctd));
 }
示例#7
0
 public static int InsertPhieuNhap(PhieuNhapObjTr ctd)
 {
     return(PhieuNhapTrMod.InsertPhieuNhap(ctd));
 }