Exemplo n.º 1
0
        public bool UpdateSLNK(NhapKho_DTO NK)
        {
            try
            {
                con.Open();
                string SQL = "UPDATE NHAPKHO SET SLNHAP= SLNHAP + " + NK.SLNHAP + ",GIANHAP = GIANHAP + " + NK.GIANHAP
                             + "WHERE MASP =" + NK.MASP + " AND NGAYNHAP ='" + NK.NGAYNHAP
                             + "' AND NGNHAP =" + NK.NGNHAP;

                SqlCommand cmd = new SqlCommand(SQL, con);
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }

            catch (Exception e)
            { }

            finally
            {
                con.Close();
            }

            return(false);
        }
Exemplo n.º 2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            int    MASP     = int.Parse(txtID.Text);
            string TenSP    = txtTen.Text;
            int    SLNHAP   = int.Parse(txtSL.Text);
            string NgayNhap = txtNgaynhap.Value.Date.ToString("yyyy/MM/dd");
            string GiaNhap  = txtGiaNhap.Text;
            string TongTien = txtTongTien.Text;
            int    MANGNHAP = nv_BUS.getMANV(TENNV);

            if (txtNgaynhap.Value <= DateTime.Now)
            {
                if (sp_BUS.CheckTonTai(MASP, TenSP) == false)
                {
                    MessageBox.Show("Vui lòng kiểm tra lại hoặc chưa thêm phụ tùng vào kho!");
                }
                else
                {
                    NhapKho_DTO nk = new NhapKho_DTO(NgayNhap, MASP, MANGNHAP, SLNHAP, TongTien);
                    if (nk_BUS.checkSPNhap(MASP, NgayNhap, MANGNHAP) == true)
                    {
                        if (nk_BUS.UpdateSLNK(nk))
                        {
                            sp_BUS.UpdateSL(nk.MASP, SLNHAP);
                            NhapHang_GUI_Load(sender, e);
                            MessageBox.Show("Cập nhật hàng thành công!");
                        }
                        else
                        {
                            MessageBox.Show("Cập nhật hàng thất bại!");
                        }
                    }
                    else
                    {
                        if (nk_BUS.Insert(nk))
                        {
                            sp_BUS.UpdateSL(nk.MASP, SLNHAP);
                            NhapHang_GUI_Load(sender, e);
                            MessageBox.Show("Nhập hàng thành công!");
                        }
                        else
                        {
                            MessageBox.Show("Nhập hàng thất bại!");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Ngày nhập phải bằng hoặc bé hơn ngày hiện tại!");
            }
        }
Exemplo n.º 3
0
        public bool Insert(NhapKho_DTO NK)
        {
            try
            {
                con.Open();
                string     SQL = "INSERT INTO NHAPKHO VALUES ('" + NK.NGAYNHAP + "'," + NK.MASP + "," + NK.NGNHAP + "," + NK.SLNHAP + "," + NK.GIANHAP + ")";
                SqlCommand cmd = new SqlCommand(SQL, con);
                if (cmd.ExecuteNonQuery() > 0)
                {
                    return(true);
                }
            }

            catch (Exception e)
            { }

            finally
            {
                con.Close();
            }

            return(false);
        }
Exemplo n.º 4
0
 public bool UpdateSLNK(NhapKho_DTO NK)
 {
     return(sp_dal.UpdateSLNK(NK));
 }
Exemplo n.º 5
0
 public bool Insert(NhapKho_DTO NK)
 {
     return(sp_dal.Insert(NK));
 }