protected void Page_Load(object sender, EventArgs e)
 {
     if (!int.TryParse(Request.QueryString["id"], out id))
     {
         Response.Write("<script>alert('异常!');window.close();self.opener.location.reload();</script>");
     }
     ccm = new ctt_contract_milestone_dal().FindSignleBySql <ctt_contract_milestone>($"select * from ctt_contract_milestone where id={id} and delete_time=0");//里程碑
 }
Example #2
0
        protected void SaveClose()
        {
            ctt_contract_milestone milst = AssembleModel <ctt_contract_milestone>();

            if (long.Parse(milstId.Value) == 0)
            {
                bll.AddMilestone(milst, GetLoginUserId());
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('新增里程碑成功');window.close();self.opener.location.reload();</script>");
            }
            else
            {
                milst.id = long.Parse(milstId.Value);
                bll.UpdateMilestone(milst, GetLoginUserId());
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('编辑里程碑成功');window.close();self.opener.location.reload();</script>");
            }
            statuList = bll.GetMilestoneStatuDic();
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            udfList      = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.CONTRACTS);
            resourceList = new DAL.sys_resource_dal().GetSourceList();
            roleList     = new DAL.sys_role_dal().GetList();
            long quoteId = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["quoteId"]) && long.TryParse(Request.QueryString["quoteId"], out quoteId))
            {
                quote = new QuoteBLL().GetQuote(quoteId);
                if (quote != null)
                {
                    account = new CompanyBLL().GetCompany(quote.account_id);
                }
            }

            if (IsPostBack)
            {
                ContractAddDto dto = new ContractAddDto();
                dto.contract = AssembleModel <ctt_contract>();

                if (!string.IsNullOrEmpty(Request.Form["isSdtDefault"]) && Request.Form["isSdtDefault"].Equals("on"))
                {
                    dto.contract.is_sdt_default = 1;
                }

                if (!string.IsNullOrEmpty(Request.Form["needTimeSheet"]) && Request.Form["needTimeSheet"].Equals("on"))
                {
                    dto.contract.timeentry_need_begin_end = 1;
                }
                else
                {
                    dto.contract.timeentry_need_begin_end = 0;
                }

                if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.BLOCK_HOURS)
                {
                    if (!string.IsNullOrEmpty(Request.Form["enableOverage"]) && Request.Form["enableOverage"].Equals("on"))
                    {
                        dto.contract.enable_overage_billing_rate = 1;
                    }
                }

                if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.FIXED_PRICE)
                {
                    if (!string.IsNullOrEmpty(Request.Form["applyPayment"]) && Request.Form["applyPayment"].Equals("on"))
                    {
                        decimal price = 0;
                        if (decimal.TryParse(Request.Form["alreadyReceived"], out price) && price > 0)
                        {
                            dto.alreadyReceived = price;
                        }
                        if (decimal.TryParse(Request.Form["toBeInvoiced"], out price) && price > 0)
                        {
                            dto.toBeInvoiced = price;
                        }
                        long code = 0;
                        if (long.TryParse(Request.Form["defaultCostCode"], out code))
                        {
                            dto.defaultCostCode = code;
                        }
                    }
                }

                if (udfList != null && udfList.Count > 0)                      // 首先判断是否有自定义信息
                {
                    var list = new List <UserDefinedFieldValue>();
                    foreach (var udf in udfList)                            // 循环添加
                    {
                        var new_udf = new UserDefinedFieldValue()
                        {
                            id    = udf.id,
                            value = Request.Form[udf.id.ToString()] == "" ? null : Request.Form[udf.id.ToString()],
                        };
                        list.Add(new_udf);
                    }
                    dto.udf = list;
                }

                // 服务
                dto.serviceList = new List <ServiceInfoDto>();
                if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.SERVICE)
                {
                    if (!string.IsNullOrEmpty(Request.Form["AddServiceIds"]))   // 服务
                    {
                        string[] ids = Request.Form["AddServiceIds"].Split(',');
                        foreach (string id in ids)
                        {
                            ServiceInfoDto si = new ServiceInfoDto();
                            si.price     = decimal.Parse(Request.Form["price" + id]);
                            si.number    = decimal.Parse(Request.Form["num" + id]);
                            si.serviceId = long.Parse(id);
                            si.type      = 1;
                            dto.serviceList.Add(si);
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Form["AddSerBunIds"]))    // 服务包
                    {
                        string[] ids = Request.Form["AddSerBunIds"].Split(',');
                        foreach (string id in ids)
                        {
                            ServiceInfoDto si = new ServiceInfoDto();
                            si.price     = decimal.Parse(Request.Form["price" + id]);
                            si.number    = decimal.Parse(Request.Form["num" + id]);
                            si.serviceId = long.Parse(id);
                            si.type      = 2;
                            dto.serviceList.Add(si);
                        }
                    }
                }

                // 里程碑
                dto.milestone = new List <ctt_contract_milestone>();
                if (dto.contract.type_id == (int)DicEnum.CONTRACT_TYPE.FIXED_PRICE && (!string.IsNullOrEmpty(Request.Form["milestoneAddList"])))
                {
                    string[] ids = Request.Form["milestoneAddList"].Split(',');
                    foreach (string id in ids)
                    {
                        ctt_contract_milestone mil = new ctt_contract_milestone();
                        mil.name        = Request.Form["MilName" + id];
                        mil.description = Request.Form["MilDetail" + id];
                        decimal dollar = 0;
                        if (!decimal.TryParse(Request.Form["MilAmount" + id], out dollar))
                        {
                            dollar = 0;
                        }
                        mil.dollars      = dollar;
                        mil.due_date     = DateTime.Parse(Request.Form["MilDate" + id]);
                        mil.cost_code_id = long.Parse(Request.Form["MilCode" + id]);
                        mil.status_id    = int.Parse(Request.Form["isBill" + id]);
                        dto.milestone.Add(mil);
                    }
                }

                // 角色费率
                dto.rateList = new List <ContractRateDto>();
                if (dto.contract.type_id != (int)DicEnum.CONTRACT_TYPE.SERVICE &&
                    dto.contract.type_id != (int)DicEnum.CONTRACT_TYPE.PER_TICKET)
                {
                    foreach (var role in roleList)
                    {
                        if (Request.Form["cbRoleRate" + role.id] != null && Request.Form["cbRoleRate" + role.id].Equals("on"))
                        {
                            var roleRate = new ContractRateDto();
                            roleRate.roleId = role.id;
                            roleRate.rate   = decimal.Parse(Request.Form["txtRoleRate" + role.id]);
                            dto.rateList.Add(roleRate);
                        }
                    }
                }

                // 邮件通知
                dto.notifyUserIds = new List <long>();
                foreach (var res in resourceList)
                {
                    if (Request.Form["notify" + res.id] != null && Request.Form["notify" + res.id].Equals("on"))
                    {
                        dto.notifyUserIds.Add(res.id);
                    }
                }
                if (dto.notifyUserIds.Count != 0)
                {
                    dto.notifySubject = Request.Form["notifyTitle"];
                    dto.notifyMessage = Request.Form["notifyContent"];
                    dto.notifyEmails  = Request.Form["notifyEmails"];
                }

                contractId   = bll.Insert(dto, GetLoginUserId());
                contractType = dto.contract.type_id;
                isFinish     = 1;
            }
            else
            {
                if (!int.TryParse(Request.QueryString["type"], out contractType))
                {
                    contractType = 0;
                }
                isFinish = 0;
            }

            Dictionary <string, object> dics = bll.GetField();

            contractCate = dics["cate"] as List <DictionaryEntryDto>;
            periodType   = dics["periodType"] as List <DictionaryEntryDto>;
            periodType.Remove(periodType.Find(pt => pt.val.Equals(((int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME).ToString())));
            billPostType = dics["billPostType"] as List <DictionaryEntryDto>;
            slaList      = bll.GetSLAList();

            contractTypeName = bll.GetContractTypeName(contractType);
        }
Example #4
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);
        }