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 oldCode = Convert.ToString(this.Request["OldCode"]); if (gwRptCodeDao.DeleteCode(oldCode)) { 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() { 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 (string.IsNullOrEmpty(code.OldCode) || code.OldCode.Length < 3 || (string.IsNullOrEmpty(code.NewCode) || code.NewCode.Length < 3)) { this.Response.Write(""); this.Response.End(); } if (gwRptCodeDao.AddCode(code)) { 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(); } } } }