public ActionResult ModifyVipService(VIPDto vip) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_VIPs theVIP = db.T_VIPs.FirstOrDefault(a => a.ServerID == vip.ServerID); theVIP.ServerName = vip.ServerName; theVIP.Contact = vip.Contact; theVIP.Tel = vip.Tel; theVIP.Remark = vip.Remark; theVIP.SupplierID = vip.SupplierID; db.T_VIPs.Attach(theVIP); db.Entry(theVIP).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); result.Code = SystemConst.MSG_SUCCESS; } catch (Exception exception) { result.Message = exception.Message; } return(Content(AppUtils.JsonSerializer(result))); } }
private void btnSave_Click(object sender, EventArgs e) { if (!ClientUtils.CheckEmpty(txtName, "EMPTY_VIP_NAME")) { return; } int id = isModify ? vip.ServerID: 0; VIPDto param = new VIPDto { ServerID = id, SupplierID = supplierID, ServerName = txtName.Text, Contact = txtContact.Text, Tel = txtTel.Text, Remark = txtRemark.Text, }; string strResult = WebCall.PostMethod <VIPDto>(isModify ? WebCall.ModifyVips : WebCall.AddVips, param); WebResult result = AppUtils.JsonDeserialize <WebResult>(strResult); if (result.Code.Equals(SystemConst.MSG_SUCCESS)) { ClientUtils.WarningCode(Travel.Client.Lang.LangBase.GetString(isModify ? "MODIFY_VIP_SUCCESS" : "ADD_VIP_SUCCESS") + result.Message); this.DialogResult = DialogResult.OK; this.Close(); } else { ClientUtils.WarningCode(result.Message); } }
public ActionResult AddNewVipService(VIPDto vip) { WebResult result = new WebResult { Code = SystemConst.MSG_ERR_UNKNOWN, Message = string.Empty }; using (var db = new TravelEntities()) { try { T_VIPs newVip = new T_VIPs { ServerName = vip.ServerName, Tel = vip.Tel, SupplierID = vip.SupplierID, Contact = vip.Contact, Remark = vip.Remark }; db.T_VIPs.Add(newVip); db.SaveChanges(); result.Code = SystemConst.MSG_SUCCESS; } catch (Exception exception) { result.Message = exception.Message; } return(Content(AppUtils.JsonSerializer(result))); } }
public AddVip(VIPDto selectedVip) { InitializeComponent(); isModify = true; vip = selectedVip; txtName.Text = vip.ServerName; txtTel.Text = vip.Tel; txtContact.Text = vip.Contact; txtRemark.Text = vip.Remark; supplierID = vip.SupplierID; }