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 workbuttonmanageEdit : BasePage
{
int id = 0;
BLL.T_Wo_WorkOrderButton WorkOrdeButton = new BLL.T_Wo_WorkOrderButton();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Action == "addedit")
{
if (Request.QueryString["id"] != null)
{
Model.T_Wo_WorkOrderButton model = new Model.T_Wo_WorkOrderButton();
id = Convert.ToInt32(Request.QueryString["id"].ToString());
model = WorkOrdeButton.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_WorkOrderButton model = new Model.T_Wo_WorkOrderButton();
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 = WorkOrdeButton.Add(model);
return result;
}
///
/// 修改用户信息
///
///
public bool Edit()
{
Model.T_Wo_WorkOrderButton model = new Model.T_Wo_WorkOrderButton();
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_ButtonId =Convert.ToInt32(Request.QueryString["id"].ToString());
bool result = WorkOrdeButton.Update(model);
return result;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
bool result;
string a = Request.QueryString["id"];
if (string.IsNullOrEmpty(a) || a=="0")
{
InsertOptLogs(0, 0, "操作成功!workbuttonmanageEdit.aspx页面,添加操作。", 0);
result = Add();
}
else
{
InsertOptLogs(0, 0, "操作成功!workbuttonmanageEdit.aspx页面,修改操作。", 0);
result = Edit();
}
MessageBoxToWindow("提交成功", "提示", "success");
}
catch (Exception ex)
{
InsertOptLogs(0, 0, "操作异常!workbuttonmanageEdit.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);
}
}
}