| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- 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 alamangeStateEdit : BasePage
- {
- BLL.T_Wo_StateAlarmDate bll = new BLL.T_Wo_StateAlarmDate();
- //WorkOrderSystem.BLL.T_SYS_ORGANIZATIONINFO bll_c = new WorkOrderSystem.BLL.T_SYS_ORGANIZATIONINFO();
- /// <summary>
- /// 处理类型新增还是修改
- /// </summary>
- public string Action
- {
- get
- {
- if (Request.QueryString["action"] != null)
- {
- return Request.QueryString["action"].ToString().ToLower();
- }
- else
- {
- return "add";
- }
- }
- }
- public int TypeId
- {
- get {
- int id = 0;
- if (Request.QueryString["f_worktypeid"] != null)
- int.TryParse(Request.QueryString["f_worktypeid"].ToString(), out id);
- return id;
- }
- }
- /// <summary>
- /// 状态ID
- /// </summary>
- public int StateId
- {
- get
- {
- int id = 0;
- if (Request.QueryString["f_workstateId"] != null)
- int.TryParse(Request.QueryString["f_workstateId"].ToString(), out id);
- return id;
- }
- }
- /// <summary>
- /// 记录ID
- /// </summary>
- public int Id
- {
- get
- {
- int id = 0;
- if (Request.QueryString["f_id"] != null)
- int.TryParse(Request.QueryString["f_id"].ToString(), out id);
- return id;
- }
- }
- /// <summary>
- /// 类型名称
- /// </summary>
- public string TypeName
- {
- get
- {
- if (Request.QueryString["f_workstateId"] != null)
- {
- return DBUtility.DbHelperSQL.GetSingle("select F_name from T_Wo_WorkOrderState where F_WorkOrderStateId='" + Request.QueryString["f_workstateId"] + "'").ToString().ToLower();
- }
- else
- {
- return "";
- }
- }
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- labTypeTxt.Text = TypeName;
- // BindAreaList();
- if (Action == "edit")
- {
- Model.T_Wo_StateAlarmDate model = new Model.T_Wo_StateAlarmDate();
- model = bll.GetModel(Id);
- txtGaoJingNumber.Text = model.F_Gcount.ToString();
- ddlGaojingUnit.SelectedValue = model.F_Gunit.ToString();
- txtChaoshiNumber.Text = model.F_Ccount.ToString();
- ddlChaoShiUnit.SelectedValue = model.F_Cunit.ToString();
- }
- }
-
- }
- public string GetUnit(string val)
- {
- switch (val)
- {
- case "0":
- return "分";
- case "1":
- return "小时";
- case "2":
- return "天";
- default:
- return "";
- }
- }
-
- /// <summary>
- /// 获取功能对象实体模型
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public Model.T_Wo_StateAlarmDate GetModel()
- {
- Model.T_Wo_StateAlarmDate model = new Model.T_Wo_StateAlarmDate();
- if (Id > 0)
- {
- model = bll.GetModel(Id);
- }
- try
- {
- model.F_WorkOrderStateId = StateId; //状态
- model.F_Gcount = txtGaoJingNumber.Text.Trim() == "" ? 0 : int.Parse(txtGaoJingNumber.Text.Trim());
- model.F_Gunit = ddlGaojingUnit.SelectedValue == "" ? -1 : int.Parse(ddlGaojingUnit.SelectedValue);
- model.F_WorkOrderTypeId = TypeId;
- model.F_Ccount = txtChaoshiNumber.Text.Trim() == "" ? 0 : int.Parse(txtChaoshiNumber.Text.Trim());
- model.F_Cunit = ddlChaoShiUnit.SelectedValue == "" ? -1 : int.Parse(ddlChaoShiUnit.SelectedValue);
- model.F_ModifyDate = DateTime.Now;//最后修改时间
- model.F_DeleteFlag = 0;
- }
- catch (Exception)
- {
- }
- return model;
- }
- protected void btnSubmit_Click(object sender, EventArgs e)
- {
- Model.T_Wo_StateAlarmDate new_model = GetModel();
- //Common.LoginUser user = new WorkOrderSystem.Common.LoginUser(this.Context);
- new_model.F_ModifyBy = 1;//修改人
- try
- {
- bool result;
- switch (Action)
- {
- case "add":
- new_model.F_Createby = 1;
- new_model.F_CreateDate = DateTime.Now;
- result = bll.Add(new_model);
- if (result)
- {
- InsertOptLogs(0, 0, "操作成功!alamangeStateEdit.aspx页面,新建操作。", 0);
- MessageBoxToWindow("新增成功", "新增提示!", "success");
- }
- else
- {
- InsertOptLogs(0, 0, "操作失败!alamangeStateEdit.aspx页面,新建操作。", 1);
- MessageBoxToWindow("新增失败", "新增提示!", "error");
- }
- break;
- case "edit":
- result = bll.Update(new_model);
- if (result)
- {
- InsertOptLogs(0, 0, "操作成功!alamangeStateEdit.aspx页面,修改操作。", 0);
- MessageBoxToWindow("修改成功", "修改提示!", "success");
- }
- else
- {
- InsertOptLogs(0, 0, "操作失败!alamangeStateEdit.aspx页面,修改操作。", 1);
- MessageBoxToWindow("修改失败", "修改提示!", "error");
- }
- break;
- }
- }
- catch (Exception ex)
- {
- InsertOptLogs(0, 0, "操作异常!alamangeStateEdit.aspx页面,异常信息:" + ex.ToString(), 2);
- MessageBoxToWindow("异常信息", ex.Message, "catch");
- }
- }
- /// <summary>
- /// 弹出对话框
- /// </summary>
- /// <param name="title"></param>
- /// <param name="content"></param>
- /// <param name="type"></param>
- public void MessageBoxToWindow(string title, string content, string type)
- {
- string script = "";
- switch (type)
- {
- case "error"://失败
- type = "warning";
- script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
- break;
- case "success"://成功
- type = "info";
- script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',CloseThis);</script>";
- break;
- case "catch"://异常
- type = "error";
- script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
- break;
- default:
- type = "question";
- break;
- }
- ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
- }
- }
- }
|