合同审批流程:

ERP合同审核流程处理(二十九)-LMLPHP

前端的代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CRMContractEidt.aspx.cs" Inherits="BioErpWeb.CRMSystem.CRMContract.CRMContractEidt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
<script src="../../JS/CheckUserName.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/validateExtender.js" type="text/javascript"></script>
<script src="../../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.metadata.js" type="text/javascript"></script>
<script src="../../JS/CustomerName.js" type="text/javascript"></script>
<link href="../../Styles/InputStyle1.css" rel="stylesheet" type="text/css" />
<script src="../../JS/CheckDepartMent.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.7.custom.min.js" type="text/javascript"></script>
<link href="../../Scripts/jquery-ui-1.7.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function () {
$("#form1").validate();
$("#txtCreatTime").datepicker({ dateFormat: 'yy-mm-dd' });
$("#txtSinTime").datepicker({ dateFormat: 'yy-mm-dd' });
$("#txtEffectiveTime").datepicker({ dateFormat: 'yy-mm-dd' });
$("#txtEndTime").datepicker({ dateFormat: 'yy-mm-dd' }) }); </script>
<style type="text/css">
.style1
{
width: 73px;
}
</style>
</head>
<body>
<form id="form1" runat="server"> <div>
<table class="maintable Inupttable" style=" width:900px;">
<tr>
<td colspan="8" class="titlebar">合同审核</td>
</tr>
<tr>
<td class="style1">合同名称</td><td class="style3"><asp:TextBox ID="txtName" CssClass="required" runat="server"></asp:TextBox></td>
<td class="style4">下次审批人</td><td><asp:TextBox ID="txtUser1" CssClass="{required:true,digits:true, min:1}" runat="server"></asp:TextBox>
<input id="btnuser1" type="button" value="选择" onclick="showDialog3()" class="btnchoose"/>
</td>
<td class="style7">合同负责人</td><td class="style6"><asp:TextBox ID="txtUser2" CssClass="{required:true,digits:true, min:1}" runat="server"></asp:TextBox>
<input id="btnUser2" type="button" value="选择" onclick="showDialog3()" class="btnchoose"/>
</td>
<td>所属部门</td><td>
<asp:TextBox ID="txtDepartMentID" CssClass="{required:true,digits:true, min:1}" runat="server"></asp:TextBox>
<input id="btnDepart" type="button" value="选择" class="btnchoose" onclick="showDepartMentDialog2()" /></td>
</tr>
<tr>
<td class="style1">签约客户</td><td class="style3"><asp:TextBox ID="txtCustomer" CssClass="{required:true,digits:true, min:1}" runat="server"></asp:TextBox>
<input id="btncustomer" type="button" value="选择" onclick="showCustomerDialog3()" class="btnchoose"/>
</td>
<td class="style4">签约金额</td><td><asp:TextBox ID="txtSum" CssClass="{required:true,number:true}" runat="server"></asp:TextBox>元(RMB)</td>
<td class="style7">合同创建时间</td><td class="style6"><asp:TextBox ID="txtCreatTime" CssClass="{required:true,dateISO:true}" runat="server"></asp:TextBox></td>
<td>计划签约时间</td><td><asp:TextBox ID="txtSinTime" CssClass="{required:true,dateISO:true}" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="style1">生效时间</td><td class="style3" ><asp:TextBox ID="txtEffectiveTime" CssClass="{required:true,dateISO:true}" runat="server"></asp:TextBox></td>
<td class="style4">截止</td><td colspan="5"><asp:TextBox ID="txtEndTime" CssClass="{required:true,dateISO:true}" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="style1">合同内容</td><td colspan="7">
<asp:TextBox ID="txtDesc" CssClass="required"
runat="server" Height="300px" Width="100%" Rows="10" TextMode="MultiLine"></asp:TextBox></td> </tr>
<tr>
<td class="style1">合同附件</td><td colspan="5">
<asp:FileUpload ID="FileUpload1" runat="server" Width="200px" />
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/Web/images/files.gif" Width="26px" Height="24px"
onclick="ImageButton1_Click"/>
(下载)</td>
<td>合同类型</td><td>
<asp:DropDownList ID="ddlType" runat="server">
<asp:ListItem>买卖合同</asp:ListItem>
<asp:ListItem>运输合同</asp:ListItem>
<asp:ListItem>技术合同</asp:ListItem>
<asp:ListItem>保管合同</asp:ListItem>
<asp:ListItem>仓储合同</asp:ListItem>
<asp:ListItem>委托合同</asp:ListItem>
</asp:DropDownList>
</td> </tr> <tr>
<td class="style1">历史意见</td><td colspan="7">
<asp:Label ID="lbHistory" Width="99%" runat="server"
Text=""></asp:Label> </td>
</tr>
<tr>
<td class="style1">审批意见</td><td colspan="5">
<asp:TextBox ID="txtMind" Width="80%" runat="server"></asp:TextBox> </td>
<td>
<asp:Label ID="lbIsCheck" runat="server" Visible="false" Text="法律顾问意见"></asp:Label> </td><td>
<asp:CheckBox ID="cbIsCheck" Text="符合法律效应" Visible="false" BorderStyle="None" runat="server" /></td> </tr>
<tr>
<td colspan="8" class="bottomtd">
<asp:Button ID="btnSubmit" runat="server" Text="合同申请提交"
onclick="btnSubmit_Click" /> </td>
</tr> </table> </div>
</form>
</body>
</html>

