using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using CY.Model; using CY.BLL; using CY.Infrastructure.Common; using CY.BLL.Sys; using CY.BLL.EC; using CY.Infrastructure.DESEncrypt; using CY.Infrastructure.Query; using CY.BLL.OA; using System.Transactions; namespace CY.WebForm.Pages.work { //吴辉 //新增请示 public partial class MyBaoxiaoAdd : BasePage { OA_DepartmentBll departmentBll = null; OA_StaffBLL oA_StaffBLL = null; Sys_DictionaryBLL bll_Sys_DictionaryBLL = null; OA_WorkPlanBll oA_WorkReminderBll = null; OA_CarDictionaryBLL bll_OA_CarDictionaryBLL = null; OA_SuppliersBLL _OA_SuppliersBLL = null; OA_SubjectSetBLL _OA_SubjectSetBLL = null; OA_WorkPlan_attachmentBLL oA_WorkPlan_AttachmentBLL = null; OA_WorkPlan_shenpiBLL oA_WorkPlan_ShenpiBLL = null; public string reado = ""; public MyBaoxiaoAdd() { departmentBll = new OA_DepartmentBll(); bll_Sys_DictionaryBLL = new Sys_DictionaryBLL(); oA_WorkReminderBll = new OA_WorkPlanBll(); oA_StaffBLL = new OA_StaffBLL(); bll_OA_CarDictionaryBLL = new OA_CarDictionaryBLL(); _OA_SuppliersBLL = new OA_SuppliersBLL(); _OA_SubjectSetBLL = new OA_SubjectSetBLL(); oA_WorkPlan_AttachmentBLL = new OA_WorkPlan_attachmentBLL(); oA_WorkPlan_ShenpiBLL = new OA_WorkPlan_shenpiBLL(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.txtStaff.Value = CurrentUser.TrueName; var staff = oA_StaffBLL.GetModelByKeyid(CurrentUser.StaffId); if (staff != null) { this.txtDepart.Value = staff.DepartmentName; } //科目名称 this.selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "贷"); this.selSubject.DataBind(); this.selSubject.Items.Insert(0, new ListItem("请选择", "")); InitData(); } } //数据加载 public void InitData() { if (Request["keyid"].ToInt32() > 0) { var oA_WorkPlan_Shenpis = oA_WorkPlan_ShenpiBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value).ToList(); if (oA_WorkPlan_Shenpis.Count > 0) { txtPlanMoney.Disabled = true; selSubject.Disabled = true; txtPlanContent.Disabled = true; selHoubufapiaoStatus.Disabled = true; } OA_WorkPlan m_OA_WorkPlan = oA_WorkReminderBll.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_WorkPlan != null) { this.txtPlanMoney.Value = m_OA_WorkPlan.PlanMoney.Value.ToString("0.00"); this.selHoubufapiaoStatus.Value = m_OA_WorkPlan.HoubufapiaoStatus.ToString(); this.selSubject.Value = m_OA_WorkPlan.RewardResult; this.txtPlanContent.Value = m_OA_WorkPlan.PlanContent.ToString(); } var sss = oA_WorkPlan_AttachmentBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value); this.RepClientList.DataSource = sss.Where(x => x.AttachmentType == 1); this.RepClientList.DataBind(); this.Repeater1.DataSource = sss.Where(x => x.AttachmentType == 2); this.Repeater1.DataBind(); } } //表单提交 protected void btn_submit_form(object sender, EventArgs e) { var HideKeyidFapiao = Request["HideKeyidFapiao"].Split(','); if(HideKeyidFapiao.Length<=1 && this.selHoubufapiaoStatus.Value == "1") { JavaScript.MessageBox("选择有发票必须上传发票", this); return; } using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted, Timeout = TransactionManager.MaximumTimeout } ) ) { try { DateTime nowTime = DateTime.Now; OA_WorkPlan m_OA_WorkPlan = oA_WorkReminderBll.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_WorkPlan == null) { m_OA_WorkPlan = new OA_WorkPlan(); m_OA_WorkPlan.ApprovalContent = ""; m_OA_WorkPlan.ApprovalStaffId = Guid.Empty; m_OA_WorkPlan.ApprovalStaffName = ""; m_OA_WorkPlan.ApprovalStatus = 0; m_OA_WorkPlan.ApprovalTime = nowTime; m_OA_WorkPlan.EvaluationContent = ""; m_OA_WorkPlan.EvaluationStaff = ""; m_OA_WorkPlan.EvaluationStaffId = Guid.Empty; m_OA_WorkPlan.EvaluationStatus = 2; m_OA_WorkPlan.EvaluationTime = nowTime; m_OA_WorkPlan.RewardMoney = 0; m_OA_WorkPlan.RewardType = 1; m_OA_WorkPlan.PlanStartTime = nowTime; m_OA_WorkPlan.PlanStatus = 1; m_OA_WorkPlan.SentStaffId = CurrentUser.TrueMemberId; m_OA_WorkPlan.MemberId = CurrentUser.MemberId; OA_Staff m_OA_Staff = oA_StaffBLL.GetModelByMemberId(CurrentUser.TrueMemberId); if (m_OA_Staff != null) m_OA_WorkPlan.DepartId = m_OA_Staff.DepartmentId; else m_OA_WorkPlan.DepartId = 0; m_OA_WorkPlan.PlanPeople = CurrentUser.TrueName; m_OA_WorkPlan.ReciveStaffId = CurrentUser.TrueMemberId; } else { } m_OA_WorkPlan.RewardResult = this.selSubject.Value; var a_SubjectSet = _OA_SubjectSetBLL.getSingleSubject(this.selSubject.Value.ToInt32()); if (a_SubjectSet != null) { m_OA_WorkPlan.RewardContent = a_SubjectSet.SubjectName; } m_OA_WorkPlan.PlanComplany = ""; m_OA_WorkPlan.Operator = CurrentUser.ShortName; m_OA_WorkPlan.HoubufapiaoStatus = this.selHoubufapiaoStatus.Value.ToInt32(); m_OA_WorkPlan.PlanContent = this.txtPlanContent.Value.Trim(); m_OA_WorkPlan.PlanDataType = 17; m_OA_WorkPlan.PlanMoney = this.txtPlanMoney.Value.Trim().ToDecimal2() ?? 0; m_OA_WorkPlan.PlanRemark = ""; m_OA_WorkPlan.PlanRunTime = DateTime.Now; m_OA_WorkPlan.PlanTitle = ""; m_OA_WorkPlan.PlanType = 3; m_OA_WorkPlan.LastUpdateTime = nowTime; if (Request["keyid"].ToInt32() > 0) { bool res = true; var oA_WorkPlan_Shenpis = oA_WorkPlan_ShenpiBLL.GetModelByKaipiaoId(Request["keyid"].ToInt32().Value).ToList(); if (oA_WorkPlan_Shenpis.Count == 0) { res = oA_WorkReminderBll.UpdateModel(m_OA_WorkPlan); } if (res) { //var HideKeyidFapiao = Request["HideKeyidFapiao"].Split(','); var HideAttachmentFapiao = Request["HideAttachmentFapiao"].Split(','); var HideKeyidFujian = Request["HideKeyidFujian"].Split(','); var HideAttachmentFujian = Request["HideAttachmentFujian"].Split(','); //需要删除的附件 var oA_WorkPlan_Attachments = oA_WorkPlan_AttachmentBLL.GetModelByKaipiaoId(m_OA_WorkPlan.Keyid.Value); List HideKeyidFujianid = new List(); for (int i = 0; i < HideKeyidFapiao.Length; i++) { if (!string.IsNullOrEmpty(HideKeyidFapiao[i]) && HideKeyidFapiao[i].ToInt32() != 0) { HideKeyidFujianid.Add(HideKeyidFapiao[i].ToInt32().Value); } } for (int i = 0; i < HideKeyidFujian.Length; i++) { if (!string.IsNullOrEmpty(HideKeyidFujian[i]) && HideKeyidFujian[i].ToInt32() != 0) { HideKeyidFujianid.Add(HideKeyidFujian[i].ToInt32().Value); } } var oA_WorkPlan_Attachments1 = oA_WorkPlan_Attachments.Where(x => !HideKeyidFujianid.Contains(x.Keyid)).ToList(); foreach(var oa_WorkPlan_Attachment in oA_WorkPlan_Attachments1) { res = oA_WorkPlan_AttachmentBLL.DeleteModel(oa_WorkPlan_Attachment); } for (int i = 0; i < HideKeyidFapiao.Length; i++) { if (string.IsNullOrEmpty(HideKeyidFapiao[i])) { var a_WorkPlan_Attachment = new OA_WorkPlan_attachment(); a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid; a_WorkPlan_Attachment.AttachmentType = 1; a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFapiao[i]; a_WorkPlan_Attachment.CreateTime = DateTime.Now; a_WorkPlan_Attachment.Operator = CurrentUser.TrueName; var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment); } else { continue; } } for (int i = 0; i < HideKeyidFujian.Length; i++) { if (string.IsNullOrEmpty(HideKeyidFujian[i])) { var a_WorkPlan_Attachment = new OA_WorkPlan_attachment(); a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid; a_WorkPlan_Attachment.AttachmentType = 2; a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFujian[i]; a_WorkPlan_Attachment.CreateTime = DateTime.Now; a_WorkPlan_Attachment.Operator = CurrentUser.TrueName; var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment); } else { continue; } } scope.Complete(); JavaScript.MessageBox("更新成功", this, true, true); } else JavaScript.MessageBox("操作失败", this); } else { var aaaa = oA_WorkReminderBll.InserModelAndGetId(m_OA_WorkPlan); m_OA_WorkPlan.Keyid = aaaa; if (aaaa > 0) { //var HideKeyidFapiao = Request["HideKeyidFapiao"].Split(','); var HideAttachmentFapiao = Request["HideAttachmentFapiao"].Split(','); var HideKeyidFujian = Request["HideKeyidFujian"].Split(','); var HideAttachmentFujian = Request["HideAttachmentFujian"].Split(','); for (int i = 0; i < HideKeyidFapiao.Length; i++) { if (string.IsNullOrEmpty(HideKeyidFapiao[i])) { var a_WorkPlan_Attachment = new OA_WorkPlan_attachment(); a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid; a_WorkPlan_Attachment.AttachmentType = 1; a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFapiao[i]; a_WorkPlan_Attachment.CreateTime = DateTime.Now; a_WorkPlan_Attachment.Operator = CurrentUser.TrueName; var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment); } else { continue; } } for (int i = 0; i < HideKeyidFujian.Length; i++) { if (string.IsNullOrEmpty(HideKeyidFujian[i])) { var a_WorkPlan_Attachment = new OA_WorkPlan_attachment(); a_WorkPlan_Attachment.OA_WorkPlanId = m_OA_WorkPlan.Keyid; a_WorkPlan_Attachment.AttachmentType = 2; a_WorkPlan_Attachment.PlanAttachment = HideAttachmentFujian[i]; a_WorkPlan_Attachment.CreateTime = DateTime.Now; a_WorkPlan_Attachment.Operator = CurrentUser.TrueName; var sss = oA_WorkPlan_AttachmentBLL.InsertModel(a_WorkPlan_Attachment); } else { continue; } } scope.Complete(); JavaScript.MessageBox("新增成功", this, true, true); } else JavaScript.MessageBox("操作失败", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } finally { // 释放资源 scope.Dispose(); } } } } }