示例#1
0
        private void btnXOA_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có chắc chắn muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                NHACUNGCAP ncc = new NHACUNGCAP();
                ncc.MANCC = txtMANCC.Text;


                if (bllNCC.DeleteNCC(ncc))
                {
                    ShowAllNCC();
                }
                else
                {
                    MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#2
0
        private void btnSUA_Click(object sender, EventArgs e)
        {
            NHACUNGCAP ncc = new NHACUNGCAP();

            ncc.MANCC     = txtMANCC.Text;
            ncc.TENNCC    = txtTENNCC.Text;
            ncc.DIACHINCC = txtDIACHINCC.Text;
            ncc.SDTNCC    = int.Parse(txtSDTNCC.Text);

            if (bllNCC.UpdateNCC(ncc))
            {
                ShowAllNCC();
            }
            else
            {
                MessageBox.Show("Lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public bool DeleteNCC(NHACUNGCAP ncc)
        {
            string        sql = "DELETE NHACUNGCAP WHERE MANCC = @MANCC ";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MANCC", SqlDbType.NChar).Value = ncc.MANCC;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
        public bool UpdateNCC(NHACUNGCAP ncc)
        {
            string        sql = "UPDATE NHACUNGCAP SET MANCC = @MANCC, TENNCC = @TENNCC, DIACHINCC = @DIACHINCC, SDTNCC = @SDTNCC WHERE MANCC = @MANCC ";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MANCC", SqlDbType.NChar).Value        = ncc.MANCC;
                cmd.Parameters.Add("@TENNCC", SqlDbType.NVarChar).Value    = ncc.TENNCC;
                cmd.Parameters.Add("@DIACHINCC", SqlDbType.NVarChar).Value = ncc.DIACHINCC;
                cmd.Parameters.Add("@SDTNCC", SqlDbType.Int).Value         = ncc.SDTNCC;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
        public bool InsertNCC(NHACUNGCAP ncc)
        {
            string        sql = "INSERT INTO NHACUNGCAP(MANCC, TENNCC, DIACHINCC, SDTNCC) VALUES(@MANCC, @TENNCC, @DIACHINCC, @SDTNCC)";
            SqlConnection con = dc.getConnect();

            try
            {
                cmd = new SqlCommand(sql, con);
                con.Open();
                cmd.Parameters.Add("@MANCC", SqlDbType.NChar).Value        = ncc.MANCC;
                cmd.Parameters.Add("@TENNCC", SqlDbType.NVarChar).Value    = ncc.TENNCC;
                cmd.Parameters.Add("@DIACHINCC", SqlDbType.NVarChar).Value = ncc.DIACHINCC;
                cmd.Parameters.Add("@SDTNCC", SqlDbType.Int).Value         = ncc.SDTNCC;
                cmd.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
示例#6
0
 public bool DeleteNCC(NHACUNGCAP ncc)
 {
     return(dalNCC.DeleteNCC(ncc));
 }
示例#7
0
 public bool UpdateNCC(NHACUNGCAP ncc)
 {
     return(dalNCC.UpdateNCC(ncc));
 }
示例#8
0
 public bool InsertNCC(NHACUNGCAP ncc)
 {
     return(dalNCC.InsertNCC(ncc));
 }