根据员工编号返回员工权限字符串的自定义函数:

-- Description:	根据员工编号返回员工权限字符串
-- =============================================
CREATE FUNCTION [dbo].[GetUserRightsByUserID]
(
@userid INT
)
RETURNS NVARCHAR(200)
AS
BEGIN DECLARE cur CURSOR FOR
SELECT RightID FROM dbo.tbUserRight WHERE tbUserRight.UserId =@userid
OPEN cur
DECLARE @Rightid NVARCHAR(20)
DECLARE @Rightids NVARCHAR(1000)
SET @Rightids=''
FETCH NEXT FROM cur INTO @Rightid
WHILE @@FETCH_STATUS =0
BEGIN
SET @Rightids=@Rightids+@Rightid+','
FETCH NEXT FROM cur INTO @Rightid
END
CLOSE cur
DEALLOCATE cur RETURN @Rightids END

存储过程的封装:

CREATE PROCEDURE Sp_getUserRightsbyUserid
@userid int
AS
BEGIN
SET NOCOUNT ON;
SELECT dbo.GetUserRightsByUserID(@userid)
END

公用类的调用:

        /// <summary>
/// 根据用户编号返回用户的权限值字符串
/// </summary>
/// <param name="userid">用户编号</param>
/// <returns>权限值字符串</returns>
public static string getUserRightsByUserId(string userid)
{
//dbo.GetUserRightsByUserID
SqlParameter[] pars = new SqlParameter[]{
new SqlParameter("@userid",userid)
}; object obj= DataBaseHelper.SelectSQLReturnObject("Sp_getUserRightsbyUserid", CommandType.StoredProcedure, pars);
if (obj != null)
{
return obj.ToString();
}
else
{
return "";
}
}

后端代码:

  static  byte[] filecontent = null;

       static string contractid = "";
