ERP完善合同起草(二十八)

网友投稿 328 2022-09-05

ERP完善合同起草(二十八)

前端的代码:

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

合同起草
合同名称 下次审批人 合同负责人 所属部门
签约客户 签约金额元(RMB) 合同创建时间 计划签约时间
生效时间 截止
合同内容
合同附件 合同类型 买卖合同 运输合同 技术合同 保管合同 仓储合同 委托合同

创建触发器:

CREATE TRIGGER [dbo].[CreateContractNoByContractID] ON [dbo].[BioCRMContract] AFTER INSERTAS BEGIN DECLARE @str nvarchar(10) DECLARE @ContractNo nvarchar(50) DECLARE @ContractID nvarchar(50) SET @str='0000000' SELECT @ContractID=MAX(ContractID) FROM dbo.BioCRMContract SET @ContractNo=RIGHT(@str+@ContractID,7) UPDATE dbo.BioCRMContract SET ContractNumber=@ContractNo WHERE ContractID=@ContractIDend

后端的代码:

提交不成功删除原有的数据

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.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 = "待审核"; contract.CreateTime = Convert.ToDateTime(this.txtCreatTime.Text); int ContractID = conbll.BioCRMContractadd(contract); if (ContractID != 0) { //文档基本信息 if (this.FileUpload1.HasFile) { document = new BioCrmCorrelationDocument() { 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(); int documentid = documentbll.BioCrmCorrelationDocumentAdd(document); if (documentid != 0) { condocument = new CRMContractDocument() { DocumentID = documentid, ContractID = ContractID }; int count = conbll.CRMContractDocumentADD(condocument); if (count != 0) { 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 = "", Pass = 1, Subject = this.txtName.Text, SumitTime = DateTime.Now, TaskID = ContractID, TaskTableID = 1 }; if (SqlComm.TaskListRecordAdd(tasklistRecord) != 0) { ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('合同申请提交成功,下次审批人员编号:" + this.txtUser1.Text + "')", true); } else { SqlComm.DeleteTableByCondition("BioErpCRMContractDocument", " where ContractID=" + ContractID); SqlComm.DeleteTableByCondition("BioCrmCorrelationDocument", " where DocumentID=" + documentid); SqlComm.DeleteTableByCondition("BioCRMContract", " where ContractID=" + ContractID); } } else { SqlComm.DeleteTableByCondition("BioErpCRMContractDocument", " where ContractID=" + ContractID); SqlComm.DeleteTableByCondition("BioCrmCorrelationDocument", " where DocumentID=" + documentid); } } else { SqlComm.DeleteTableByCondition("BioCRMContract", " where ContractID=" + ContractID); } } }

修改的业务(前端):

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