Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId);
                if (!IsPostBack)
                {
                    ThisPageDataBind();
                }
                task_udfList = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.TASK);
                var project_id = Request.QueryString["project_id"];
                if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = ppdal.FindNoDeleteById(long.Parse(project_id));
                }
                var parTaskId = Request.QueryString["par_task_id"];
                if (!string.IsNullOrEmpty(parTaskId))
                {
                    parTask = sdDal.FindNoDeleteById(long.Parse(parTaskId));
                    if (parTask != null)
                    {
                        if (parTask.project_id != null)
                        {
                            thisProject = ppdal.FindNoDeleteById((long)parTask.project_id);
                        }
                    }
                }

                var typeString = Request.QueryString["type_id"];
                if (!string.IsNullOrEmpty(typeString))
                {
                    type_id = int.Parse(typeString);
                    if (!IsPostBack)
                    {
                        switch (type_id)
                        {
                        case (int)DicEnum.TASK_TYPE.PROJECT_ISSUE:
                            isProject_issue.Checked = true;
                            break;

                        case (int)DicEnum.TASK_TYPE.PROJECT_TASK:
                            isProject_issue.Checked = false;
                            break;

                        default:
                            break;
                        }
                    }
                }
                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisTask = sdDal.FindNoDeleteById(long.Parse(id));
                    if (thisTask != null)
                    {
                        if (thisTask.parent_id != null)
                        {
                            parTask = sdDal.FindNoDeleteById((long)thisTask.parent_id);
                        }
                        type_id = thisTask.type_id;
                        isAdd   = false;
                        var isCopyString = Request.QueryString["IsCopy"];
                        if (!string.IsNullOrEmpty(isCopyString) && thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_TASK)
                        {
                            isCopy = true;
                        }
                        if (thisTask.project_id != null)
                        {
                            thisProject = ppdal.FindNoDeleteById((long)thisTask.project_id);
                        }
                        task_udfValueList = new UserDefinedFieldsBLL().GetUdfValue(DicEnum.UDF_CATE.TASK, thisTask.id, task_udfList);
                        noteList          = new com_activity_dal().GetActiList($" and (task_id ={thisTask.id} or object_id={thisTask.id} )");

                        preList = new sdk_task_predecessor_dal().GetRelList(thisTask.id);
                        if (!IsPostBack)
                        {
                            status_id.SelectedValue = thisTask.status_id.ToString();
                            if (thisTask.is_visible_in_client_portal == 0)
                            {
                                DisplayInCapNone.Checked = true;
                            }
                            else
                            {
                                if (thisTask.can_client_portal_user_complete_task == 1)
                                {
                                    DisplayInCapYes.Checked = true;
                                }
                                else
                                {
                                    DisplayInCapYesNoComplete.Checked = true;
                                }
                            }

                            if (thisTask.is_project_issue == 1)
                            {
                                isProject_issue.Checked = true;
                            }
                            else
                            {
                                isProject_issue.Checked = false;
                            }

                            if (thisTask.estimated_type_id == (int)DicEnum.TIME_ENTRY_METHOD_TYPE.FIXWORK)
                            {
                                TaskTypeFixedWork.Checked = true;
                            }
                            else if (thisTask.estimated_type_id == (int)DicEnum.TIME_ENTRY_METHOD_TYPE.FIXDURATION)
                            {
                                TaskTypeFixedDuration.Checked = true;
                            }
                            else
                            {
                            }

                            department_id.SelectedValue = thisTask.department_id == null ? "" : ((int)thisTask.department_id).ToString();
                        }
                        var typeName = "任务";
                        //  判断是阶段,查询出相关项目的关联合同的里程碑  和自己的里程碑
                        if (type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE && thisProject != null && thisProject.contract_id != null)
                        {
                            typeName = "阶段";
                            // 获取该项目合同下未被关联的里程碑
                            var proConMilList = new ctt_contract_milestone_dal().GetListByProId(thisProject.id);
                            // 获取该阶段下的所有里程碑
                            var phaMilList = new sdk_task_milestone_dal().GetPhaMilList(thisTask.id);
                            thisPhaMile = new List <PageMile>();
                            if (proConMilList != null && proConMilList.Count > 0)
                            {
                                thisPhaMile.AddRange(proConMilList);
                            }
                            if (phaMilList != null && phaMilList.Count > 0)
                            {
                                thisPhaMile.AddRange(phaMilList);
                            }
                            if (thisPhaMile.Count > 0)
                            {
                                thisPhaMile = thisPhaMile.OrderBy(_ => _.dueDate).ToList();
                            }
                        }
                        #region 记录浏览历史
                        if (!isCopy && !isAdd)
                        {
                            var account = new CompanyBLL().GetCompany(thisTask.account_id);
                            var history = new sys_windows_history()
                            {
                                title = $"编辑{typeName}:" + (thisProject != null ? thisProject.name : "") + " " + thisTask.title + " " + (account != null ? account.name : ""),
                                url   = Request.RawUrl,
                            };
                            new IndexBLL().BrowseHistory(history, LoginUserId);
                        }
                        #endregion
                    }
                }
                if (type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
                {
                    isPhase = true;
                }

                if (thisProject == null)
                {
                    Response.End();
                }
                else
                {
                    if (thisProject.contract_id != null)
                    {
                        thisProContract = new ctt_contract_dal().FindNoDeleteById((long)thisProject.contract_id);
                        rateList        = new ctt_contract_rate_dal().GetRateByConId((long)thisProject.contract_id);
                    }
                }
            }
            catch (Exception msg)
            {
                Response.End();
            }
        }