コード例 #1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                CHITIET_PHIEUNHAP c = new CHITIET_PHIEUNHAP();
                c.SOPN = txtSOPN.Text;
                c.MAHH = txtMAHH.Text;

                if (bllCTPN.DeleteCTPN(c))
                {
                    ShowAllCTPN();
                }
                else
                {
                    MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #2
0
        public bool DeleteCTPN(CHITIET_PHIEUNHAP c)
        {
            string        sql = "DELETE CHITIET_PHIEUNHAP WHERE SOPN = @SOPN AND MAHH = @MAHH";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@SOPN", SqlDbType.NChar).Value = c.SOPN;
                cmd.Parameters.Add("@MAHH", SqlDbType.NChar).Value = c.MAHH;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
コード例 #3
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            CHITIET_PHIEUNHAP c = new CHITIET_PHIEUNHAP();

            c.SOPN     = txtSOPN.Text;
            c.MAHH     = txtMAHH.Text;
            c.SLGIAO   = int.Parse(txtSLGIAO.Text);
            c.SLNHAN   = int.Parse(txtSLNHAN.Text);
            c.DONGIA   = int.Parse(txtDONGIA.Text);
            c.SOHIEUDH = txtSOHIEUDH.Text;

            if (bllCTPN.UpdateCTPN(c))
            {
                ShowAllCTPN();
            }
            else
            {
                MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        public bool UpdateCTPN(CHITIET_PHIEUNHAP c)
        {
            string        sql = "UPDATE CHITIET_PHIEUNHAP SET MAHH = @MAHH, SLNHAN = @SLNHAN, SLGIAO = @SLGIAO, DONGIA = @DONGIA, SOHIEUDH = @SOHIEUDH WHERE SOPN = @SOPN AND MAHH = @MAHH";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@SOPN", SqlDbType.NChar).Value     = c.SOPN;
                cmd.Parameters.Add("@MAHH", SqlDbType.NChar).Value     = c.MAHH;
                cmd.Parameters.Add("@SLGIAO", SqlDbType.Int).Value     = c.SLGIAO;
                cmd.Parameters.Add("@SLNHAN", SqlDbType.Int).Value     = c.SLNHAN;
                cmd.Parameters.Add("@DONGIA", SqlDbType.Int).Value     = c.DONGIA;
                cmd.Parameters.Add("@SOHIEUDH", SqlDbType.NChar).Value = c.SOHIEUDH;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
コード例 #5
0
        public bool InsertCTPN(CHITIET_PHIEUNHAP c)
        {
            string        sql = "INSERT INTO CHITIET_PHIEUNHAP(SOPN, MAHH, SLGIAO, SLNHAN, DONGIA, SOHIEUDH) VALUES(@SOPN, @MAHH, @SLGIAO, @SLNHAN, @DONGIA, @SOHIEUDH)";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@SOPN", SqlDbType.NChar).Value     = c.SOPN;
                cmd.Parameters.Add("@MAHH", SqlDbType.NChar).Value     = c.MAHH;
                cmd.Parameters.Add("@SLGIAO", SqlDbType.Int).Value     = c.SLGIAO;
                cmd.Parameters.Add("@SLNHAN", SqlDbType.Int).Value     = c.SLNHAN;
                cmd.Parameters.Add("@DONGIA", SqlDbType.Int).Value     = c.DONGIA;
                cmd.Parameters.Add("@SOHIEUDH", SqlDbType.NChar).Value = c.SOHIEUDH;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch
            {
                return(false);
            }
            return(true);
        }
コード例 #6
0
 public bool DeleteCTPN(CHITIET_PHIEUNHAP c)
 {
     return(dalCTPN.DeleteCTPN(c));
 }
コード例 #7
0
 public bool UpdateCTPN(CHITIET_PHIEUNHAP c)
 {
     return(dalCTPN.UpdateCTPN(c));
 }
コード例 #8
0
 public bool InsertCTPN(CHITIET_PHIEUNHAP c)
 {
     return(dalCTPN.InsertCTPN(c));
 }