private void btnLuu_Click(object sender, EventArgs e) { string bienSo = this.txtBienSo.Text; string userID = this.cbbKhachHang.SelectedValue.ToString(); string dongXe = this.cbbDongXe.SelectedValue.ToString(); string mota = this.txtMoTa.Text; string mau = this.colorMauXe.Text; string mauTrong = this.colorMauNoiThat.Text; string namSX = this.txtNamSX.Text; string xuatXu = this.txtXuatXu.Text; if (bienSo == "" || userID == "" || dongXe == "" || mau == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int userId = 1; try { userId = Int32.Parse(userID); } catch { MessageBox.Show("Vui lòng kiểm tra lại Dòng xe ID và ID chủ xe!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Entity_Xe _xe = new Entity_Xe(bienSo, userId, dongXe, mau, mota, mauTrong, namSX, xuatXu); if (xe.insertXe(_xe) == true) { MessageBox.Show("Thêm thành công Xe " + _xe.BienSo, "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); gwXe.DataSource = xe.getData(); this.txtBienSo.Enabled = false; } else { if (xe.updateXe(_xe) == true) { MessageBox.Show("Sửa thành công Xe " + _xe.BienSo, "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); gwXe.DataSource = xe.getData(); } else { MessageBox.Show("Không thể thêm!", "Thông Báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
public bool updateXe(Entity_Xe _xe) { try { const string strSQL = "SP_UPDATE_XE"; string[] pNames = { "@bs", "@userId", "@ngayTN", "@dongXeId", "@mau", "@mota", "@mauTrong", "@namXX", "@xuatXu" }; object[] pValues = { _xe.BienSo, _xe.User_id, _xe.NgayTn, _xe.DongXeId, _xe.MauXe, _xe.MoTa, _xe.MauNoiThat, _xe.NamSx, _xe.XuatSu }; int count = con.ExecuteStoredProcedure(strSQL, pNames, pValues); if (count >= 0) { return(true); } else { return(false); } } catch { return(false); } }
public bool updateXe(Entity_Xe _xe) { return(xe.updateXe(_xe)); }
public bool insertXe(Entity_Xe _xe) { return(xe.insertXe(_xe)); }