/// <summary> /// 编辑库存仓库 /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="is_default"></param> /// <param name="is_active"></param> /// <param name="userId"></param> /// <returns></returns> public bool EditLocation(long id, string name, bool is_default, bool is_active, long userId) { ivt_warehouse lct = dal.FindById(id); if (lct == null) { return(false); } ivt_warehouse lctOld = dal.FindById(id); lct.name = name; lct.is_active = (sbyte)(is_active ? 1 : 0); lct.is_default = (sbyte)(is_default ? 1 : 0); lct.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lct.update_user_id = userId; if (lct.resource_id != null) { lct.is_default = 0; } if (lctOld.is_default == 0 && lct.is_default == 1) // 只能设置一个默认仓库 { string sql = "update ivt_warehouse set is_default=0 where delete_time=0"; dal.ExecuteSQL(sql); } dal.Update(lct); OperLogBLL.OperLogUpdate <ivt_warehouse>(lct, lctOld, lct.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_LOCATION, "编辑库存仓库"); return(true); }
/// <summary> /// 服务编辑 /// </summary> /// <param name="ser"></param> /// <param name="userId"></param> /// <returns></returns> public bool EditService(ivt_service ser, long userId) { ivt_service_dal dal = new ivt_service_dal(); ivt_service service = dal.FindById(ser.id); ivt_service serOld = dal.FindById(ser.id); service.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); service.update_user_id = userId; service.name = ser.name; service.description = ser.description; service.invoice_description = ser.invoice_description; service.sla_id = ser.sla_id; service.vendor_account_id = ser.vendor_account_id; service.period_type_id = ser.period_type_id; service.unit_cost = ser.unit_cost; service.unit_price = ser.unit_price; service.cost_code_id = ser.cost_code_id; service.is_active = ser.is_active; var desc = OperLogBLL.CompareValue <ivt_service>(serOld, service); if (!string.IsNullOrEmpty(desc)) { dal.Update(service); OperLogBLL.OperLogUpdate(desc, service.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE, "编辑服务"); } return(true); }
/// <summary> /// 设置库存仓库激活/不激活 /// </summary> /// <param name="id"></param> /// <param name="is_active"></param> /// <param name="userId"></param> /// <returns></returns> public bool SetLocationIsActive(long id, bool is_active, long userId) { var lct = dal.FindById(id); var lctOld = dal.FindById(id); if (lct == null) { return(false); } if (is_active) { lct.is_active = 1; } else { lct.is_active = 0; } lct.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lct.update_user_id = userId; dal.Update(lct); OperLogBLL.OperLogUpdate <ivt_warehouse>(lct, lctOld, lct.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_LOCATION, "修改库存仓库激活状态"); return(true); }
/// <summary> /// 删除队列 /// </summary> public bool DeleteQueue(long queId, long userId, ref string faileReason) { sys_department thisQue = _dal.FindNoDeleteById(queId); if (thisQue == null) { return(true); } if (thisQue.is_system == 1) { faileReason = "系统队列,不能删除"; return(false); } List <sys_resource_department> resDepList = GetResDepList(queId); if (resDepList != null && resDepList.Count > 0) { faileReason = "队列下有多个联系人,不能删除"; return(false); } List <sdk_task> ticketList = _dal.FindListBySql <sdk_task>("SELECT * from sdk_task where delete_time =0 and type_id = 1809 and department_id = " + queId.ToString()); if (ticketList != null && ticketList.Count > 0) { faileReason = "队列被多个工单引用,不能删除"; return(false); } _dal.SoftDelete(thisQue, userId); OperLogBLL.OperLogDelete <sys_department>(thisQue, thisQue.id, userId, OPER_LOG_OBJ_CATE.DEPARTMENT, ""); return(true); }
/// <summary> /// 删除预付 /// </summary> /// <param name="blockId"></param> /// <param name="userId"></param> /// <returns></returns> public bool DeletePurchase(long blockId, long userId) { ctt_contract_cost_dal costDal = new ctt_contract_cost_dal(); var list = costDal.FindByBlockId(blockId); foreach (var cost in list) { cost.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); cost.delete_user_id = userId; costDal.Update(cost); OperLogBLL.OperLogDelete <ctt_contract_cost>(cost, cost.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_COST, "删除合同预付"); } var block = dal.FindById(blockId); if (block == null) { return(false); } block.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); block.delete_user_id = userId; dal.Update(block); OperLogBLL.OperLogDelete <ctt_contract_block>(block, block.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_BLOCK, "删除合同预付"); return(true); }
/// <summary> /// 删除库存产品 /// </summary> /// <param name="id"></param> /// <param name="userId"></param> /// <returns></returns> public bool DeleteIvtProduct(long id, long userId) { var pdtInfo = GetIvtProductEdit(id); if (pdtInfo == null) { return(false); } if (int.Parse(pdtInfo.picked) > 0 || int.Parse(pdtInfo.on_order) > 0) { return(false); } ivt_warehouse_product product = dal.FindById(id); string sql = $"update ivt_warehouse_product_sn set delete_user_id={userId},delete_time={Tools.Date.DateHelper.ToUniversalTimeStamp()} where warehouse_product_id={id} and delete_time=0"; dal.ExecuteSQL(sql); product.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); product.delete_user_id = userId; dal.Update(product); OperLogBLL.OperLogDelete <ivt_warehouse_product>(product, id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM, "删除库存产品"); if (int.Parse(pdtInfo.reserved_picked) - int.Parse(pdtInfo.picked) > 0) // 有预留库存产品,删除之 { sql = $"update ivt_reserve set delete_user_id={userId},delete_time={Tools.Date.DateHelper.ToUniversalTimeStamp()} where warehouse_id={product.warehouse_id} and delete_time=0 and quote_item_id in(select id from crm_quote_item where object_id={product.id} and delete_time=0)"; dal.ExecuteSQL(sql); } return(true); }
/// <summary> /// 修改知识库的类别( 某一类别下的所有知识库包括子类别的所有知识库 ) /// </summary> public void ChangeArtCate(long cateId, long userId, int parentId) { var subArt = _dal.GetArtByCate(cateId); var dgDal = new d_general_dal(); var gBll = new GeneralBLL(); var subMenu = dgDal.GetGeneralByParentId(cateId); if (subArt != null && subArt.Count > 0) { foreach (var art in subArt) { subArt.ForEach(_ => { _.kb_category_id = parentId; UpdateKnow(_, userId); }); } } if (subMenu != null && subMenu.Count > 0) { foreach (var menu in subMenu) { ChangeArtCate(menu.id, userId, parentId); dgDal.SoftDelete(menu, userId); OperLogBLL.OperLogAdd <d_general>(menu, menu.id, userId, OPER_LOG_OBJ_CATE.General_Code, "删除知识库目录"); } } }
/// <summary> /// 删除知识库目录 /// </summary> public bool DeleteKnowMenu(long cateId, long userId, ref string failReason) { var dgDal = new d_general_dal(); var cate = dgDal.FindNoDeleteById(cateId); if (cate == null) { return(true); } if (cate.parent_id == null) { failReason = "根目录不可删除"; return(false); } var gBll = new GeneralBLL(); ChangeArtCate(cateId, userId, (int)cate.parent_id); //var subMenu = dgDal.GetGeneralByParentId(cateId); //if (subMenu != null && subMenu.Count > 0) // subMenu.ForEach(_ => { // _.parent_id = cate.parent_id; // gBll.EditGeneral(_,userId); // }); //var subArt = _dal.GetArtByCate(cateId); //if(subArt!=null&& subArt.Count > 0) // subArt.ForEach(_=> { // _.kb_category_id = (int)cate.parent_id; // UpdateKnow(_,userId); // }); dgDal.SoftDelete(cate, userId); OperLogBLL.OperLogAdd <d_general>(cate, cate.id, userId, OPER_LOG_OBJ_CATE.General_Code, "删除知识库目录"); return(true); }
/// <summary> /// 删除知识库 /// </summary> public bool DeleteKnow(long artId, long userId) { var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); var skatDal = new sdk_kb_article_ticket_dal(); var skacDal = new sdk_kb_article_comment_dal(); var thisArt = _dal.FindNoDeleteById(artId); var thisArtTicket = skatDal.GetArtTicket(artId); var thisArtComm = skacDal.GetCommByArt(artId); if (thisArtComm != null && thisArtComm.Count > 0) { thisArtComm.ForEach(_ => { skacDal.SoftDelete(_, userId); OperLogBLL.OperLogDelete <sdk_kb_article_comment>(_, _.id, userId, OPER_LOG_OBJ_CATE.SDK_KONWLEDGE_COMMENT, "删除知识库评论"); }); } if (thisArtTicket != null && thisArtTicket.Count > 0) { thisArtTicket.ForEach(_ => { skatDal.SoftDelete(_, userId); OperLogBLL.OperLogDelete <sdk_kb_article_ticket>(_, _.id, userId, OPER_LOG_OBJ_CATE.SDK_KONWLEDGE_TICKET, "删除知识库关联工单"); }); } if (thisArt != null) { _dal.SoftDelete(thisArt, userId); OperLogBLL.OperLogDelete <sdk_kb_article>(thisArt, thisArt.id, userId, OPER_LOG_OBJ_CATE.SDK_KONWLEDGE, "删除知识库"); } return(true); }
private void SaveProductSn(string snList, long productId, long userId) { if (string.IsNullOrEmpty(snList)) { return; } var sns = snList.Split('\n'); ivt_warehouse_product_sn_dal snDal = new ivt_warehouse_product_sn_dal(); foreach (var sn in sns) { string s = sn.Trim(); if (string.IsNullOrEmpty(s)) { continue; } ivt_warehouse_product_sn psn = new ivt_warehouse_product_sn(); psn.id = dal.GetNextIdCom(); psn.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); psn.create_user_id = userId; psn.update_time = psn.create_time; psn.update_user_id = userId; psn.warehouse_product_id = productId; psn.sn = s; snDal.Insert(psn); OperLogBLL.OperLogAdd <ivt_warehouse_product_sn>(psn, psn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_SN, "新增库存产品串号"); } }
public bool EditTicketTmpl(sys_form_tmpl tmpl, sys_form_tmpl_ticket tmplTicket, List <UserDefinedFieldValue> udfValue, List <CheckListDto> checkList, long userId) { var user = UserInfoBLL.GetUserInfo(userId); sys_form_tmpl_ticket_dal sfttDal = new sys_form_tmpl_ticket_dal(); var oldtmplTicket = sfttDal.FindNoDeleteById(tmplTicket.id); if (oldtmplTicket == null || user == null) { return(false); } if (!EditFormTmpl(tmpl, userId)) { return(false); } tmplTicket.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); tmplTicket.update_user_id = userId; sfttDal.Update(tmplTicket); OperLogBLL.OperLogUpdate <sys_form_tmpl_ticket>(tmplTicket, oldtmplTicket, tmplTicket.id, userId, OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_TICKET, ""); var udf_ticket_list = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.TICKETS); if (udf_ticket_list != null && udf_ticket_list.Count > 0) { new UserDefinedFieldsBLL().UpdateUdfValue(DicEnum.UDF_CATE.FORM_TICKET, udf_ticket_list, tmplTicket.id, udfValue, user, DicEnum.OPER_LOG_OBJ_CATE.SYS_FORM_TMPL_TICKET_EXT); } CheckManage(checkList, tmplTicket.id, userId); return(true); }
/// <summary> /// 取消提交工时表 /// </summary> /// <param name="startDate"></param> /// <param name="resourceId"></param> /// <param name="userId"></param> /// <returns></returns> public bool CancleSubmitWorkEntry(DateTime startDate, long resourceId, long userId) { var weList = GetWorkEntryListByStartDate(startDate, resourceId); if (weList.Count == 0) { return(false); } sdk_work_entry_report_dal rptDal = new sdk_work_entry_report_dal(); var find = rptDal.FindSignleBySql <sdk_work_entry_report>($"select * from sdk_work_entry_report where resource_id={resourceId} and start_date='{startDate}' and delete_time=0"); if (find == null || find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL) { return(false); } sdk_work_entry_report reportOld = rptDal.FindById(find.id); find.status_id = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.HAVE_IN_HAND; find.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); find.update_user_id = userId; find.submit_time = find.update_time; find.submit_user_id = userId; rptDal.Update(find); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry_report>(reportOld, find), find.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表取消提交"); return(true); }
/// <summary> /// 编辑附件 /// </summary> public void EditAttachment(com_attachment att, long userId) { var oldAtt = dal.FindNoDeleteById(att.id); if (oldAtt == null) { return; } att.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); att.update_user_id = userId; dal.Update(att); OperLogBLL.OperLogUpdate <com_attachment>(att, oldAtt, att.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ATTACHMENT, ""); if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.TASK) { var task = new sdk_task_dal().FindNoDeleteById(att.object_id); if (task != null) { #region 更新客户最后活动时间 crm_account thisAccount = new CompanyBLL().GetCompany(task.account_id); if (thisAccount != null) { thisAccount.last_activity_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); new CompanyBLL().EditAccount(thisAccount, userId); } #endregion } } }
/// <summary> /// 编辑工作流规则 /// </summary> /// <param name="workflow"></param> /// <param name="userId"></param> /// <returns></returns> public bool EditWorkflow(sys_workflow workflow, long userId) { sys_workflow wf = dal.FindById(workflow.id); sys_workflow wfOld = dal.FindById(workflow.id); if (wf.workflow_object_id != workflow.workflow_object_id) // 编辑不能修改对象类型 { return(false); } wf.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); wf.update_user_id = userId; wf.name = workflow.name; wf.description = workflow.description; wf.is_active = workflow.is_active; wf.use_default_tmpl = workflow.use_default_tmpl; wf.notify_tmpl_id = workflow.notify_tmpl_id; wf.notify_subject = workflow.notify_subject; wf.event_json = workflow.event_json; wf.condition_json = workflow.condition_json; wf.update_json = workflow.update_json; string desc = OperLogBLL.CompareValue <sys_workflow>(wfOld, wf); if (!string.IsNullOrEmpty(desc)) { dal.Update(wf); OperLogBLL.OperLogUpdate(desc, wf.id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORKFLOW_RULE, "编辑工作流规则"); } return(true); }
/// <summary> /// 服务新增 /// </summary> /// <param name="ser"></param> /// <param name="userId"></param> /// <returns></returns> public bool AddService(ivt_service ser, long userId) { ivt_service service = new ivt_service(); ivt_service_dal dal = new ivt_service_dal(); service.id = dal.GetNextIdCom(); service.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); service.update_time = service.create_time; service.create_user_id = userId; service.update_user_id = userId; service.name = ser.name; service.description = ser.description; service.invoice_description = ser.invoice_description; service.sla_id = ser.sla_id; service.vendor_account_id = ser.vendor_account_id; service.period_type_id = ser.period_type_id; service.unit_cost = ser.unit_cost; service.unit_price = ser.unit_price; service.cost_code_id = ser.cost_code_id; service.is_active = ser.is_active; dal.Insert(service); OperLogBLL.OperLogAdd <ivt_service>(service, service.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE, "新增服务"); return(true); }
/// <summary> /// 新增工时 /// </summary> /// <param name="weList"></param> /// <param name="userId"></param> /// <returns></returns> public bool AddWorkEntry(List <sdk_work_entry> weList, long userId) { var bll = new TimeOffPolicyBLL(); tst_timeoff_balance_dal balDal = new tst_timeoff_balance_dal(); long batchId = dal.GetNextId("seq_entry_batch"); foreach (var we in weList) { we.id = dal.GetNextIdCom(); we.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); we.update_time = we.create_time; we.create_user_id = userId; we.update_user_id = userId; we.batch_id = batchId; dal.Insert(we); OperLogBLL.OperLogAdd <sdk_work_entry>(we, we.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_ENTRY, "新增工时"); if (we.task_id == (long)CostCode.Sick) // 病假需要在假期余额表添加记录 { bll.UpdateTimeoffBalance(we.resource_id.Value, Tools.Date.DateHelper.TimeStampToUniversalDateTime(we.start_time.Value), (CostCode)we.task_id); //var balance = bll.UpdateTimeoffBalance((long)we.resource_id, Tools.Date.DateHelper.TimeStampToDateTime((long)we.start_time), 0 - (decimal)we.hours_billed); //tst_timeoff_balance bal = new tst_timeoff_balance(); //bal.object_id = we.id; //bal.object_type_id = 2214; //bal.task_id = we.task_id; //bal.resource_id = (long)we.resource_id; //bal.balance = balance - (decimal)we.hours_billed; //balDal.Insert(bal); } } return(true); }
/// <summary> /// 设置库存仓库为默认仓库,如果仓库为停用状态,设置为激活 /// </summary> /// <param name="id"></param> /// <param name="userId"></param> /// <returns></returns> public bool SetLocationDefault(long id, long userId) { var lct = dal.FindById(id); if (lct == null) { return(false); } if (lct.resource_id != null) // 员工仓库不能设置为默认 { return(false); } var lctOld = dal.FindById(id); string sql = "update ivt_warehouse set is_default=0 where delete_time=0"; dal.ExecuteSQL(sql); lct.is_default = 1; lct.is_active = 1; lct.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lct.update_user_id = userId; dal.Update(lct); OperLogBLL.OperLogUpdate <ivt_warehouse>(lct, lctOld, lct.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_LOCATION, "修改库存仓库为默认"); return(true); }
/// <summary> /// 新增评论 /// </summary> public bool SaveComment(long artId, string comment, long userId) { var thisArt = _dal.FindNoDeleteById(artId); var thisUser = new sys_resource_dal().FindNoDeleteById(userId); if (thisArt != null && !string.IsNullOrEmpty(comment) && thisUser != null) { var skacDal = new sdk_kb_article_comment_dal(); var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); var comm = new sdk_kb_article_comment() { comment = comment, create_time = timeNow, create_user_id = userId, id = skacDal.GetNextIdCom(), update_time = timeNow, update_user_id = userId, creator_name = thisUser.name, kb_article_id = thisArt.id, }; skacDal.Insert(comm); OperLogBLL.OperLogAdd <sdk_kb_article_comment>(comm, comm.id, userId, OPER_LOG_OBJ_CATE.SDK_KONWLEDGE_COMMENT, "新增知识库评论"); return(true); } else { return(false); } }
/// <summary> /// 设置邮件模板默认 /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <param name="userId"></param> /// <returns></returns> public bool SetDefault(long id, int type, long userId) { var tmpl = dal.FindNoDeleteById(id); if (tmpl == null || tmpl.is_system_default == 1) { return(false); } sys_quote_email_tmpl old; var dft = dal.FindSignleBySql <sys_quote_email_tmpl>($"select * from sys_quote_email_tmpl where is_system_default=1 and cate_id={type}"); if (dft != null) { old = dal.FindById(dft.id); dft.is_system_default = 0; dft.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); dft.update_user_id = userId; dal.Update(dft); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sys_quote_email_tmpl>(old, dft), dft.id, userId, DicEnum.OPER_LOG_OBJ_CATE.QUOTE_TEMP, "取消邮件模板默认"); } old = dal.FindById(tmpl.id); tmpl.is_system_default = 1; tmpl.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); tmpl.update_user_id = userId; dal.Update(tmpl); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sys_quote_email_tmpl>(old, tmpl), tmpl.id, userId, DicEnum.OPER_LOG_OBJ_CATE.QUOTE_TEMP, "设置邮件模板默认"); return(true); }
public bool DeleteLocation(long location_id, long user_id) { var location = _dal.GetLocationById(location_id); var result = _dal.SoftDelete(location, user_id); OperLogBLL.OperLogDelete <crm_location>(location, location.id, user_id, OPER_LOG_OBJ_CATE.CUSTOMER, "删除客户"); return(result); }
/// <summary> /// 删除合同费率 /// </summary> /// <param name="id"></param> /// <param name="userId"></param> public void DeleteRate(long id, long userId) { var rate = dal.FindById(id); rate.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); rate.delete_user_id = userId; dal.Update(rate); OperLogBLL.OperLogDelete <ctt_contract_rate>(rate, rate.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.CONTRACT_RATE, "删除合同费率"); }
/// <summary> /// 新增工作组员工 /// </summary> public bool AddGroupResource(sys_workgroup_resouce group, long userId) { sys_workgroup_resouce_dal swrDal = new sys_workgroup_resouce_dal(); group.id = swrDal.GetNextIdCom(); swrDal.Insert(group); OperLogBLL.OperLogAdd <sys_workgroup_resouce>(group, group.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SYS_WORKGROUP_RESOURCE, ""); return(true); }
/// <summary> /// 新增队列 /// </summary> public bool AddQueue(sys_department queue, long userId) { queue.id = _dal.GetNextIdCom(); queue.create_time = queue.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); queue.create_user_id = queue.update_user_id = userId; _dal.Insert(queue); OperLogBLL.OperLogAdd <sys_department>(queue, queue.id, userId, OPER_LOG_OBJ_CATE.DEPARTMENT, ""); return(true); }
/// <summary> /// 工时表提交 /// </summary> /// <param name="startDate"></param> /// <param name="resourceId"></param> /// <param name="userId"></param> /// <returns></returns> public bool SubmitWorkEntry(DateTime startDate, long resourceId, long userId) { var weList = GetWorkEntryListByStartDate(startDate, resourceId); //if (weList.Count == 0) // return false; sdk_work_entry_report report = new sdk_work_entry_report(); sdk_work_entry_report_dal rptDal = new sdk_work_entry_report_dal(); var find = rptDal.FindSignleBySql <sdk_work_entry_report>($"select * from sdk_work_entry_report where resource_id={resourceId} and start_date='{startDate}' and delete_time=0"); if (find != null && find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.HAVE_IN_HAND && find.status_id != (int)DicEnum.WORK_ENTRY_REPORT_STATUS.REJECTED) { return(false); } if (find == null) { report.id = rptDal.GetNextIdCom(); report.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); report.update_time = report.create_time; report.create_user_id = userId; report.update_user_id = userId; report.resource_id = resourceId; report.start_date = startDate; report.end_date = startDate.AddDays(6); report.status_id = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL; report.submit_time = report.create_time; report.submit_user_id = userId; rptDal.Insert(report); OperLogBLL.OperLogAdd <sdk_work_entry_report>(report, report.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表提交"); foreach (var we in weList) { var weOld = dal.FindById(we.id); we.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); we.update_user_id = userId; we.work_entry_report_id = report.id; dal.Update(we); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry>(weOld, we), we.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_ENTRY, "工时表提交"); } } else { sdk_work_entry_report reportOld = rptDal.FindById(find.id); find.status_id = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL; find.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); find.update_user_id = userId; find.submit_time = find.update_time; find.submit_user_id = userId; rptDal.Update(find); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry_report>(reportOld, find), find.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表提交"); } return(true); }
/// <summary> /// 费用报表 管理(新增,编辑) /// </summary> public bool ReportManage(sdk_expense_report report, long userId, bool isCopy = false, long copyId = 0) { try { var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); report.update_user_id = userId; report.update_time = timeNow; if (report.id == 0) { report.id = _dal.GetNextIdCom(); report.create_time = timeNow; report.create_user_id = userId; report.submit_user_id = userId; report.submit_time = report.create_time; _dal.Insert(report); OperLogBLL.OperLogAdd <sdk_expense_report>(report, report.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE_REPORT, "新增费用报表"); // 代表是复制操作 if (isCopy && copyId != 0) { var seDal = new sdk_expense_dal(); // 复制时,将原有的费用复制,已经审批提交的只复制相关信息,审批状态不复制 var thisExpList = seDal.GetExpByReport(copyId); if (thisExpList != null && thisExpList.Count > 0) { thisExpList.ForEach(_ => { _.id = seDal.GetNextIdCom(); _.oid = 0; _.expense_report_id = report.id; _.create_time = timeNow; _.update_time = timeNow; _.create_user_id = userId; _.update_user_id = userId; _.approve_and_post_date = null; _.approve_and_post_user_id = null; seDal.Insert(_); OperLogBLL.OperLogAdd <sdk_expense>(_, _.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE, "新增费用"); }); } } } else { var oldReport = _dal.FindNoDeleteById(report.id); if (oldReport != null) { _dal.Update(report); OperLogBLL.OperLogUpdate <sdk_expense_report>(report, oldReport, report.id, userId, OPER_LOG_OBJ_CATE.SDK_EXPENSE_REPORT, "修改费用报表"); } } } catch (Exception) { return(false); } return(true); }
/// <summary> /// 删除工作流规则 /// </summary> /// <param name="id"></param> /// <param name="userId"></param> /// <returns></returns> public bool DeleteWorkflow(long id, long userId) { sys_workflow wf = dal.FindById(id); wf.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); wf.delete_user_id = userId; dal.Update(wf); OperLogBLL.OperLogDelete <sys_workflow>(wf, wf.id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORKFLOW_RULE, "删除工作流规则"); return(true); }
/// <summary> /// 工时表审批 /// </summary> /// <param name="ids">,号分割的多个工时表id</param> /// <param name="userId"></param> /// <returns></returns> public int ApproveWorkEntryReport(string ids, long userId) { int appCnt = 0; var rptDal = new sdk_work_entry_report_dal(); var logDal = new tst_work_entry_report_log_dal(); var reports = rptDal.FindListBySql($"select * from sdk_work_entry_report where id in({ids}) and status_id={(int)DicEnum.WORK_ENTRY_REPORT_STATUS.WAITING_FOR_APPROVAL} and delete_time=0"); if (reports == null || reports.Count == 0) { return(appCnt); } var user = new UserResourceBLL().GetResourceById(userId); foreach (var report in reports) { // 判断用户是否在当前可以审批工时表 int tier = GetWorkEntryReportCurrentApproveTier(report.id); if (tier == 3) { continue; } var aprvResList = GetApproverList((long)report.resource_id); tier++; if (user.security_level_id == 1 || aprvResList.Exists(_ => _.tier == tier && _.approver_resource_id == userId)) // 用户是管理员或用户可以审批下一级 { tst_work_entry_report_log log = new tst_work_entry_report_log(); log.id = logDal.GetNextIdCom(); log.work_entry_report_id = report.id; log.oper_user_id = userId; log.oper_type_id = (int)DicEnum.WORK_ENTRY_REPORT_OPER_TYPE.APPROVAL; log.oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); log.tier = tier; logDal.Insert(log); OperLogBLL.OperLogAdd <tst_work_entry_report_log>(log, log.id, userId, DicEnum.OPER_LOG_OBJ_CATE.WORK_ENTRY_REPORT_LOG, "工时表审批"); appCnt++; if (aprvResList.Count == 0 || aprvResList.Max(_ => _.tier) == tier) // 是最后一级审批人 { var rptOld = rptDal.FindById(report.id); report.status_id = (int)DicEnum.WORK_ENTRY_REPORT_STATUS.PAYMENT_BEEN_APPROVED; report.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); report.update_user_id = userId; report.approve_time = report.update_time; report.approve_user_id = userId; rptDal.Update(report); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <sdk_work_entry_report>(rptOld, report), report.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SDK_WORK_RECORD, "工时表审批"); } } } return(appCnt); }
/// <summary> /// 删除服务包相关,不能删除时,返回所有不能删除相关对象数量 /// </summary> public bool DeleteServiceBundle(long serviceId, long userId, ref string faileReason) { try { var isbDal = new ivt_service_bundle_dal(); var thisSerBundle = isbDal.FindNoDeleteById(serviceId); if (thisSerBundle == null) { return(true); } var conSerList = new ctt_contract_service_dal().getContractByServiceId(thisSerBundle.id); if (conSerList != null && conSerList.Count > 0) { faileReason += $"{conSerList.Count} 合同\n"; } var quoteItemList = new crm_quote_item_dal().GetItemByObjId(thisSerBundle.id); if (quoteItemList != null && quoteItemList.Count > 0) { faileReason += $"{quoteItemList.Count} 报价项\n"; } var labourList = new sdk_work_entry_dal().GetListByService(thisSerBundle.id); if (labourList != null && labourList.Count > 0) { faileReason += $"{labourList.Count} 工时\n"; } var insProList = new crm_installed_product_dal().GetInsListBySerBunId(thisSerBundle.id); if (insProList != null && insProList.Count > 0) { faileReason += $"{insProList.Count} 配置项\n"; } if (!string.IsNullOrEmpty(faileReason)) { return(false); } else { var isbsDal = new ivt_service_bundle_service_dal(); var serList = GetServiceListByServiceBundleId(thisSerBundle.id); if (serList != null && serList.Count > 0) { serList.ForEach(_ => { isbsDal.Delete(_); }); } isbDal.SoftDelete(thisSerBundle, userId); OperLogBLL.OperLogDelete <ivt_service_bundle>(thisSerBundle, thisSerBundle.id, userId, DTO.DicEnum.OPER_LOG_OBJ_CATE.IVT_SERVICE_BUNDLE, "删除服务包"); } } catch (Exception) { return(false); } return(true); }
/// <summary> /// 撤销费用审批 /// </summary> public ERROR_CODE REVOKE_EXPENSE(long user_id, string ids, out string re) { re = ""; if (!string.IsNullOrEmpty(ids)) { var idArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var cadDal = new crm_account_deduction_dal(); var seDal = new sdk_expense_dal(); StringBuilder returnvalue = new StringBuilder(); var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); foreach (var accId in idArr) { var thisCad = cadDal.FindNoDeleteById(long.Parse(accId)); if (thisCad != null) { 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(accId + "条目已经生成发票(发票ID:" + thisCad.invoice_id + "),请先作废该发票\n"); } } else { #region 除条目信息 // var oldCad = cadDal.FindNoDeleteById(long.Parse(accId)); cadDal.SoftDelete(thisCad, user_id); OperLogBLL.OperLogDelete <crm_account_deduction>(thisCad, thisCad.id, user_id, OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION, "删除审批并提交条目"); #endregion #region 修改费用表 if (thisCad.object_id != null) { var se = seDal.FindNoDeleteById((long)thisCad.object_id); if (se != null) { var oldSe = seDal.FindNoDeleteById((long)thisCad.object_id); se.approve_and_post_date = null; se.approve_and_post_user_id = null; se.amount_deduction = null; se.update_time = timeNow; se.update_user_id = user_id; seDal.Update(se); OperLogBLL.OperLogUpdate <sdk_expense>(se, oldSe, se.id, user_id, OPER_LOG_OBJ_CATE.SDK_EXPENSE, "修改费用"); } } #endregion } } } } return(ERROR_CODE.SUCCESS); }
/// <summary> /// 新增工作组 /// </summary> public bool AddGroup(sys_workgroup group, long userId) { sys_workgroup_dal swDal = new sys_workgroup_dal(); group.id = swDal.GetNextIdCom(); group.create_time = group.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); group.create_user_id = group.update_user_id = userId; swDal.Insert(group); OperLogBLL.OperLogAdd <sys_workgroup>(group, group.id, userId, DicEnum.OPER_LOG_OBJ_CATE.SYS_WORKGROUP, ""); return(true); }