using Common; using Dao; using Model; using System; using System.Web; using System.Web.Profile; using System.Web.SessionState; public partial class GwRptCodeUpdate : PageBase, IRequiresSessionState { public RptCode CurrentCode { get; set; } public string Action { get; set; } protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack) return; this.Action = this.Request["action"]; if (this.Action == "addDeal") { this.CheckRight("1031", FailedOperation.ErrorMsgOnly); this.SaveAddForm(); } else if (this.Action == "editDeal") { this.CheckRight("1032", FailedOperation.ErrorMsgOnly); this.SaveEditForm(); } else if (this.Action == "edit") { this.CheckRight("1032", FailedOperation.ErrorMsgOnly); using (GwRptCodeDao gwRptCodeDao = new GwRptCodeDao()) { string oldCode = Convert.ToString(this.Request["OldCode"]); this.CurrentCode = gwRptCodeDao.GetRptCode(oldCode); } } else if (this.Action == "del") { this.CheckRight("1034", FailedOperation.ErrorMsgOnly); using (GwRptCodeDao gwRptCodeDao = new GwRptCodeDao()) { string spid = Convert.ToString(this.Request["Spid"]); if (gwRptCodeDao.DeleteAccount(spid)) { this.Response.Write(""); this.Response.End(); } else { this.Response.Write(""); this.Response.End(); } } } else if (this.Action == "delSelect") { this.CheckRight("1034", FailedOperation.ErrorMsgOnly); using (GwRptCodeDao gwRptCodeDao = new GwRptCodeDao()) { string[] strArray = Convert.ToString(this.Request["OldCode"]).Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); bool flag = false; foreach (string oldCode in strArray) { if (!gwRptCodeDao.DeleteCode(oldCode)) flag = true; } if (flag) { this.Response.Write(""); this.Response.End(); } else { this.Response.Write(""); this.Response.End(); } } } else { this.CheckRight("1031", FailedOperation.ErrorMsgOnly); this.CurrentCode = new RptCode(); } } /// /// 添加 /// protected void SaveAddForm() { RptAccount rc = new RptAccount(); rc.Spid = this.Request["Spid"]; rc.Proportion = this.Request["Proportion"]; rc.TimeSpan = this.Request["TimeSpan"]; rc.Threshold = this.Request["Threshold"]; rc.WhitePhone = this.Request["WhitePhone"]; using (GwRptCodeDao gwRptCodeDao = new GwRptCodeDao()) { if (string.IsNullOrEmpty(rc.Proportion) || (string.IsNullOrEmpty(rc.Proportion) )) { this.Response.Write(""); this.Response.End(); } if (gwRptCodeDao.AddAccountCode(rc)) { this.Response.Write(""); this.Response.End(); } else { this.Response.Write(""); this.Response.End(); } } } protected void SaveEditForm() { RptCode code = new RptCode(); code.OldCode = this.Request["OldCode"]; code.NewCode = this.Request["NewCode"]; code.Remark = this.Request["Remark"]; using (GwRptCodeDao gwRptCodeDao = new GwRptCodeDao()) { if (gwRptCodeDao.UpdateCode(code)) { this.Response.Write(";"); this.Response.End(); } else { this.Response.Write(""); this.Response.End(); } } } }