コード例 #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            TacGiaObj tgObj = new TacGiaObj();

            addData(tgObj);
            if (flagLuu == 0)
            {
                if (tgCtr.AddData(tgObj))
                {
                    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 (tgCtr.UpdData(tgObj))
                {
                    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);
                }
            }
            frmTacgia_Load(sender, e);
        }
コード例 #2
0
 private void addData(TacGiaObj tg)
 {
     tg.Ma     = txtMaTG.Text.Trim();
     tg.Ten    = txtTenTG.Text.Trim();
     tg.Diachi = txtDiaChi.Text.Trim();
     tg.Sodt   = txtSoDT.Text.Trim();
 }
コード例 #3
0
 public bool UpdData(TacGiaObj tgObj)
 {
     cmd.CommandText = "Update TacGia set TenTG =  N'" + tgObj.Ten + "', DiaChi = N'" + tgObj.Diachi + "',Email = '" + tgObj.Email + "',SoDT = '" + tgObj.Sodt + "' Where MaTG = '" + tgObj.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);
 }
コード例 #4
0
 public bool AddData(TacGiaObj tgObj)
 {
     cmd.CommandText = "Insert into TacGia values ('" + tgObj.Ma + "',N'" + tgObj.Ten + "',N'" + tgObj.Diachi + "','" + tgObj.Email + "','" + tgObj.Sodt + "')";
     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);
 }
コード例 #5
0
 public bool UpdData(TacGiaObj tgbObj)
 {
     return(tgMod.UpdData(tgbObj));
 }
コード例 #6
0
 public bool AddData(TacGiaObj tgbObj)
 {
     return(tgMod.AddData(tgbObj));
 }