Exemplo n.º 1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            TheLoaiObj tlObj = new TheLoaiObj();

            addData(tlObj);
            if (flagLuu == 0)
            {
                if (tlCtr.AddData(tlObj))
                {
                    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 (tlCtr.UpdData(tlObj))
                {
                    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);
                }
            }
            frmTheloai_Load(sender, e);
        }
 public bool UpdData(TheLoaiObj tlObj)
 {
     cmd.CommandText = "Update TheLoai set TenTL =  N'" + tlObj.Ten + "' Where MaTL = '" + tlObj.Ma + "'";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
 public bool AddData(TheLoaiObj tlObj)
 {
     cmd.CommandText = "Insert into TheLoai values ('" + tlObj.Ma + "',N'" + tlObj.Ten + "')";
     cmd.CommandType = CommandType.Text;
     cmd.Connection  = con.Connection;
     try
     {
         con.OpenConn();
         cmd.ExecuteNonQuery();
         return(true);
     }
     catch (Exception ex)
     {
         string mex = ex.Message;
         cmd.Dispose();
         con.CloseConn();
     }
     return(false);
 }
 public bool UpdData(TheLoaiObj tlbObj)
 {
     return(tlMod.UpdData(tlbObj));
 }
 public bool AddData(TheLoaiObj tlbObj)
 {
     return(tlMod.AddData(tlbObj));
 }
Exemplo n.º 6
0
 private void addData(TheLoaiObj tl)
 {
     tl.Ma  = txtMaTL.Text.Trim();
     tl.Ten = txtTenTL.Text.Trim();
 }