static string tasklistid = "";
static string documentsid = "";
/// <summary>
/// 绑定页面信息
/// </summary>
protected void pageinfo()
{
contractid = "5";
tasklistid = "2";
#region 从合同信息表中绑定数据
CrmContractBLL cbll = new CrmContractBLL();
ViewContactInfo contactinfo = new ViewContactInfo();
contactinfo = cbll.getViewContactInfoByContactID(contractid);
this.txtName.Text = contactinfo.ContractName;
this.txtUser2.Text = contactinfo.UserID.ToString();
this.txtSinTime.Text = Convert.ToDateTime(contactinfo.SignTime.ToString()).ToString("yyyy-MM-dd");
this.txtCreatTime.Text = Convert.ToDateTime(contactinfo.CreateTime.ToString()).ToString("yyyy-MM-dd");
this.txtCustomer.Text = contactinfo.CustomerID.ToString();
this.txtSum.Text = Convert.ToDecimal(contactinfo.ContractSum.ToString()).ToString("0.00");
this.txtEffectiveTime.Text = Convert.ToDateTime(contactinfo.EffectiveTime).ToString("yyyy-MM-dd");
this.txtDesc.Text = contactinfo.ContractDesc;
this.txtEndTime.Text = Convert.ToDateTime(contactinfo.EndTime).ToString("yyyy-MM-dd");
this.ddlType.SelectedItem.Text = contactinfo.ContractType.ToString(); this.cbIsCheck.Checked =bool.Parse(contactinfo.AssessorAuditing.ToString()); #endregion #region 从流程表中绑定数据
//1代表 合同管理表单
System.Data.DataTable dt = SqlComm.getTaskListRecordsByCondition(contractid, "1");
System.Data.DataRow[] dr0 = dt.Select(" listID=" + tasklistid);
//如果当前表单流程的审批人和当前登录用户不一致,则跳出
if (dr0[0].ItemArray[5].ToString() != Session["Userid"].ToString())
{
this.FileUpload1.Visible = false;
}
else
{
this.FileUpload1.Visible = true;
}
string historys = "";
for (int i = 1; i < dt.Rows.Count; i++)
{
historys+= dt.Rows[i]["Mind"].ToString() + " " + Convert.ToDateTime(dt.Rows[i]["SumitTime"].ToString()).ToString("yyyy-MM-dd")+"</br>"; }
if (historys.Length == 0)
{
historys = "暂无审核意见";
}
this.lbHistory.Text = historys; this.txtDepartMentID.Text = dr0[0].ItemArray[12].ToString();
this.txtUser1.Text = dr0[0].ItemArray[5].ToString();
#endregion filecontent = Comm.GetDownDocumet("BioCrmCorrelationDocument", "Content", " DocumentID=" + contactinfo.DocumentID);
documentsid = contactinfo.DocumentID.ToString(); if (SqlComm.getUserRightsByUserId(Session["Userid"].ToString()).Contains("45") || this.cbIsCheck.Checked==true)
{
this.lbIsCheck.Visible = true;
this.cbIsCheck.Visible = true;
}
else
{
this.lbIsCheck.Visible = false;
this.cbIsCheck.Visible = false; }
} //如果不是合同负责人本人,则不能修改合同的相关信息,只能发表审批意见或则如果是法律顾问权限人员则可以修改法律审核备注
protected void btnSubmit_Click(object sender, EventArgs e)
{ CrmContractBLL conbll = new CrmContractBLL();
BioCRMContract contract = new BioCRMContract();
CRMContractDocument condocument =null;
TaskListRecord tasklistRecord =null;
BioCrmCorrelationDocument document=null; //获取合同相关信息
contract.ContractID = int.Parse(contractid);
contract.UserID = int.Parse(this.txtUser2.Text);
contract.ContractName = this.txtName.Text;
contract.CustomerID = int.Parse(this.txtCustomer.Text);
contract.ContractSum = decimal.Parse(this.txtSum.Text);
contract.ContractType = this.ddlType.SelectedValue;
contract.EndTime = Convert.ToDateTime(this.txtEndTime.Text);
contract.EffectiveTime = Convert.ToDateTime(this.txtEffectiveTime.Text);
contract.SignTime = Convert.ToDateTime(this.txtSinTime.Text);
contract.ContractDesc = this.txtDesc.Text;
contract.ExecutiveState = "待审核"; if (this.cbIsCheck.Visible == true)
{
contract.AssessorAuditing = cbIsCheck.Checked;
} contract.CreateTime = Convert.ToDateTime(this.txtCreatTime.Text); int count = conbll.BioCRMContractaUpdate(contract); //文档基本信息
if (this.FileUpload1.HasFile)
{
document = new BioCrmCorrelationDocument()
{
DocumentID = int.Parse(documentsid.ToString()),
Subject = this.txtName.Text,
Content = this.FileUpload1.FileBytes,
DocumentSize =this.FileUpload1.FileContent.Length,
Type = this.FileUpload1.PostedFile.ContentType,
ExetendName = System.IO.Path.GetExtension(this.FileUpload1.FileName),
DocumentLevel = "绝密",
Name = this.FileUpload1.FileName,
Remark = "合同附件文档",
UserID = int.Parse(this.txtUser2.Text),
UploadTime = DateTime.Now
};
BioCrmCorrelationDocumentBLL documentbll = new BioCrmCorrelationDocumentBLL(); documentbll.BioCrmCorrelationDocumentUpdate(document); } tasklistRecord = new TaskListRecord()
{
Accepter = int.Parse(this.txtUser1.Text),
Transmitter = int.Parse(this.txtUser2.Text),
AuditingSate = 0,
DepartMentId = int.Parse(this.txtDepartMentID.Text),
FirstAccepter = int.Parse(this.txtUser1.Text),
FirstSumitTime = DateTime.Now,
FirstTransmitter = int.Parse(Session["Userid"].ToString()),
Mind =this.txtMind.Text,
Pass = 1,
Subject = this.txtName.Text,
SumitTime = DateTime.Now,
TaskID =int.Parse(contractid),
TaskTableID = 1
}; //向流程表添加一条新的记录
if (SqlComm.TaskListRecordAdd(tasklistRecord) != 0)
{
SqlComm.UpdateTableByCondition("dbo.TaskListRecord", " AuditingSate=1", " ListID=" + tasklistid);
ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('合同申请提交成功,下次审批人员编号:" + this.txtUser1.Text + "')", true);
}
} /// <summary>
/// 下载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{ //创建弹出式Windows下载窗体
Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(this.txtName.Text));
//把二进制数组写入Http输出流
Response.BinaryWrite(filecontent);
//想当前客户端缓冲区输出
Response.Flush();
//停止执行
Response.End();
}

创建没有审核的视图:

CREATE VIEW View_NoAuditingState
AS
SELECT ListID,Subject,dbo.TaskListRecord.TaskID,dbo.TaskListRecord.TaskTableID
,Transmitter,Accepter,SumitTime,LinEdit=(
SELECT LinkEdit FROM dbo.TaskNavigate WHERE dbo.TaskNavigate.TaskTableID=
dbo.TaskListRecord.TaskTableID
) FROM dbo.TaskListRecord
  /// <summary>
/// 获取未审核表单信息
/// </summary>
public void getNoAuditing()
{
NoAuditingList.DataSource= SqlComm.GetDataByCondition("dbo.View_NoAuditingSate", "*", " AuditingSate=0 and Accepter='" + Session["Userid"] + "'");
this.NoAuditingList.DataBind();
} public string setToString(string str)
{ if (str == "0")
{
return "未受理";
}
else if (str == "1")
{ return "受理中";
}
else if (str == "2")
{ return "已解决";
}
else
{ return "过期";
} }
04-15 13:06