Ejemplo n.º 1
0
        public crm_subscription GetParam()
        {
            var id = subscription == null ? 0 : subscription.id;

            subscription = AssembleModel <crm_subscription>();
            //subscription.status_id = isActive.Checked ? 1 : 0;/
            if (!isAdd)
            {
                subscription.id = id;
            }
            return(subscription);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 撤销订阅审批
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ERROR_CODE Revoke_Subscriptions(long user_id, string ids, out string re)
        {
            re = string.Empty;
            StringBuilder returnvalue = new StringBuilder();
            var           user        = UserInfoBLL.GetUserInfo(user_id);

            if (user == null)
            {   // 查询不到用户,用户丢失
                return(ERROR_CODE.USER_NOT_FIND);
            }
            crm_account_deduction       cad     = new crm_account_deduction();
            crm_subscription            cs      = new crm_subscription();        //订阅表
            crm_subscription_period     csp     = new crm_subscription_period(); //订阅周期表
            crm_subscription_dal        cs_dal  = new crm_subscription_dal();
            crm_subscription_period_dal csp_dal = new crm_subscription_period_dal();

            if (!string.IsNullOrEmpty(ids))
            {
                var idList = ids.Split(',');
                foreach (var id in idList)
                {
                    var oldcad = cad = GetAccountDed(long.Parse(id));
                    if (cad.invoice_id != null)
                    {
                        var ci = new ctt_invoice_dal().FindNoDeleteById((long)cad.invoice_id);
                        if (ci.is_voided != 1)
                        {
                            returnvalue.Append(id + "条目已经生成发票(发票ID:" + cad.invoice_id + "),请先作废该发票\n");
                        }
                    }
                    else
                    {
                        cad.delete_time    = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                        cad.delete_user_id = user.id;
                        // 插入日志
                        var add1_log = new sys_oper_log()
                        {
                            user_cate           = "用户",
                            user_id             = (int)user.id,
                            name                = user.name,
                            phone               = user.mobile == null ? "" : user.mobile,
                            oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                            oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACCOUNT_DEDUCTION,
                            oper_object_id      = cad.id,// 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.DELETE,
                            oper_description    = cad_dal.CompareValue(oldcad, cad),
                            remark              = "删除审批并提交"
                        };                                       // 创建日志
                        new sys_oper_log_dal().Insert(add1_log); // 插入日志
                        if (!cad_dal.Update(cad))
                        {
                            return(ERROR_CODE.ERROR);
                        }
                        else
                        {
                        }
                    }
                    //订阅
                    if (cad.object_id != null)
                    {
                        var oldcsp = csp = csp_dal.FindSignleBySql <crm_subscription_period>($"select * from crm_subscription_period where id={cad.object_id}");
                        cs = cs_dal.FindNoDeleteById(csp.subscription_id);
                        csp.approve_and_post_user_id = null;
                        csp.approve_and_post_date    = null;
                        csp.period_price             = cs.period_price;
                        var add_log = new sys_oper_log()
                        {
                            user_cate           = "用户",
                            user_id             = (int)user.id,
                            name                = user.name,
                            phone               = user.mobile == null ? "" : user.mobile,
                            oper_time           = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now),
                            oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SUBSCRIPTION_PERIOD, //订阅周期
                            oper_object_id      = csp.id,                                     // 操作对象id
                            oper_type_id        = (int)OPER_LOG_TYPE.UPDATE,
                            oper_description    = cad_dal.CompareValue(oldcsp, csp),
                            remark              = "修改订阅周期"
                        };                                      // 创建日志
                        new sys_oper_log_dal().Insert(add_log); // 插入日志

                        if (!csp_dal.Update(csp))
                        {
                            return(ERROR_CODE.ERROR);
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(returnvalue.ToString()))
            {
                re = returnvalue.ToString();
                return(ERROR_CODE.EXIST);
            }
            return(ERROR_CODE.SUCCESS);
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                #region  拉框配数据源
                period_type_id.DataTextField  = "show";
                period_type_id.DataValueField = "val";
                period_type_id.DataSource     = dic.FirstOrDefault(_ => _.Key == "period_type").Value;
                period_type_id.DataBind();
                period_type_id.Items.Insert(0, new ListItem()
                {
                    Value = "0", Text = "   ", Selected = true
                });
                #endregion

                var iProduct_id = Request.QueryString["insProId"];
                if (!string.IsNullOrEmpty(iProduct_id))
                {
                    iProduct = new crm_installed_product_dal().GetInstalledProduct(long.Parse(iProduct_id));
                }

                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    subscription = new crm_subscription_dal().GetSubscription(long.Parse(id));
                    iProduct     = new crm_installed_product_dal().GetInstalledProduct(subscription.installed_product_id);
                    period_type_id.SelectedValue = subscription.period_type_id.ToString();
                    // period_type_id.Enabled = false;
                    isAdd         = false;
                    subPeriodList = new crm_subscription_period_dal().GetSubPeriodByWhere($" and subscription_id = {subscription.id}");
                }
                if (iProduct == null)
                {
                    Response.End();
                }



                if (!IsPostBack)
                {
                    if (subscription != null)
                    {
                        if (subscription.status_id != 1)
                        {
                            status_id.SelectedValue = subscription.status_id.ToString();
                        }
                        else
                        {
                            status_id.SelectedValue = "1";
                        }
                    }
                    else
                    {
                        status_id.SelectedValue = "1";
                    }
                }
            }
            catch (Exception)
            {
                Response.End();
            }
        }