|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Security;
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
using System.Web.UI.HtmlControls;
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
using System.Web.UI.WebControls.WebParts;
|
|
|
|
|
using DSWeb.Models;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.WorkFlow
|
|
|
|
|
{
|
|
|
|
|
public partial class Edit : System.Web.UI.Page
|
|
|
|
|
{
|
|
|
|
|
private string strUserID;
|
|
|
|
|
private string strShowName;
|
|
|
|
|
private string strHandle;//值"add"表示添加新的工作流信息 值"edit"表示更新工作流信息
|
|
|
|
|
private string strWorkFlowID;//工作流GID 更新时使用
|
|
|
|
|
private string strCompanyID;//公司GID
|
|
|
|
|
private string strDeptName;//部门名称
|
|
|
|
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Session["USERID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strUserID = Session["USERID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Session["SHOWNAME"] != null)
|
|
|
|
|
{
|
|
|
|
|
strShowName = Session["SHOWNAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["COMPANYID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strCompanyID = Session["COMPANYID"].ToString();
|
|
|
|
|
}
|
|
|
|
|
if (Session["DEPTNAME"] != null)
|
|
|
|
|
{
|
|
|
|
|
strDeptName = Session["DEPTNAME"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["handle"] != null)
|
|
|
|
|
{
|
|
|
|
|
strHandle = Request.QueryString["handle"].ToString().Trim().ToLower();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["flowid"] != null)
|
|
|
|
|
{
|
|
|
|
|
strWorkFlowID = Request.QueryString["flowid"].ToString();
|
|
|
|
|
h_workflowid.Value = strWorkFlowID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strHandle != null)
|
|
|
|
|
{
|
|
|
|
|
InitWorkFlowInfo();//获取工作流信息
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
private void InitWorkFlowInfo()
|
|
|
|
|
{
|
|
|
|
|
CompanyDA companyDA = new CompanyDA();
|
|
|
|
|
IList<WorkFlowTypeEntity> workFlowTypeEntities = new List<WorkFlowTypeEntity>();
|
|
|
|
|
workFlowTypeEntities = new WorkFlowTypeDA().GetAllWorkFlowType();
|
|
|
|
|
|
|
|
|
|
if (workFlowTypeEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
this.sel_workflowtype.Items.Clear();
|
|
|
|
|
foreach (WorkFlowTypeEntity workFlowTypeEntity in workFlowTypeEntities)
|
|
|
|
|
{
|
|
|
|
|
this.sel_workflowtype.Items.Add(new ListItem(workFlowTypeEntity.Description, workFlowTypeEntity.TypeNo.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strHandle == "add")
|
|
|
|
|
{
|
|
|
|
|
this.txt_wfcreateuser.Value = strShowName;
|
|
|
|
|
CompanyEntity companyEntity = companyDA.GetCompanyByID(strCompanyID);
|
|
|
|
|
|
|
|
|
|
if (companyEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (companyEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
this.txt_company.Value = companyEntity.NAME;
|
|
|
|
|
this.h_compid.Value = companyEntity.GID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strHandle == "edit" && strWorkFlowID != null)
|
|
|
|
|
{
|
|
|
|
|
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
|
|
|
|
|
WorkFlowDA workFlowDA = new WorkFlowDA();
|
|
|
|
|
workFlowEntity = workFlowDA.GetSingleWorkFlow(strWorkFlowID);
|
|
|
|
|
|
|
|
|
|
if (workFlowEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
UserDA userDA = new UserDA();
|
|
|
|
|
UserEntity userEntity = new UserEntity();
|
|
|
|
|
userEntity = userDA.GetUserSignByID(workFlowEntity.CreateUser);
|
|
|
|
|
|
|
|
|
|
this.txt_wfname.Value = workFlowEntity.Name;
|
|
|
|
|
|
|
|
|
|
this.txt_wfdescription.Value = workFlowEntity.Description;
|
|
|
|
|
this.txt_wfcreatetime.Value = workFlowEntity.CreateTime.ToString();
|
|
|
|
|
this.txt_wfcreateuser.Value = userEntity.ShowName;
|
|
|
|
|
this.sel_workflowtype.Value = workFlowEntity.Type.ToString();
|
|
|
|
|
|
|
|
|
|
CompanyEntity companyEntity = companyDA.GetCompanyByID(workFlowEntity.CompanyID);
|
|
|
|
|
|
|
|
|
|
if (companyEntity != null)
|
|
|
|
|
{
|
|
|
|
|
if (companyEntity.GID != null)
|
|
|
|
|
{
|
|
|
|
|
this.txt_company.Value = companyEntity.NAME;
|
|
|
|
|
this.h_compid.Value = companyEntity.GID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void btn_enter_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
|
|
string workFlowCompanyID = this.h_compid.Value.Trim();
|
|
|
|
|
string strFlowName = Request.Form["txt_wfname"].ToString().Trim();
|
|
|
|
|
string strDescription = Request.Form["txt_wfdescription"].ToString().Trim();
|
|
|
|
|
int iWorkFlowType = int.Parse(Request.Form["sel_workflowtype"].ToString());
|
|
|
|
|
string tempWorkFlowID = "";
|
|
|
|
|
tempWorkFlowID = this.h_workflowid.Value.Trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorkFlowDA workFlowDA = new WorkFlowDA();
|
|
|
|
|
|
|
|
|
|
if (workFlowDA.IsExistSameValueWorkFlow(WorkFlowCheckValueType.NAME, strFlowName, tempWorkFlowID))
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('系统名称已存在,请重新填写');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (workFlowDA.IsExistSameValueWorkFlow(WorkFlowCheckValueType.DESCRIPTION, strDescription, tempWorkFlowID))
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('显示名称已存在,请重新填写');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strHandle == "add")
|
|
|
|
|
{
|
|
|
|
|
if (workFlowDA.ExistSameWorkFlowInCompanyAndType(workFlowCompanyID, iWorkFlowType, 1, "") > 0)
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('已经存在相同类型的工作流,不能重复添加');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
|
|
|
|
|
|
|
|
|
|
workFlowEntity.GID = Guid.NewGuid().ToString();
|
|
|
|
|
workFlowEntity.Name = strFlowName;
|
|
|
|
|
workFlowEntity.Description = strDescription;
|
|
|
|
|
workFlowEntity.CompanyID = workFlowCompanyID;
|
|
|
|
|
workFlowEntity.Sort = 0;
|
|
|
|
|
workFlowEntity.State = 0;
|
|
|
|
|
workFlowEntity.CreateUser = strUserID;
|
|
|
|
|
workFlowEntity.Type = iWorkFlowType;
|
|
|
|
|
workFlowEntity.ModuleID = "";
|
|
|
|
|
|
|
|
|
|
result = workFlowDA.InsertWorkFlow(workFlowEntity);
|
|
|
|
|
|
|
|
|
|
if (result == 1)
|
|
|
|
|
{
|
|
|
|
|
this.txt_wfcreateuser.Value = strShowName;
|
|
|
|
|
this.btn_enter.Enabled = false;
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>alert('保存成功');window.opener.location.href=window.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('保存失败');</script>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strHandle == "edit" && strWorkFlowID != null)
|
|
|
|
|
{
|
|
|
|
|
//WorkFlowEntity workFlowEntity = new WorkFlowEntity();
|
|
|
|
|
//workFlowEntity = workFlowDA.GetSingleWorkFlow(strWorkFlowID);
|
|
|
|
|
|
|
|
|
|
//this.txt_wfname.Value = workFlowEntity.Name;
|
|
|
|
|
//this.txt_wfdescription.Value = workFlowEntity.Description;
|
|
|
|
|
////this.txt_wfmodule.Value = workFlowEntity.ModuleID;
|
|
|
|
|
//this.txt_wfcreateuser.Value = workFlowEntity.CreateUser;
|
|
|
|
|
//this.txt_wfcreatetime.Value = workFlowEntity.CreateTime.ToString();
|
|
|
|
|
|
|
|
|
|
if (workFlowDA.ExistSameWorkFlowInCompanyAndType(workFlowCompanyID, iWorkFlowType, 2, tempWorkFlowID) > 0)
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('已经存在相同类型的工作流,不能重复添加');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
|
|
|
|
|
workFlowEntity = workFlowDA.GetSingleWorkFlow(strWorkFlowID);
|
|
|
|
|
|
|
|
|
|
workFlowEntity.Name = strFlowName;
|
|
|
|
|
workFlowEntity.Description = strDescription;
|
|
|
|
|
workFlowEntity.CompanyID = workFlowCompanyID;
|
|
|
|
|
workFlowEntity.Sort = 0;
|
|
|
|
|
workFlowEntity.State = 0;
|
|
|
|
|
workFlowEntity.ModifiedUser = strUserID;
|
|
|
|
|
workFlowEntity.Type = iWorkFlowType;
|
|
|
|
|
workFlowEntity.ModuleID = "";
|
|
|
|
|
|
|
|
|
|
result = workFlowDA.DeleteWorkFlowByID(workFlowEntity.GID,1);
|
|
|
|
|
|
|
|
|
|
if (result == 1)
|
|
|
|
|
{
|
|
|
|
|
InitWorkFlowInfo();
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>alert('保存成功');window.opener.location.href=window.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('保存失败');</script>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查看是否有重复的值
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempFiledName">查询字段名称</param>
|
|
|
|
|
/// <param name="tempValue">查询字段值</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private bool IsExistSame(string tempFiledName,string tempValue)
|
|
|
|
|
{
|
|
|
|
|
bool exist = false;
|
|
|
|
|
//WorkFlowDA workFlowDA = new WorkFlowDA();
|
|
|
|
|
|
|
|
|
|
//string strSql = string.Format("SELECT COUNT(*) FROM workflow WHERE {0} = {1} AND ISDELETE <> 1 ", tempFiledName, tempValue);
|
|
|
|
|
|
|
|
|
|
//int result = workFlowDA.CheckExistSame(strSql);
|
|
|
|
|
|
|
|
|
|
//if (result > 0)
|
|
|
|
|
//{
|
|
|
|
|
// exist = true;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return exist;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|