using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace HySoft.BaseCallCenter.Web.workordermanage.workorderset { public partial class WorkorderStateEdit : BasePage { int id = 0; BLL.T_Wo_WorkOrderState WorkOrderState = new BLL.T_Wo_WorkOrderState(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Action == "addedit") { if (Request.QueryString["id"] != null) { Model.T_Wo_WorkOrderState model = new Model.T_Wo_WorkOrderState(); id = Convert.ToInt32(Request.QueryString["id"].ToString()); model = WorkOrderState.GetModel(id); F_ParamDes.Text = model.F_Des;//描述 textF_Sort.Text = model.F_Sort.ToString();//排序 F_ParamCode.Text = model.F_Name;//状态名称 F_ParamValue.Text = model.F_Code; } } } } /// /// 处理类型新增还是修改 /// public string Action { get { if (Request.QueryString["action"] != null) { return Request.QueryString["action"].ToString().ToLower(); } else { return "add"; } } } /// /// 添加用户信息 /// /// public bool Add() { Model.T_Wo_WorkOrderState model = new Model.T_Wo_WorkOrderState(); model.F_Des = F_ParamDes.Text.Trim();//描述 model.F_Sort = Convert.ToInt32(textF_Sort.Text.Trim());//排序 model.F_Name = F_ParamCode.Text.Trim();//状态名称 model.F_Code = F_ParamValue.Text.Trim(); model.F_Deleteflag = 0;//是否删除 bool result = WorkOrderState.Add(model); return result; } /// /// 修改用户信息 /// /// public bool Edit() { Model.T_Wo_WorkOrderState model = new Model.T_Wo_WorkOrderState(); model.F_Des = F_ParamDes.Text.Trim();//描述 model.F_Sort = Convert.ToInt32(textF_Sort.Text.Trim());//排序 model.F_Name = F_ParamCode.Text.Trim();//状态名称 model.F_Code = F_ParamValue.Text.Trim(); model.F_Deleteflag = 0; model.F_WorkOrderStateId = Convert.ToInt32(Request.QueryString["id"].ToString()); bool result = WorkOrderState.Update(model); return result; } protected void btnSubmit_Click(object sender, EventArgs e) { try { bool result; if (Convert.ToInt32(Request.QueryString["id"].ToString()) == 0) { result = Add(); InsertOptLogs(0, 0, "操作成功!WorkorderStateEdit.aspx页面,增加操作。", 0); } else { result = Edit(); InsertOptLogs(0, 0, "操作成功!WorkorderStateEdit.aspx页面,修改操作。", 0); } MessageBoxToWindow("提交成功", "提示", "success"); } catch (Exception ex) { InsertOptLogs(0, 0, "操作异常!WorkorderStateEdit.aspx页面,异常信息:"+ex.ToString(), 2); MessageBoxToWindow("异常信息", ex.Message, "catch"); } } /// /// 弹出对话框 /// /// /// /// public void MessageBoxToWindow(string title, string content, string type) { string script = ""; switch (type) { case "error"://失败 type = "warning"; script = ""; break; case "success"://成功 type = "info"; script = ""; break; case "catch"://异常 type = "error"; script = ""; break; default: type = "question"; break; } ClientScript.RegisterClientScriptBlock(this.GetType(), "", script); } } }