Beispiel #1
0
 void gandulieu(ClassNhanVien nv)
 {
     nv.Ma = txtMaNV.Text.Trim();
     if (cbGioiTinh.SelectedIndex == 0)
     {
         nv.Gioitinh = "Nam";
     }
     else
     {
         nv.Gioitinh = "Nữ";
     }
     nv.Gioitinh = cbGioiTinh.Text.Trim();
     nv.Diachi   = txtDiaChi.Text.Trim();
     nv.Sdt      = txtSDT.Text.Trim();
     nv.Ten      = txtTenNV.Text.Trim();
 }
Beispiel #2
0
 public bool UpdateData(ClassNhanVien nv)
 {
     cmd.CommandText = "update tb_NV set TenNV= N'" + nv.Ten + "',GioiTinh=N'" + nv.Gioitinh + "',DiaChi=N'" + nv.Diachi + "',SDT='" + nv.Sdt + "' where MaNV='" + nv.Ma + "'";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         con.CloseConn();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
Beispiel #3
0
      public bool AddData(ClassNhanVien nv)
      {
          DataTable dt = new DataTable();

          cmd.CommandText = "insert into  tb_NV values ('" + nv.Ma + "',N'" + nv.Ten + "',N'" + nv.Gioitinh + "',N'" + nv.Diachi + "','" + nv.Sdt + "')";
          cmd.CommandType = CommandType.Text;
          cmd.Connection  = con.Connection;
          try
          {
              con.OpenConn();
              cmd.ExecuteNonQuery();
              con.CloseConn();
              return(true);
          }
          catch (Exception ex)
          {
              string mex = ex.Message;
              cmd.Dispose();
              con.CloseConn();
          }
          return(false);
      }
Beispiel #4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            ClassNhanVien nv2 = new ClassNhanVien();

            gandulieu(nv2);
            if (txtMaNV.Text == "" || txtTenNV.Text == "" || txtDiaChi.Text == "" || cbGioiTinh.Text == "" || txtSDT.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dis_end(true);
            }
            else
            {
                if (flag == 0)
                {
                    if (nvctrl.AddData(nv2))
                    {
                        MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    if (nvctrl.UpdData(nv2))
                    {
                        MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                dis_end(false);
                frmNhanVien_Load(sender, e);
            }
        }
Beispiel #5
0
 public bool UpdData(ClassNhanVien nv)
 {
     return(nvMod.UpdateData(nv));
 }
Beispiel #6
0
 public bool AddData(ClassNhanVien nv)
 {
     return(nvMod.AddData(nv));
 }