Example #1
0
        public int Thempb(PhongbanPublic p)
        {
            int Nparameter = 4;

            string[] name  = new string[Nparameter];
            string[] value = new string[Nparameter];
            name[0]  = "@MAPB";
            name[1]  = "@TENPB";
            name[2]  = "@TENNDN";
            name[3]  = "@PASS";
            value[0] = p.Mapb;
            value[1] = p.Tenpb;
            value[2] = p.Tenndn;
            value[3] = p.Pass;
            return(cn.Update("insert into PHONGBAN values(@MAPB,@TENPB,@TENNDN,@PASS)", name, value, Nparameter));
        }
Example #2
0
        public int Suapb(PhongbanPublic p)
        {
            int Nparameter = 4;

            string[] name  = new string[Nparameter];
            string[] value = new string[Nparameter];
            name[0]  = "@MAPB";
            name[1]  = "@TENPB";
            name[2]  = "@TENNDN";
            name[3]  = "@PASS";
            value[0] = p.Mapb;
            value[1] = p.Tenpb;
            value[2] = p.Tenndn;
            value[3] = p.Pass;

            return(cn.Update("update PHONGBAN set MAPB=@MAPB,TENPB=@TENPB,TENNDN=@TENNDN,PASS=@PASS where MAPB=@MAPB", name, value, Nparameter));
        }
Example #3
0
 public int Suaphongban(PhongbanPublic p)
 {
     return(cls.Suapb(p));
 }
Example #4
0
 public int Themphongban(PhongbanPublic p)
 {
     return(cls.Thempb(p));
 }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (IorU == true)
            {
                try
                {
                    bool checklbl = true;
                    if (txtId.Text == "" && txtName.Text == "")
                    {
                        MessageBox.Show("Nhập giá trị cho phòng ban", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        checklbl = false;
                    }
                    if (checklbl == true)
                    {
                        PhongbanBUL    cls = new PhongbanBUL();
                        PhongbanPublic p   = new PhongbanPublic();
                        p.Mapb   = txtId.Text;
                        p.Tenpb  = txtName.Text;
                        p.Tenndn = txtInterest.Text;
                        p.Pass   = txtPass.Text;
                        cls.Themphongban(p);
                    }
                }
                catch
                {
                    MessageBox.Show("Lỗi, không thêm được");
                }
            }
            else if (IorU == false)
            {
                try
                {
                    PhongbanPublic p   = new PhongbanPublic();
                    PhongbanBUL    cls = new PhongbanBUL();
                    p.Mapb   = txtId.Text;
                    p.Tenpb  = txtName.Text;
                    p.Tenndn = txtInterest.Text;
                    p.Pass   = txtPass.Text;
                    cls.Suaphongban(p);

                    for (int i = 0; i < chuatextbox.Count(); i++)
                    {
                        chuatextbox[i].DataBindings.Clear();
                    }
                }
                catch
                {
                    MessageBox.Show("Lỗi, không sửa được");
                }
            }

            btnInsert.Enabled = true;
            btnUpdate.Enabled = true;

            for (int i = 0; i < 4; i++)
            {
                chuatextbox[i].Enabled = false;
                chuatextbox[i].Clear();
            }
            frmPhongban_Load(sender, e);
        }