private void btnEdit_Click(object sender, EventArgs e) { try { if (ValidateData() == true) { Permits aPermits = new Permits(); aPermits.ID = ID_Old; aPermits.IsAdmin = cbxIsAdmin.Checked; aPermits.Name = txtName.Text; aPermits.IsContent = cbxIsContent.Checked; aPermits.IsPartner = cbxIsPartner.Checked; aPermits.Type = int.Parse(cbbType.Text); aPermits.Status = int.Parse(cbbStatus.Text); aPermits.Disable = bool.Parse(cbbDisable.Text); aPermitsBO.Update(aPermits); MessageBox.Show("Sửa permit thành công"); afrmLst_Permits_Old.Reload(); this.Close(); } } catch (Exception ex) { MessageBox.Show("frmUpd_Permits.btnEdit_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int Ins(Permits aPermits) { try { _aDatabaseDa.Permits.AddOrUpdate(aPermits); return _aDatabaseDa.SaveChanges(); } catch (Exception ex) { throw new Exception(String.Format("PermitsBO.Ins: {0}", ex.Message)); } }
private void btnAdd_Click(object sender, EventArgs e) { Permits aPermits = new Permits(); aPermits.IsAdmin = cbxIsAdmin.Checked; aPermits.Name = txtName.Text; aPermits.IsContent = cbxIsContent.Checked; aPermits.IsPartner = cbxIsPartner.Checked; aPermits.Type = int.Parse(cbbType.Text); aPermits.Status = int.Parse(cbbStatus.Text); aPermits.Disable = bool.Parse(cbbDisable.Text); aPermitsBO.Insert(aPermits); MessageBox.Show("Thêm permit thành công"); afrmLst_Permits_Old.Reload(); this.Close(); }
private void btnEdit_Click(object sender, EventArgs e) { try { Permits aPermits = new Permits(); aPermits.ID = ID_Old; aPermits.IsAdmin = cbxIsAdmin.Checked; aPermits.Name = txtName.Text; aPermits.IsContent = cbxIsContent.Checked; aPermits.IsPartner = cbxIsPartner.Checked; aPermits.Type = int.Parse(cbbType.Text); aPermits.Status = int.Parse(cbbStatus.Text); aPermits.Disable = bool.Parse(cbbDisable.Text); aPermitsBO.Update(aPermits); MessageBox.Show("Sửa permit thành công"); afrmLst_Permits_Old.Reload(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Upd_ByID(HttpContext context) { String jSonString = ""; try { Permits aPermits = new Permits(); int idPermits = Convert.ToInt32(context.Request.Form["txtID"]); aPermits.ID = idPermits; aPermits.Name = !String.IsNullOrEmpty(context.Request.Form["txtName"]) ? Convert.ToString(context.Request.Form["txtName"]) : aPermits.Name; aPermits.SystemKey = !String.IsNullOrEmpty(context.Request.Form["txtSystemKey"]) ? Convert.ToString(context.Request.Form["txtSystemKey"]) : aPermits.SystemKey; aPermits.IsAdmin = !String.IsNullOrEmpty(context.Request.Form["cbbIsAdmin"]) ? Convert.ToBoolean(context.Request.Form["cbbIsAdmin"]) : aPermits.IsAdmin; aPermits.IsContent = !String.IsNullOrEmpty(context.Request.Form["cbbIsContent"]) ? Convert.ToBoolean(context.Request.Form["cbbIsContent"]) : aPermits.IsContent; aPermits.IsPartner = !String.IsNullOrEmpty(context.Request.Form["cbbIsPartner"]) ? Convert.ToBoolean(context.Request.Form["cbbIsPartner"]) : aPermits.IsPartner; aPermits.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : aPermits.Type; aPermits.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : aPermits.Status; aPermits.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : aPermits.Disable; PermitsBO aPermitsBo = new PermitsBO(); int ret = aPermitsBo.Upd(aPermits); if (ret != 0) jSonString = "{\"status\": \"success\"}"; if (ret == 0) jSonString = "{\"status\":\"error|" + ret + "\"}"; } catch (Exception ex) { jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message + "\"}"; } finally { context.Response.Write(jSonString); } }
private void Ins(HttpContext context) { String jSonString = ""; try { Permits permits = new Permits { Name = !String.IsNullOrEmpty(context.Request.Form["txtName"]) ? Convert.ToString(context.Request.Form["txtName"]) : "", IsAdmin = !String.IsNullOrEmpty(context.Request.Form["cbbIsAdmin"]) ? Convert.ToBoolean(context.Request.Form["cbbIsAdmin"]) : false, IsContent = !String.IsNullOrEmpty(context.Request.Form["cbbIsContent"]) ? Convert.ToBoolean(context.Request.Form["cbbIsContent"]) : false, IsPartner = !String.IsNullOrEmpty(context.Request.Form["cbbIsPartner"]) ? Convert.ToBoolean(context.Request.Form["cbbIsPartner"]) : false, Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : 0, Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : 0, SystemKey = !String.IsNullOrEmpty(context.Request.Form["txtSystemKey"]) ? Convert.ToString(context.Request.Form["txtSystemKey"]) : "", Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : false }; PermitsBO permitsBo = new PermitsBO(); int ret = permitsBo.Ins(permits); if (ret != 0) jSonString = "{\"status\": \"success\"}"; if (ret == 0) jSonString = "{\"status\":\"error|" + ret + "\"}"; } catch (Exception ex) { jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message + "\"}"; } finally { context.Response.Write(jSonString); } }
//----------------Update BookingRooms ----------------------------- public int Update(Permits aPermits) { try { aDatabaseDA.Permits.AddOrUpdate(aPermits); return aDatabaseDA.SaveChanges(); } catch (Exception ex) { throw new Exception("PermitsBO.Update:" + ex.ToString()); } }
//-----------------Add New --------------------------------- public int Insert(Permits aPermits) { try { aDatabaseDA.Permits.Add(aPermits); return aDatabaseDA.SaveChanges(); } catch (Exception ex) { throw new Exception("PermitsBO.Insert:" + ex.ToString()); } }