Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         conCost = new ctt_contract_cost_dal().FindNoDeleteById(long.Parse(Request.QueryString["id"]));
     }
     catch (Exception)
     {
         Response.End();
         Response.Write("<script>alert('成本不存在!');window.close();</script>");
     }
 }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var cost_id     = Request.QueryString["id"];
                var contract_id = Request.QueryString["contract_id"];
                var project_id  = Request.QueryString["project_id"];
                var task_id     = Request.QueryString["task_id"];
                var ticket_id   = Request.QueryString["ticket_id"];
                var costCodeId  = Request.QueryString["cost_code_id"];
                if (!string.IsNullOrEmpty(costCodeId))
                {
                    costCode = new d_cost_code_dal().FindNoDeleteById(long.Parse(costCodeId));
                }

                #region  拉框赋值
                cost_type_id.DataTextField  = "show";
                cost_type_id.DataValueField = "val";
                cost_type_id.DataSource     = dic.FirstOrDefault(_ => _.Key == "chargeType").Value;
                cost_type_id.DataBind();
                cost_type_id.Items.Insert(0, new ListItem()
                {
                    Value = "0", Text = "   ", Selected = true
                });
                cost_type_id.SelectedValue = ((int)DicEnum.COST_TYPE.OPERATIONA).ToString();

                // status_id
                status_id.DataTextField  = "show";
                status_id.DataValueField = "val";
                var statuList = dic.FirstOrDefault(_ => _.Key == "chargeStatus").Value as List <DictionaryEntryDto>;

                #endregion
                if (!string.IsNullOrEmpty(contract_id))
                {
                    contract = new ctt_contract_dal().FindNoDeleteById(long.Parse(contract_id));
                    if (contract != null)
                    {
                        if (!IsPostBack)
                        {
                            isbillable.Checked = true;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(cost_id))
                {
                    conCost = new ctt_contract_cost_dal().FindNoDeleteById(long.Parse(cost_id));
                    if (conCost != null)
                    {
                        isAdd    = false;
                        costCode = new d_cost_code_dal().FindNoDeleteById(conCost.cost_code_id);

                        cost_type_id.SelectedValue = conCost.cost_type_id == null ? ((int)DicEnum.COST_TYPE.OPERATIONA).ToString() : conCost.cost_type_id.ToString();
                        if (!IsPostBack)
                        {
                            status_id.SelectedValue = conCost.status_id.ToString();
                        }


                        if (conCost.contract_id != null)
                        {
                            contract = new ctt_contract_dal().FindNoDeleteById((long)conCost.contract_id);
                        }
                        if (conCost.project_id != null)
                        {
                            thisProject = new pro_project_dal().FindNoDeleteById((long)conCost.project_id);
                        }
                        if (conCost.task_id != null)
                        {
                            thisTask = new sdk_task_dal().FindNoDeleteById((long)conCost.task_id);
                            if (thisTask.type_id == (int)DicEnum.TASK_TYPE.SERVICE_DESK_TICKET)
                            {
                                thisTask   = null;
                                thisTicket = new sdk_task_dal().FindNoDeleteById((long)conCost.task_id);
                            }
                        }

                        if (!IsPostBack)
                        {
                            isbillable.Checked    = conCost.is_billable == 1;
                            AddConfigItem.Checked = conCost.create_ci == 1;
                        }

                        if (conCost.status_id == (int)DicEnum.COST_STATUS.UNDETERMINED)
                        {
                            statuList = statuList.Where(_ => _.val == (conCost.status_id).ToString() || _.val == ((int)DicEnum.COST_STATUS.PENDING_PURCHASE).ToString() || _.val == ((int)DicEnum.COST_STATUS.CANCELED).ToString()).ToList();
                        }
                        else if (conCost.status_id == (int)DicEnum.COST_STATUS.CANCELED)
                        {
                            statuList = statuList.Where(_ => _.val == (conCost.status_id).ToString() || _.val == ((int)DicEnum.COST_STATUS.PENDING_PURCHASE).ToString() || _.val == ((int)DicEnum.COST_STATUS.CANCELED).ToString()).ToList();
                        }
                        else
                        {
                            statuList = statuList.Where(_ => _.val == (conCost.status_id).ToString() || _.val == ((int)DicEnum.COST_STATUS.CANCELED).ToString()).ToList();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(project_id));
                }
                if (!string.IsNullOrEmpty(task_id))
                {
                    thisTask = new sdk_task_dal().FindNoDeleteById(long.Parse(task_id));
                    if (thisTask != null && thisTask.project_id != null)
                    {
                        thisProject = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id);
                    }
                }
                if (!string.IsNullOrEmpty(ticket_id))
                {
                    thisTicket = new sdk_task_dal().FindNoDeleteById(long.Parse(ticket_id));
                }
                if (thisTicket != null)
                {
                    thisAccount = new CompanyBLL().GetCompany(thisTicket.account_id);
                }

                status_id.DataSource = statuList;
                status_id.DataBind();
                //status_id.Items.Insert(0, new ListItem() { Value = "0", Text = "   ", Selected = true });
                if (!IsPostBack)
                {
                    if (isAdd)
                    {
                        status_id.SelectedValue = ((int)DicEnum.COST_STATUS.PENDING_DELIVERY).ToString();
                    }
                }
            }
            catch (Exception msg)
            {
                Response.End();
            }
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 新增报价项
        /// </summary>
        /// <param name="quote_item"></param>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public ERROR_CODE Insert(crm_quote_item quote_item, Dictionary <long, int> wareDic, long user_id, bool isSaleOrder = false, long?saleOrderId = null)
        {
            if (quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISCOUNT)
            {
                if (quote_item.unit_price == null || quote_item.unit_cost == null || quote_item.quantity == null || quote_item.unit_discount == null)
                {
                    return(ERROR_CODE.PARAMS_ERROR);
                }
                if (string.IsNullOrEmpty(quote_item.name))
                {
                    return(ERROR_CODE.PARAMS_ERROR);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(quote_item.name))
                {
                    return(ERROR_CODE.PARAMS_ERROR);
                }
                if (quote_item.discount_percent == null && quote_item.unit_discount == null)
                {
                    return(ERROR_CODE.PARAMS_ERROR);
                }
            }

            var user = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {
                return(ERROR_CODE.USER_NOT_FIND);
            }
            quote_item.id             = _dal.GetNextIdCom();
            quote_item.tax_cate_id    = quote_item.tax_cate_id == 0 ? null : quote_item.tax_cate_id;
            quote_item.period_type_id = quote_item.period_type_id == 0 ? null : quote_item.period_type_id;
            quote_item.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            quote_item.update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            quote_item.create_user_id = user_id;
            quote_item.update_user_id = user_id;

            _dal.Insert(quote_item);
            new sys_oper_log_dal().Insert(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.QUOTE_ITEM,
                oper_object_id      = quote_item.id,// 操作对象id
                oper_type_id        = (int)OPER_LOG_TYPE.ADD,
                oper_description    = _dal.AddValue(quote_item),
                remark              = "保存报价项信息"
            });

            var oDal = new crm_opportunity_dal();
            var oppo = oDal.GetOpByItemID(quote_item.id);

            if (oppo != null && oppo.use_quote == 1)
            {
                if (quote_item.optional != 1 && quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES)
                {
                    decimal?changeRevenue = quote_item.quantity * ((quote_item.unit_price ?? 0) - (quote_item.unit_discount ?? 0));
                    decimal?changeCost    = quote_item.quantity * quote_item.unit_cost;

                    switch (quote_item.period_type_id)
                    {
                    case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME:
                        oppo.one_time_revenue += (changeRevenue ?? 0);
                        oppo.one_time_cost    += (changeCost ?? 0);
                        break;

                    case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.MONTH:
                        oppo.monthly_revenue += (changeRevenue ?? 0);
                        oppo.monthly_cost    += (changeCost ?? 0);
                        break;

                    case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER:
                        oppo.quarterly_revenue += (changeRevenue ?? 0);
                        oppo.quarterly_cost    += (changeCost ?? 0);
                        break;

                    case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR:
                        oppo.semi_annual_revenue += (changeRevenue ?? 0);
                        oppo.semi_annual_cost    += (changeCost ?? 0);
                        break;

                    case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR:
                        oppo.yearly_revenue += (changeRevenue ?? 0);
                        oppo.yearly_cost    += (changeCost ?? 0);
                        break;

                    default:
                        break;
                    }

                    // var udfDto = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.OPPORTUNITY);
                    // var udfValue =
                    OpportunityAddOrUpdateDto param = new OpportunityAddOrUpdateDto()
                    {
                        general = oppo,
                        udf     = null,
                        notify  = null
                    };
                    new OpportunityBLL().Update(param, user.id);
                }
            }
            if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT)
            {
                if (wareDic != null && wareDic.Count > 0)
                {
                    var irDal = new ivt_reserve_dal();
                    var iwDal = new ivt_warehouse_dal();
                    foreach (var thisPageWare in wareDic)
                    {
                        var thisWareHouse = iwDal.FindNoDeleteById(thisPageWare.Key);
                        if (thisWareHouse != null && thisPageWare.Value != 0)
                        {
                            var thisReserve = new ivt_reserve()
                            {
                                id             = irDal.GetNextIdCom(),
                                create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                                create_user_id = user_id,
                                update_user_id = user_id,
                                quote_item_id  = quote_item.id,
                                warehouse_id   = thisPageWare.Key,
                                quantity       = thisPageWare.Value,
                                resource_id    = thisWareHouse.resource_id,
                            };
                            irDal.Insert(thisReserve);
                            OperLogBLL.OperLogAdd <ivt_reserve>(thisReserve, thisReserve.id, user_id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "新增库存预留");
                        }
                    }
                }
            }

            if (isSaleOrder && saleOrderId != null && (quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.PRODUCT || quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.DEGRESSION || quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES))
            {
                var cccDal   = new ctt_contract_cost_dal();
                var costList = cccDal.GetListBySaleOrderId((long)saleOrderId);
                if (costList != null && costList.Count > 0)
                {
                    int  status_id    = 0;
                    long cost_code_id = (long)quote_item.object_id;
                    long?product_id   = null;
                    if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT)
                    {
                        product_id = quote_item.object_id;
                        status_id  = (int)COST_STATUS.PENDING_PURCHASE;
                        var thisProduct = new ivt_product_dal().FindNoDeleteById((long)quote_item.object_id);
                        if (thisProduct != null)
                        {
                            cost_code_id = thisProduct.cost_code_id;
                        }
                        else
                        {
                            return(ERROR_CODE.ERROR);
                        }
                        var appSet = new SysSettingBLL().GetSetById(DTO.SysSettingEnum.CTT_COST_APPROVAL_VALUE);
                        if (appSet != null && !string.IsNullOrEmpty(appSet.setting_value) && thisProduct.does_not_require_procurement == 0) // 该产品走采购流程,并且价格大于设置,则带审批
                        {
                            if (((decimal)quote_item.quantity * (decimal)quote_item.unit_price) > decimal.Parse(appSet.setting_value))      // 金额超出(待审批)
                            {
                                status_id = (int)COST_STATUS.PENDING_APPROVAL;
                            }
                        }
                    }
                    else
                    {
                        status_id = (int)COST_STATUS.PENDING_DELIVERY;
                    }
                    ctt_contract_cost cost = new ctt_contract_cost()
                    {
                        id             = _dal.GetNextIdCom(),
                        opportunity_id = costList[0].opportunity_id,
                        quote_item_id  = quote_item.id,
                        cost_code_id   = cost_code_id,
                        product_id     = product_id,
                        name           = quote_item.name,
                        description    = quote_item.description,
                        date_purchased = DateTime.Now,
                        is_billable    = 1,
                        bill_status    = 0,
                        cost_type_id   = (int)COST_TYPE.OPERATIONA,
                        status_id      = status_id,
                        quantity       = quote_item.quantity ?? 0,
                        unit_price     = (quote_item.unit_price ?? 0) - (quote_item.unit_discount ?? 0),
                        unit_cost      = quote_item.unit_cost,
                        extended_price = ((quote_item.unit_price ?? 0) - (quote_item.unit_discount ?? 0)) * quote_item.quantity,
                        create_user_id = user.id,
                        update_user_id = user.id,
                        create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        update_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                        project_id     = costList[0].project_id,
                        contract_id    = costList[0].contract_id,
                        task_id        = costList[0].task_id,
                        sub_cate_id    = costList[0].sub_cate_id,
                    };
                    cccDal.Insert(cost);
                    OperLogBLL.OperLogAdd <ctt_contract_cost>(cost, cost.id, user_id, OPER_LOG_OBJ_CATE.CONTRACT_COST, "新增成本");
                    if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT)
                    {
                        var ccBll          = new ContractCostBLL();
                        var irDal          = new ivt_reserve_dal();
                        var thisPro        = new ivt_product_dal().FindNoDeleteById((long)quote_item.object_id);
                        var thisProResList = irDal.GetListByItemId(quote_item.id);
                        if (thisProResList != null && thisProResList.Count > 0 && thisPro != null)
                        {
                            foreach (var thisProRes in thisProResList)
                            {
                                ccBll.AddCostProduct(cost.id, thisPro.id, thisProRes.warehouse_id, thisProRes.quantity, "", "", user.id);

                                irDal.SoftDelete(thisProRes, user.id);
                                OperLogBLL.OperLogDelete <ivt_reserve>(thisProRes, thisProRes.id, user.id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "删除产品预留");
                            }
                            ccBll.ChangCostStatus(cost.id, user_id);
                        }
                    }
                }
            }

            return(ERROR_CODE.SUCCESS);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取相关参数
        /// </summary>s
        protected SdkWorkEntryDto GetParam()
        {
            SdkWorkEntryDto param     = new SdkWorkEntryDto();
            var             pageEntry = AssembleModel <sdk_work_entry>();

            // 除了工时信息外,获取相关附加信息,成本信息,邮件信息

            if (!string.IsNullOrEmpty(Request.Form["ckIsBilled"]))
            {
                pageEntry.is_billable = 1;
            }
            else
            {
                pageEntry.is_billable = 0;
            }
            if (!string.IsNullOrEmpty(Request.Form["ckShowOnInv"]))
            {
                pageEntry.show_on_invoice = 1;
            }
            else
            {
                pageEntry.show_on_invoice = 0;
            }
            var status_id = Request.Form["status_id"];

            if (!string.IsNullOrEmpty(status_id))
            {
                param.status_id = int.Parse(status_id);
            }
            var labourDate = Request.Form["LabourDate"];
            var startTime  = Request.Form["startTime"];
            var endTime    = Request.Form["endTime"];

            if (!string.IsNullOrEmpty(labourDate) && !string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime))
            {
                var startDate = DateTime.Parse(labourDate + " " + startTime);
                var endDate   = DateTime.Parse(labourDate + " " + endTime);
                pageEntry.start_time = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate);
                pageEntry.end_time   = Tools.Date.DateHelper.ToUniversalTimeStamp(endDate);
            }
            pageEntry.hours_billed = (pageEntry.hours_worked ?? 0) + pageEntry.offset_hours;
            if (!string.IsNullOrEmpty(Request.Form["ckAppThisResou"]))
            {
                param.isAppthisResoule = true;
            }
            if (!string.IsNullOrEmpty(Request.Form["ckAppOtherResou"]))
            {
                param.isAppOtherResoule = true;
            }
            if (!string.IsNullOrEmpty(Request.Form["CkNoteCreat"]))
            {
                param.isAppOtherNote = true;
            }
            if (!string.IsNullOrEmpty(Request.Form["ckBillToAccount"]))
            {
                param.billToAccount = true;
            }
            param.ticketId = thisTicket.id;
            var charge_cost_code_id = Request.Form["charge_cost_code_id"];
            var quantity            = Request.Form["quantity"];

            if (!string.IsNullOrEmpty(charge_cost_code_id) && !string.IsNullOrEmpty(quantity))
            {
                var charge = new ctt_contract_cost()
                {
                    cost_code_id = long.Parse(charge_cost_code_id),
                    description  = Request.Form["description"],
                    quantity     = decimal.Parse(quantity),
                };
                var unit_price = Request.Form["unit_price"];
                if (!string.IsNullOrEmpty(unit_price))
                {
                    charge.unit_price = decimal.Parse(unit_price);
                }
                param.thisCost = charge;
            }
            pageEntry.task_id = thisTicket.id;
            if (isAdd)
            {
                var parentType  = Request.QueryString["AddType"];
                var parentobjId = Request.QueryString["parentObjId"];
                if (!string.IsNullOrEmpty(parentType) && !string.IsNullOrEmpty(parentobjId))
                {
                    if (parentType == "att")
                    {
                        pageEntry.parent_attachment_id = int.Parse(parentobjId);
                    }
                    else if (parentType == "note")
                    {
                        pageEntry.parent_note_id = int.Parse(parentobjId);
                    }
                    else if (parentType == "entry")
                    {
                        pageEntry.parent_id = int.Parse(parentobjId);
                    }
                }
                if (!string.IsNullOrEmpty(Request.Form["resource_id"]))
                {
                    pageEntry.resource_id = LoginUserId;
                }
                else
                {
                    pageEntry.resource_id = long.Parse(Request.Form["resource_id"]);
                }
                param.workEntry = pageEntry;
            }
            else
            {
                if (isAllowAgentRes)
                {
                    //ticketLabour.resource_id = pageEntry.resource_id;
                    ticketLabour.contract_id = pageEntry.contract_id;
                }
                ticketLabour.service_id      = pageEntry.service_id;
                ticketLabour.cost_code_id    = pageEntry.cost_code_id;
                ticketLabour.is_billable     = pageEntry.is_billable;
                ticketLabour.show_on_invoice = pageEntry.show_on_invoice;
                ticketLabour.role_id         = pageEntry.role_id;
                ticketLabour.start_time      = pageEntry.start_time;
                ticketLabour.end_time        = pageEntry.end_time;
                ticketLabour.hours_worked    = pageEntry.hours_worked;
                ticketLabour.offset_hours    = pageEntry.offset_hours;
                ticketLabour.hours_billed    = pageEntry.hours_billed;
                ticketLabour.summary_notes   = pageEntry.summary_notes;
                ticketLabour.internal_notes  = pageEntry.internal_notes;

                param.workEntry = ticketLabour;
            }


            return(param);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 新增预付
        /// </summary>
        /// <param name="dto"></param>
        /// <param name="userId"></param>
        public bool NewPurchase(ContractBlockAddDto dto, long userId)
        {
            ctt_contract_cost_dal costDal = new ctt_contract_cost_dal();
            string blkName = "";

            if (dto.type == 1)
            {
                blkName = "时间";
            }
            if (dto.type == 2)
            {
                blkName = "费用";
            }
            if (dto.type == 3)
            {
                blkName = "事件";
            }

            if (dto.isMonthly)   // 每月计费
            {
                // 检查必填项
                if (dto.type == 2)
                {
                    if (dto.amount == null)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (dto.hours == null || dto.hourlyRate == null)
                    {
                        return(false);
                    }
                }
                if (dto.endDate == null && dto.purchaseNum == null)
                {
                    return(false);
                }
                // 检查起止日期和计费周期
                if (dto.endDate != null && (DateTime)dto.endDate < dto.startDate)
                {
                    return(false);
                }
                if (dto.endDate == null && dto.purchaseNum <= 0)
                {
                    return(false);
                }

                DateTime dtBlockStart = dto.startDate;      // 一个预付周期开始时间
                DateTime dtBlockEnd   = DateTime.MinValue;  // 所有预付周期结束时间
                if (dto.endDate != null)
                {
                    dtBlockEnd = (DateTime)dto.endDate;
                }
                int blockNums = 0;  // 已处理新增预付时间
                while (true)
                {
                    if (dto.endDate != null)    // 按最后一个周期的结束时间判断
                    {
                        if (dtBlockStart > dtBlockEnd)
                        {
                            break;
                        }
                    }
                    else    // 按周期个数判断
                    {
                        if (blockNums >= (int)dto.purchaseNum)
                        {
                            break;
                        }
                    }

                    // 新增预付
                    ctt_contract_block block = new ctt_contract_block();
                    block.id             = dal.GetNextIdCom();
                    block.contract_id    = dto.contractId;
                    block.is_billed      = 0;
                    block.is_paid        = 0;
                    block.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    block.create_user_id = userId;
                    block.update_user_id = userId;
                    block.update_time    = block.create_time;

                    block.start_date = dtBlockStart;
                    block.end_date   = dtBlockStart.AddMonths(1).AddDays(-1);
                    if (dto.type == 1 || dto.type == 3)
                    {
                        block.quantity = ((decimal)dto.hours) * 10000 / 10000;
                        block.rate     = ((decimal)dto.hourlyRate) * 100 / 100;
                    }
                    else if (dto.type == 2)
                    {
                        block.quantity = 1;
                        block.rate     = (decimal)dto.amount;
                    }
                    if ((bool)dto.firstPart && blockNums == 0)                                                   // 首月部分的处理
                    {
                        block.end_date = new DateTime(dtBlockStart.Year, dtBlockStart.Month + 1, 1).AddDays(-1); // 结束日期为开始日期同月份的最后一天

                        /* 修改:所有周期的计费按一整周期算 */
                        //if (dto.type != 2)
                        //    block.quantity = (decimal)((int)(((decimal)(block.end_date.Day - block.start_date.Day + 1) / block.end_date.Day) * ((decimal)dto.hours) * 10000)) / 10000;    // 预付数量按照天数比例计算
                        //else
                        //    block.rate = (decimal)((int)(((decimal)(block.end_date.Day - block.start_date.Day + 1) / block.end_date.Day) * block.rate * 10000)) / 10000;
                    }
                    if (dto.endDate != null && ((DateTime)dto.endDate) < block.end_date)    // 设置了结束时间的处理
                    {
                        block.end_date = (DateTime)dto.endDate;

                        /* 修改:所有周期的计费按一整周期算 */
                        //if (dto.type != 2)
                        //    block.quantity = ((decimal)((block.end_date - block.start_date).Days + 1)
                        //    / DateTime.DaysInMonth(block.start_date.Year, block.start_date.Month))
                        //    * ((decimal)dto.hours) * 10000 / 10000;    // 预付数量按照天数比例计算
                        //else
                        //    block.rate = (decimal)((int)(((decimal)((block.end_date - block.start_date).Days + 1)
                        //    / DateTime.DaysInMonth(block.start_date.Year, block.start_date.Month)) * block.rate * 10000)) / 10000;
                    }
                    dtBlockStart = block.end_date.AddDays(1); // 下一周期的开始日期
                    ++blockNums;                              // 已处理周期数加1

                    // 可以延期
                    if (dto.delayDays != null && dto.delayDays > 0)
                    {
                        block.end_date = block.end_date.AddDays((int)dto.delayDays);
                    }

                    block.status_id       = (sbyte)(dto.status ? 1 : 0);
                    block.date_purchased  = block.start_date;
                    block.payment_number  = dto.paymentNum;
                    block.payment_type_id = dto.paymentType;
                    block.description     = dto.note;

                    dal.Insert(block);
                    OperLogBLL.OperLogAdd <ctt_contract_block>(block, block.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_BLOCK, $"新增合同预付{blkName}");


                    // 新增合同成本
                    ctt_contract_cost cost = new ctt_contract_cost();
                    cost.id                = costDal.GetNextIdCom();
                    cost.create_time       = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    cost.create_user_id    = userId;
                    cost.update_time       = cost.create_time;
                    cost.update_user_id    = userId;
                    cost.contract_block_id = block.id;
                    cost.contract_id       = dto.contractId;
                    List <d_cost_code> costCode;
                    if (dto.type == 1)
                    {
                        costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.BLOCK_PURCHASE);
                    }
                    else if (dto.type == 2)
                    {
                        costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.RETAINER_PURCHASE);
                    }
                    else
                    {
                        costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.TICKET_PURCHASE);
                    }
                    if (costCode == null || costCode.Count == 0)
                    {
                        throw new Exception("字典项缺失");
                    }
                    cost.cost_code_id      = costCode[0].id;
                    cost.name              = $"预付{blkName}[{block.start_date.ToShortDateString()}-{block.end_date.ToShortDateString()}]";
                    cost.date_purchased    = block.date_purchased;
                    cost.cost_type_id      = (int)COST_TYPE.OPERATIONA;
                    cost.status_id         = (int)COST_STATUS.UNDETERMINED;
                    cost.bill_status       = 0;
                    cost.is_billable       = 1;
                    cost.quantity          = block.quantity;
                    cost.unit_cost         = 0;
                    cost.unit_price        = block.rate;
                    cost.contract_block_id = block.id;
                    cost.extended_price    = (cost.quantity * cost.unit_price) * 100 / 100;
                    if (dto.type == 1)
                    {
                        cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_TIME;
                    }
                    else if (dto.type == 2)
                    {
                        cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_COST;
                    }
                    else if (dto.type == 3)
                    {
                        cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.EVENTS;
                    }

                    costDal.Insert(cost);
                    OperLogBLL.OperLogAdd <ctt_contract_cost>(cost, cost.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_COST, "新增合同成本");
                }
                return(true);
            }
            else    // 一次计费
            {
                if (dto.type == 2)
                {
                    if (dto.amount == null)
                    {
                        return(false);
                    }
                }
                else
                {
                    if (dto.hours == null || dto.hourlyRate == null)
                    {
                        return(false);
                    }
                }
                if (dto.endDate == null) // 检查必填项
                {
                    return(false);
                }
                if ((DateTime)dto.endDate < dto.startDate)  // 检查起止日期和计费周期
                {
                    return(false);
                }

                // 新增预付
                ctt_contract_block block = new ctt_contract_block();
                block.id             = dal.GetNextIdCom();
                block.contract_id    = dto.contractId;
                block.is_billed      = 0;
                block.is_paid        = 0;
                block.create_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                block.create_user_id = userId;
                block.update_user_id = userId;
                block.update_time    = block.create_time;
                block.start_date     = dto.startDate;
                block.end_date       = (DateTime)dto.endDate;
                if (dto.type == 1 || dto.type == 3)
                {
                    block.quantity = ((decimal)dto.hours) * 10000 / 10000;
                    block.rate     = ((decimal)dto.hourlyRate) * 100 / 100;
                }
                else if (dto.type == 2)
                {
                    block.quantity = 1;
                    block.rate     = (decimal)dto.amount;
                }
                block.status_id       = (sbyte)(dto.status ? 1 : 0);
                block.date_purchased  = dto.datePurchased;
                block.payment_number  = dto.paymentNum;
                block.payment_type_id = dto.paymentType;
                block.description     = dto.note;

                dal.Insert(block);
                OperLogBLL.OperLogAdd <ctt_contract_block>(block, block.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_BLOCK, $"新增合同预付{blkName}");


                // 新增合同成本
                ctt_contract_cost cost = new ctt_contract_cost();
                cost.id                = costDal.GetNextIdCom();
                cost.create_time       = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                cost.create_user_id    = userId;
                cost.update_time       = cost.create_time;
                cost.update_user_id    = userId;
                cost.contract_block_id = block.id;
                cost.contract_id       = dto.contractId;
                List <d_cost_code> costCode;
                if (dto.type == 1)
                {
                    costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.BLOCK_PURCHASE);
                }
                else if (dto.type == 2)
                {
                    costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.RETAINER_PURCHASE);
                }
                else
                {
                    costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.TICKET_PURCHASE);
                }
                if (costCode == null || costCode.Count == 0)
                {
                    throw new Exception("字典项缺失");
                }
                cost.cost_code_id      = costCode[0].id;
                cost.name              = $"预付{blkName}[{block.start_date.ToShortDateString()}-{block.end_date.ToShortDateString()}]";
                cost.date_purchased    = block.date_purchased;
                cost.cost_type_id      = (int)COST_TYPE.OPERATIONA;
                cost.status_id         = (int)COST_STATUS.UNDETERMINED;
                cost.bill_status       = 0;
                cost.is_billable       = 1;
                cost.quantity          = block.quantity;
                cost.unit_cost         = 0;
                cost.unit_price        = block.rate;
                cost.contract_block_id = block.id;
                cost.extended_price    = (cost.quantity * cost.unit_price) * 100 / 100;
                if (dto.type == 1)
                {
                    cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_TIME;
                }
                else if (dto.type == 2)
                {
                    cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_COST;
                }
                else if (dto.type == 3)
                {
                    cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.EVENTS;
                }

                costDal.Insert(cost);
                OperLogBLL.OperLogAdd <ctt_contract_cost>(cost, cost.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_COST, "新增合同成本");

                return(true);
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var cid        = Request.QueryString["contract_id"];
                var project_id = Request.QueryString["project_id"];
                var ccid       = Request.QueryString["cost_id"];
                if (!string.IsNullOrEmpty(cid))
                {
                    contract = new ctt_contract_dal().FindNoDeleteById(long.Parse(cid));
                }
                if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(project_id));
                }

                conCost = new ctt_contract_cost_dal().FindNoDeleteById(long.Parse(ccid));
                if (conCost != null)
                {
                    if (conCost.product_id != null)
                    {
                        product = new ivt_product_dal().FindNoDeleteById((long)conCost.product_id);
                    }
                    else
                    {
                        product = new ivt_product_dal().GetDefaultProduct();
                    }
                    if (conCost.quantity != null)
                    {
                        var thisSubList = new crm_installed_product_dal().GetInsProByCostId(conCost.id, (long)conCost.quantity);
                        int num         = (int)conCost.quantity;
                        if (thisSubList != null && thisSubList.Count > 0)
                        {
                            num          = (int)conCost.quantity - thisSubList.Count;
                            exisCostList = new ctt_contract_cost_dal().GetItemByNum(conCost.id, thisSubList.Count);
                        }
                        if (num > 0)
                        {
                            costList = new ctt_contract_cost_dal().GetItemByNum(conCost.id, num);
                        }
                    }
                    if (costList != null && costList.Count > 0)
                    {
                    }
                }
                if (conCost == null)
                {
                    Response.Write("<script>alert('未查询到成本');window.close();</script>");
                    return;
                }
                if (conCost.create_ci == 1)
                {
                    Response.Write("<script>alert('成本已创建配置项!');window.close();</script>");
                    return;
                }
            }
            catch (Exception)
            {
                Response.End();
            }
        }