/// <summary> /// 撤销订阅审批 /// </summary> /// <param name="user_id"></param> /// <param name="ids"></param> /// <returns></returns> public ERROR_CODE Revoke_Subscriptions(long user_id, string ids, out string re) { re = string.Empty; StringBuilder returnvalue = new StringBuilder(); var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } crm_account_deduction cad = new crm_account_deduction(); crm_subscription cs = new crm_subscription(); //订阅表 crm_subscription_period csp = new crm_subscription_period(); //订阅周期表 crm_subscription_dal cs_dal = new crm_subscription_dal(); crm_subscription_period_dal csp_dal = new crm_subscription_period_dal(); if (!string.IsNullOrEmpty(ids)) { var idList = ids.Split(','); foreach (var id in idList) { var oldcad = cad = GetAccountDed(long.Parse(id)); if (cad.invoice_id != null) { var ci = new ctt_invoice_dal().FindNoDeleteById((long)cad.invoice_id); if (ci.is_voided != 1) { returnvalue.Append(id + "条目已经生成发票(发票ID:" + cad.invoice_id + "),请先作废该发票\n"); } } else { cad.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); cad.delete_user_id = user.id; // 插入日志 var add1_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION, oper_object_id = cad.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = cad_dal.CompareValue(oldcad, cad), remark = "删除审批并提交" }; // 创建日志 new sys_oper_log_dal().Insert(add1_log); // 插入日志 if (!cad_dal.Update(cad)) { return(ERROR_CODE.ERROR); } else { } } //订阅 if (cad.object_id != null) { var oldcsp = csp = csp_dal.FindSignleBySql <crm_subscription_period>($"select * from crm_subscription_period where id={cad.object_id}"); cs = cs_dal.FindNoDeleteById(csp.subscription_id); csp.approve_and_post_user_id = null; csp.approve_and_post_date = null; csp.period_price = cs.period_price; var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SUBSCRIPTION_PERIOD, //订阅周期 oper_object_id = csp.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = cad_dal.CompareValue(oldcsp, csp), remark = "修改订阅周期" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 if (!csp_dal.Update(csp)) { return(ERROR_CODE.ERROR); } } } } if (!string.IsNullOrEmpty(returnvalue.ToString())) { re = returnvalue.ToString(); return(ERROR_CODE.EXIST); } return(ERROR_CODE.SUCCESS); }
/// <summary> /// 撤销里程碑审批 /// </summary> /// <param name="user_id"></param> /// <param name="ids"></param> /// <returns></returns> public ERROR_CODE Revoke_Milestones(long user_id, string ids, out string re) { re = string.Empty; StringBuilder returnvalue = new StringBuilder(); var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } crm_account_deduction cad = new crm_account_deduction(); ctt_contract_milestone ccm = new ctt_contract_milestone(); ctt_contract_milestone_dal ccm_dal = new ctt_contract_milestone_dal(); if (!string.IsNullOrEmpty(ids)) { var idList = ids.Split(','); foreach (var id in idList) { var oldcad = cad = GetAccountDed(long.Parse(id)); if (cad.invoice_id != null) { var ci = new ctt_invoice_dal().FindNoDeleteById((long)cad.invoice_id); if (ci.is_voided != 1) { returnvalue.Append(id + "条目已经生成发票(发票ID:" + cad.invoice_id + "),请先作废该发票\n"); } } else { cad.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); cad.delete_user_id = user.id; // 插入日志 var add1_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION, oper_object_id = cad.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = cad_dal.CompareValue(oldcad, cad), remark = "删除审批并提交" }; // 创建日志 new sys_oper_log_dal().Insert(add1_log); // 插入日志 if (!cad_dal.Update(cad)) { return(ERROR_CODE.ERROR); } else { } } //里程碑 if (cad.object_id != null) { var oldccm = ccm = ccm_dal.FindSignleBySql <ctt_contract_milestone>($"select * from ctt_contract_milestone where id={cad.object_id} and delete_time=0"); ccm.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); ccm.update_user_id = user.id; ccm.status_id = (int)MILESTONE_STATUS.READY_TO_BILL; var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_MILESTONE, oper_object_id = ccm.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = cad_dal.CompareValue(oldccm, ccm), remark = "修改合同里程碑" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 if (!ccm_dal.Update(ccm)) { return(ERROR_CODE.ERROR); } } } } if (!string.IsNullOrEmpty(returnvalue.ToString())) { re = returnvalue.ToString(); return(ERROR_CODE.EXIST); } return(ERROR_CODE.SUCCESS); }
/// <summary> /// /撤销成本审批 /// </summary> /// <param name="user_id"></param> /// <param name="ids"></param> /// <returns></returns> public ERROR_CODE Revoke_CHARGES(long user_id, string ids, out string re) { re = string.Empty; var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } var cadDal = new crm_account_deduction_dal(); var sweDal = new sdk_work_entry_dal(); crm_account_deduction cad = new crm_account_deduction(); ctt_contract_block ccb = new ctt_contract_block(); ctt_contract_cost ccc = new ctt_contract_cost(); ctt_contract_cost_dal ccc_dal = new ctt_contract_cost_dal(); ctt_contract_block_dal ccb_dal = new ctt_contract_block_dal(); StringBuilder returnvalue = new StringBuilder(); //该条目已经生成发票(发票ID:发票ID),请先作废该发票 if (!string.IsNullOrEmpty(ids)) { var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); var idList = ids.Split(','); foreach (var id in idList) { var oldcad = cad = GetAccountDed(long.Parse(id)); if (cad != null) { if (cad.object_id != null) { var cadList = cadDal.GetListByObjectId((long)cad.object_id); if (cadList != null && cadList.Count > 0) { foreach (var thisCad in cadList) { if (thisCad.invoice_id != null) { var ci = new ctt_invoice_dal().FindNoDeleteById((long)thisCad.invoice_id); if (ci != null && ci.is_voided != 1) { returnvalue.Append(id + "条目已经生成发票(发票ID:" + thisCad.invoice_id + "),请先作废该发票\n"); } } } } if (string.IsNullOrEmpty(returnvalue.ToString())) { if (cadList != null && cadList.Count > 0) { cadList.ForEach(_ => { RecoveryBlock(_.id, user_id); cadDal.SoftDelete(_, user_id); OperLogBLL.OperLogDelete <crm_account_deduction>(_, _.id, user_id, OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION, "删除审批并提交条目"); }); var oldccc = ccc = ccc_dal.FindNoDeleteById((long)cad.object_id); if (ccc != null) { // var oldSwe = sweDal.FindNoDeleteById((long)cad.object_id); ccc.update_time = timeNow; ccc.update_user_id = user.id; ccc.bill_status = 0; ccc.extended_price = ccc.unit_price * ccc.quantity; ccc_dal.Update(ccc); OperLogBLL.OperLogUpdate <ctt_contract_cost>(ccc, oldccc, ccc.id, user_id, OPER_LOG_OBJ_CATE.CONTRACT_COST, "修改合同成本"); } } } else { re = returnvalue.ToString(); } } } #region 原有的撤销成本审批相关逻辑 //if (cad.invoice_id != null) //{ // var ci = new ctt_invoice_dal().FindNoDeleteById((long)cad.invoice_id); // if (ci.is_voided != 1) // { // returnvalue.Append(id + "条目已经生成发票(发票ID:" + cad.invoice_id + "),请先作废该发票\n"); // } //} //else //{ // cad.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); // cad.delete_user_id = user.id; // var add1_log = new sys_oper_log() // { // user_cate = "用户", // user_id = (int)user.id, // name = user.name, // phone = user.mobile == null ? "" : user.mobile, // oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), // oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION, // oper_object_id = cad.id,// 操作对象id // oper_type_id = (int)OPER_LOG_TYPE.DELETE, // oper_description = cad_dal.CompareValue(oldcad, cad), // remark = "删除审批并提交" // }; // 创建日志 // new sys_oper_log_dal().Insert(add1_log); // 插入日志 // if (!cad_dal.Update(cad)) // { // return ERROR_CODE.ERROR; // } // //合同成本 // var oldccc = ccc = ccc_dal.FindSignleBySql<ctt_contract_cost>($"select * from ctt_contract_cost where id={cad.object_id} and delete_time=0"); // if (ccc != null) // { // ccc.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); // ccc.update_user_id = user.id; // ccc.bill_status = 0; // ccc.extended_price = ccc.unit_price * ccc.quantity; // var add_log = new sys_oper_log() // { // user_cate = "用户", // user_id = (int)user.id, // name = user.name, // phone = user.mobile == null ? "" : user.mobile, // oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), // oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_COST, // oper_object_id = ccc.id,// 操作对象id // oper_type_id = (int)OPER_LOG_TYPE.UPDATE, // oper_description = cad_dal.CompareValue(oldccc, ccc), // remark = "修改合同成本" // }; // 创建日志 // new sys_oper_log_dal().Insert(add_log); // 插入日志 // if (!ccc_dal.Update(ccc)) // { // return ERROR_CODE.ERROR; // } // if (cad.contract_block_id != null) // { // //合同预付 // var oldccb = ccb = ccb_dal.FindSignleBySql<ctt_contract_block>($" select * from ctt_contract_block where id={cad.contract_block_id} and delete_time=0"); // if (ccb != null) // { // ccb.is_billed = 0; // ccb.status_id = 1; // ccb.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); // ccb.update_user_id = user.id; // var add3_log = new sys_oper_log() // { // user_cate = "用户", // user_id = (int)user.id, // name = user.name, // phone = user.mobile == null ? "" : user.mobile, // oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), // oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_BLOCK, // oper_object_id = ccc.id,// 操作对象id // oper_type_id = (int)OPER_LOG_TYPE.UPDATE, // oper_description = cad_dal.CompareValue(oldccb, ccb), // remark = "修改合同预付" // }; // 创建日志 // new sys_oper_log_dal().Insert(add3_log); // 插入日志 // if (!ccb_dal.Update(ccb)) // { // return ERROR_CODE.ERROR; // } // } // } // } //} #endregion } } if (!string.IsNullOrEmpty(returnvalue.ToString())) { re = returnvalue.ToString(); return(ERROR_CODE.EXIST); } return(ERROR_CODE.SUCCESS); }
/// <summary> /// 撤销定期服务审批 /// </summary> /// <param name="user_id"></param> /// <param name="ids"></param> /// <returns></returns> public ERROR_CODE Revoke_Recurring_Services(long user_id, string ids, out string re) { re = string.Empty; var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } StringBuilder returnvalue = new StringBuilder(); crm_account_deduction cad = new crm_account_deduction(); //审批并提交 ctt_contract_cost ccc = new ctt_contract_cost(); //成本 ctt_contract cc = new ctt_contract(); //合同 ctt_contract_service_period ccsp = new ctt_contract_service_period(); //合同服务周期 ctt_contract_service_adjust ccsa = new ctt_contract_service_adjust(); //合同服务调整 ctt_contract_service_period_dal ccsp_dal = new ctt_contract_service_period_dal(); ctt_contract_service_adjust_dal ccsa_dal = new ctt_contract_service_adjust_dal(); if (!string.IsNullOrEmpty(ids)) { var idList = ids.Split(','); foreach (var id in idList) { var oldcad = cad = GetAccountDed(long.Parse(id)); if (cad.invoice_id != null) { var ci = new ctt_invoice_dal().FindNoDeleteById((long)cad.invoice_id); if (ci.is_voided != 1) { returnvalue.Append(id + "条目已经生成发票(发票ID:" + cad.invoice_id + "),请先作废该发票\n"); } } else { cad.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); cad.delete_user_id = user.id; // 插入日志 var add1_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION, oper_object_id = cad.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = cad_dal.CompareValue(oldcad, cad), remark = "删除审批并提交" }; // 创建日志 new sys_oper_log_dal().Insert(add1_log); // 插入日志 if (!cad_dal.Update(cad)) { return(ERROR_CODE.ERROR); } //类型为服务 if (cad.type_id == (int)ACCOUNT_DEDUCTION_TYPE.SERVICE) { var oldccsp = ccsp = ccsp_dal.FindSignleBySql <ctt_contract_service_period>($"select * from ctt_contract_service_period where contract_id={cad.contract_id} and delete_time=0"); ccsp.approve_and_post_date = null; ccsp.approve_and_post_user_id = null; ccsp.period_adjusted_price = ccsp.period_price * ccsp.quantity; ccsp.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); ccsp.update_user_id = user.id; var add2_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_SERVICE_PERIOD, // oper_object_id = ccsp.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = cad_dal.CompareValue(oldccsp, ccsp), remark = "修改合同服务周期" }; // 创建日志 new sys_oper_log_dal().Insert(add2_log); // 插入日志 if (!ccsp_dal.Update(ccsp)) { return(ERROR_CODE.ERROR); } } //类型为服务调整 if (cad.type_id == (int)ACCOUNT_DEDUCTION_TYPE.SERVICE_ADJUST) { var oldccsa = ccsa = ccsa_dal.FindSignleBySql <ctt_contract_service_adjust>($"select * from ctt_contract_service_adjust where contract_id={cad.contract_id} and delete_time=0"); cc = new ctt_contract_dal().FindSignleBySql <ctt_contract>($"select * from ctt_contract where id={cad.contract_id} and delete_time=0"); ccsa.approve_and_post_date = null; ccsa.approve_and_post_user_id = null; ccsa.adjust_prorated_price_change = (decimal)cc.setup_fee; ccsa.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); ccsa.update_user_id = user.id; var add2_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTRACT_SERVICE_ADJUST, // oper_object_id = ccsp.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = cad_dal.CompareValue(oldccsa, ccsa), remark = "修改合同服务调整" }; // 创建日志 new sys_oper_log_dal().Insert(add2_log); // 插入日志 if (ccsp_dal.Update(ccsp)) { } } //类型为初始费用 if (cad.type_id == (int)ACCOUNT_DEDUCTION_TYPE.INITIAL_COST) { var oldcc = cc = new ctt_contract_dal().FindSignleBySql <ctt_contract>($"select * from ctt_contract where id={cad.contract_id} and delete_time=0"); cc.adjust_setup_fee = cc.setup_fee; cc.setup_fee_approve_and_post_user_id = null; cc.setup_fee_approve_and_post_date = null; cc.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); cc.update_user_id = user.id; var add2_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CONTACTS, oper_object_id = cad.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = cad_dal.CompareValue(oldcc, cc), remark = "修改合同初始费用" }; // 创建日志 new sys_oper_log_dal().Insert(add2_log); // 插入日志 if (!new ctt_contract_dal().Update(cc)) { return(ERROR_CODE.ERROR); } } } } } if (!string.IsNullOrEmpty(returnvalue.ToString())) { re = returnvalue.ToString(); return(ERROR_CODE.EXIST); } return(ERROR_CODE.SUCCESS); }
protected decimal befotMoveNum; // 转移前的数量 (余额) protected void Page_Load(object sender, EventArgs e) { long id = 0; if (!string.IsNullOrEmpty(Request.QueryString["id"]) && long.TryParse(Request.QueryString["id"], out id)) { deduction = invBll.GetDeduction(id); } if (deduction != null) { vItem = new DAL.v_widget_posted_item_dal().FindById(deduction.id); if (deduction.contract_id != null) { contract = new ContractBLL().GetContract((long)deduction.contract_id); } if (deduction.contract_block_id != null) { block = new ContractBlockBLL().GetBlockById((long)deduction.contract_block_id); } if (block != null) { contract = new ContractBLL().GetContract(block.contract_id); } string contractTypeSql = string.Empty; // 合同类型过滤 if (contract?.type_id == (int)EMT.DoneNOW.DTO.DicEnum.CONTRACT_TYPE.RETAINER) { contractTypeSql = $" and cc.type_id = {(int)EMT.DoneNOW.DTO.DicEnum.CONTRACT_TYPE.RETAINER} "; dedNum = deduction.extended_price; if (block != null) { befotMoveNum = Convert.ToDecimal(new DAL.crm_account_dal().GetSingle($"SELECT round(b.rate*b.quantity - ifnull((SELECT sum(extended_price)FROM crm_account_deduction WHERE contract_block_id = b.id AND delete_time = 0 ),0),2) AS rate FROM ctt_contract_block b WHERE b.delete_time = 0 and b.id = {block.id} ")); } } else if (contract?.type_id == (int)EMT.DoneNOW.DTO.DicEnum.CONTRACT_TYPE.BLOCK_HOURS) { contractTypeSql = $" and cc.type_id = {(int)EMT.DoneNOW.DTO.DicEnum.CONTRACT_TYPE.BLOCK_HOURS} "; dedNum = deduction.quantity; if (block != null) { befotMoveNum = Convert.ToDecimal(new DAL.crm_account_dal().GetSingle($"SELECT sum(round(b.rate - ifnull((SELECT sum(extended_price)FROM crm_account_deduction WHERE contract_block_id = b.id AND delete_time = 0 ),0),2)) AS rate FROM ctt_contract_block b WHERE b.delete_time = 0 and b.id ={block.id} ")); } } var dtoList = new CompanyBLL().GetBySql <MoveDeductionDto>($@"SELECT ccb.id,ccb.start_date,ccb.end_date,cc.id as contract_id,cc.name as contract_name, ca.id as account_id, ca.name as account_name,ccb.status_id, case cc.type_id when {(int)EMT.DoneNOW.DTO.DicEnum.CONTRACT_TYPE.RETAINER} then round(ccb.rate*ccb.quantity - ifnull((SELECT sum(extended_price)FROM crm_account_deduction WHERE contract_block_id = ccb.id AND delete_time = 0 ),0),2) when {(int)EMT.DoneNOW.DTO.DicEnum.CONTRACT_TYPE.BLOCK_HOURS} then round(ccb.rate - ifnull((SELECT sum(extended_price)FROM crm_account_deduction WHERE contract_block_id = ccb.id AND delete_time = 0 ),0),2) else 0 end as balance from ctt_contract_block ccb INNER JOIN ctt_contract cc on ccb.contract_id = cc.id INNER JOIN crm_account ca on cc.account_id = ca.id where ccb.delete_time =0 and cc.delete_time =0 and (cc.account_id = {deduction.account_id} or ca.parent_id = {deduction.account_id}) {contractTypeSql} and (round(ccb.rate*ccb.quantity - ifnull((SELECT sum(extended_price)FROM crm_account_deduction WHERE contract_block_id = ccb.id AND delete_time = 0 ),0),2) >0 or round(ccb.rate - ifnull((SELECT sum(extended_price)FROM crm_account_deduction WHERE contract_block_id = ccb.id AND delete_time = 0 ),0),2)>0)" ); if (dtoList != null && dtoList.Count > 0) { dtoList = dtoList.OrderBy(_ => _.start_date).ToList(); dic = dtoList.GroupBy(_ => _.contract_id).ToDictionary(_ => _.Key, _ => _.ToList()); } } else { Response.Write("<script>alert('未获取到相关条目!');window.close();</script>"); } }
protected void Page_Load(object sender, EventArgs e) { long id = 0; if (!string.IsNullOrEmpty(Request.QueryString["id"]) && long.TryParse(Request.QueryString["id"], out id)) { deduction = invBll.GetDeduction(id); } //if (deduction == null) //{ // Response.Write("<script>alert('未获取到相关条目');window.close();</script>"); //} long blockId = 0; if (!string.IsNullOrEmpty(Request.QueryString["blockId"]) && long.TryParse(Request.QueryString["blockId"], out blockId)) { block = new ContractBlockBLL().GetBlockById(blockId); } if (deduction != null) { vItem = new DAL.v_widget_posted_item_dal().FindById(deduction.id); rate = vItem?.rate; account = new CompanyBLL().GetCompany(deduction.account_id); if (deduction.contract_id != null) { contract = new ContractBLL().GetContract((long)deduction.contract_id); } if (deduction.task_id != null) { task = new TicketBLL().GetTask((long)deduction.task_id); } labour = new WorkEntryBLL().GetEntryById((long)deduction.object_id); if (vItem?.tax_category_id != null && vItem?.tax_region_id != null) { var thisTax = new DAL.d_tax_region_cate_dal().GetSingleTax((long)vItem?.tax_region_id, (long)vItem?.tax_category_id); taxRate = thisTax?.total_effective_tax_rate; } if (vItem?.resource_id != null) { resource = new UserResourceBLL().GetResourceById((long)vItem.resource_id); } if (deduction.contract_block_id != null) { dedBlock = new ContractBlockBLL().GetBlockById((long)deduction.contract_block_id); } } if (block != null) { contract = new ContractBLL().GetContract(block.contract_id); if (contract != null) { account = new CompanyBLL().GetCompany(contract.account_id); contractType = new GeneralBLL().GetSingleGeneral(contract.type_id); } } if (block == null && deduction == null) { Response.Write("<script>alert('未获取到相关条目');window.close();</script>"); } }