コード例 #1
0
ファイル: admin_ajax.ashx.cs プロジェクト: eryueren/OScms
        private void edit_category(HttpContext context)
        {
            //取得管理员登录信息
            Model.managers.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
            if (adminInfo == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}");
                return;
            }

            int category1 = OSRequest.GetFormInt("Category1");
            int category2 = OSRequest.GetFormInt("Category2");

            if (category1 == category2)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"移动目录跟目的目录不能相同!\"}");
                return;
            }

            BLL.contents.article_category   bll   = new BLL.contents.article_category();
            Model.contents.article_category model = bll.GetModel(category2);

            if (model.class_list.IndexOf("," + category1 + ",") > 0)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"父级本不能向其子级转移!\"}");
                return;
            }

            if (bll.GetModel(category1).parent_id == category2)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"移动目录已经在目的目录里!\"}");
                return;
            }

            DataTable dt = bll.GetList(0, "class_list like '%," + category1 + ",%'", "class_layer asc").Tables[0];

            if (dt.Rows != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int    id              = Convert.ToInt32(dt.Rows[i]["id"]);
                    string class_list      = dt.Rows[i]["class_list"].ToString();
                    int    new_channel_id  = model.channel_id;
                    string new_class_list  = model.class_list + class_list.Substring(class_list.IndexOf("," + category1 + ",")).TrimStart(',');
                    string new_class_layer = new_class_list.Trim(',').Split(',').Length.ToString();
                    if (i == 0)
                    {
                        bll.UpdateField(id, "channel_id=" + new_channel_id + ", parent_id=" + category2 + ", class_list='" + new_class_list + "',class_layer=" + new_class_layer);
                    }
                    else
                    {
                        bll.UpdateField(id, "channel_id=" + new_channel_id + ", class_list='" + new_class_list + "',class_layer=" + new_class_layer);
                    }
                }
            }

            new BLL.managers.manager_log().Add(adminInfo.id, adminInfo.user_name, OSEnums.ActionEnum.Edit.ToString(), "移动栏目:" + bll.GetModel(category1).title); //记录日志
            context.Response.Write("{\"status\": 1, \"msg\": \"栏目转移成功!\"}");
        }
コード例 #2
0
        //private void edit_order_status(HttpContext context)
        //{
        //    //取得管理员登录信息
        //    Model.sys_manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
        //    if (adminInfo == null)
        //    {
        //        context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}");
        //        return;
        //    }
        //    //取得订单配置信息
        //    Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig();

        //    string order_no = RequestHelper.GetString("order_no");
        //    string edit_type = RequestHelper.GetString("edit_type");
        //    if (order_no == "")
        //    {
        //        context.Response.Write("{\"status\": 0, \"msg\": \"传输参数有误,无法获取订单号!\"}");
        //        return;
        //    }
        //    if (edit_type == "")
        //    {
        //        context.Response.Write("{\"status\": 0, \"msg\": \"无法获取修改订单类型!\"}");
        //        return;
        //    }

        //    BLL.user_order bll = new BLL.user_order();
        //    Model.user_order model = null;
        //    List<Model.user_order> list = bll.GetModelList(string.Format(" order_no_child={0} ", order_no));
        //    if (list.Count > 0)
        //    {
        //        model = list[0];
        //    }
        //    if (model == null)
        //    {
        //        context.Response.Write("{\"status\": 0, \"msg\": \"不存在或已被删除!\"}");
        //        return;
        //    }
        //    switch (edit_type.ToLower())
        //    {
        //        case "edit_order_remark": //修改订单备注=================================
        //            string remark = RequestHelper.GetFormString("remark");
        //            if (remark == "")
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"请填写订单备注内容!\"}");
        //                return;
        //            }
        //            model.remark = remark;
        //            if (!bll.Update(model))
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"修改订单备注失败!\"}");
        //                return;
        //            }
        //            new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, Common.EnumCollection.ActionEnum.Modify.ToString(), "修改订单备注,订单号:" + model.order_no_child); //记录日志
        //            context.Response.Write("{\"status\": 1, \"msg\": \"修改订单备注成功!\"}");
        //            break;
        //        case "order_complete": //完成订单=========================================
        //            if (model.status >= (int)Common.EnumCollection.OrderStatus.已完成)
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"订单已经完成,不能重复处理!\"}");
        //                return;
        //            }
        //            model.status = (int)Common.EnumCollection.OrderStatus.已完成;
        //            model.complete_time = DateTime.Now;
        //            if (!bll.Update(model))
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"确认订单完成失败!\"}");
        //                return;
        //            }
        //            //给会员增加积分检查升级
        //            if (model.user_id > 0 && model.point > 0)
        //            {
        //                new BLL.user_pointlist().Add(model.user_id, model.point, ((int)Common.EnumCollection.UserPointType.购物消费).ToString(), "购物消费获得积分,订单号:" + model.order_no_child);
        //            }
        //            new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, Common.EnumCollection.ActionEnum.Confirm.ToString(), "确认交易完成订单号:" + model.order_no); //记录日志
        //            #region 发送短信或邮件=========================
        //            //if (orderConfig.completemsg > 0)
        //            //{
        //            //    switch (orderConfig.completemsg)
        //            //    {
        //            //        case 1: //短信通知
        //            //            if (string.IsNullOrEmpty(model.mobile))
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}");
        //            //                return;
        //            //            }
        //            //            Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.completecallindex); //取得短信内容
        //            //            if (smsModel == null)
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}");
        //            //                return;
        //            //            }
        //            //            //替换标签
        //            //            string msgContent = smsModel.content;
        //            //            msgContent = msgContent.Replace("{webname}", siteConfig.webname);
        //            //            msgContent = msgContent.Replace("{username}", model.user_name);
        //            //            msgContent = msgContent.Replace("{orderno}", model.order_no);
        //            //            msgContent = msgContent.Replace("{amount}", model.order_amount.ToString());
        //            //            //发送短信
        //            //            string tipMsg = string.Empty;
        //            //            bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
        //            //            if (!sendStatus)
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}");
        //            //                return;
        //            //            }
        //            //            break;
        //            //        case 2: //邮件通知
        //            //            //取得用户的邮箱地址
        //            //            if (string.IsNullOrEmpty(model.email))
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户没有填写邮箱地址。\"}");
        //            //                return;
        //            //            }
        //            //            //取得邮件模板内容
        //            //            Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.completecallindex);
        //            //            if (mailModel == null)
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}");
        //            //                return;
        //            //            }
        //            //            //替换标签
        //            //            string mailTitle = mailModel.maill_title;
        //            //            mailTitle = mailTitle.Replace("{username}", model.user_name);
        //            //            string mailContent = mailModel.content;
        //            //            mailContent = mailContent.Replace("{webname}", siteConfig.webname);
        //            //            mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
        //            //            mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
        //            //            mailContent = mailContent.Replace("{username}", model.user_name);
        //            //            mailContent = mailContent.Replace("{orderno}", model.order_no);
        //            //            mailContent = mailContent.Replace("{amount}", model.order_amount.ToString());
        //            //            //发送邮件
        //            //            DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
        //            //                siteConfig.emailfrom, model.email, mailTitle, mailContent);
        //            //            break;
        //            //    }
        //            //}
        //            #endregion
        //            context.Response.Write("{\"status\": 1, \"msg\": \"确认订单完成成功!\"}");
        //            break;
        //        case "order_express": //确认发货
        //            if (model.status > (int)Common.EnumCollection.OrderStatus.已发货 || model.express_status == (int)Common.EnumCollection.OrderStatus.已发货)
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"订单已完成或已发货,不能重复处理!\"}");
        //                return;
        //            }
        //            int express_id = RequestHelper.GetFormInt("express_id");
        //            string express_no = RequestHelper.GetFormString("express_no");
        //            //if (express_id == 0)
        //            //{
        //            //    context.Response.Write("{\"status\": 0, \"msg\": \"请选择配送方式!\"}");
        //            //    return;
        //            //}
        //            model.express_id = express_id;
        //            model.express_no = express_no;
        //            model.express_status = (int)Common.EnumCollection.OrderExpressStatus.已发货;
        //            model.express_time = DateTime.Now;
        //            model.status = (int)Common.EnumCollection.OrderStatus.已发货;
        //            if (!bll.Update(model))
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"订单发货失败!\"}");
        //                return;
        //            }
        //            new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, Common.EnumCollection.ActionEnum.Confirm.ToString(), "确认发货订单号:" + model.order_no_child); //记录日志
        //            #region 发送短信或邮件============================
        //            //if (orderConfig.expressmsg > 0)
        //            //{
        //            //    switch (orderConfig.expressmsg)
        //            //    {
        //            //        case 1: //短信通知
        //            //            if (string.IsNullOrEmpty(model.mobile))
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}");
        //            //                return;
        //            //            }
        //            //            Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.expresscallindex); //取得短信内容
        //            //            if (smsModel == null)
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}");
        //            //                return;
        //            //            }
        //            //            //替换标签
        //            //            string msgContent = smsModel.content;
        //            //            msgContent = msgContent.Replace("{webname}", siteConfig.webname);
        //            //            msgContent = msgContent.Replace("{username}", model.user_name);
        //            //            msgContent = msgContent.Replace("{orderno}", model.order_no);
        //            //            msgContent = msgContent.Replace("{amount}", model.order_amount.ToString());
        //            //            //发送短信
        //            //            string tipMsg = string.Empty;
        //            //            bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
        //            //            if (!sendStatus)
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}");
        //            //                return;
        //            //            }
        //            //            break;
        //            //        case 2: //邮件通知
        //            //            //取得用户的邮箱地址
        //            //            if (string.IsNullOrEmpty(model.email))
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户没有填写邮箱地址。\"}");
        //            //                return;
        //            //            }
        //            //            //取得邮件模板内容
        //            //            Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.expresscallindex);
        //            //            if (mailModel == null)
        //            //            {
        //            //                context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}");
        //            //                return;
        //            //            }
        //            //            //替换标签
        //            //            string mailTitle = mailModel.maill_title;
        //            //            mailTitle = mailTitle.Replace("{username}", model.user_name);
        //            //            string mailContent = mailModel.content;
        //            //            mailContent = mailContent.Replace("{webname}", siteConfig.webname);
        //            //            mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
        //            //            mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
        //            //            mailContent = mailContent.Replace("{username}", model.user_name);
        //            //            mailContent = mailContent.Replace("{orderno}", model.order_no);
        //            //            mailContent = mailContent.Replace("{amount}", model.order_amount.ToString());
        //            //            //发送邮件
        //            //            DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailssl, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
        //            //                siteConfig.emailfrom, model.email, mailTitle, mailContent);
        //            //            break;
        //            //    }
        //            //}
        //            #endregion
        //            context.Response.Write("{\"status\": 1, \"msg\": \"订单发货成功!\"}");
        //            break;
        //        case "order_cancel": //取消订单==========================================
        //            if (model.status == (int)Common.EnumCollection.OrderStatus.已完成)
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"订单已经完成,不能取消订单!\"}");
        //                return;
        //            }
        //            if (model.status == (int)Common.EnumCollection.OrderStatus.已发货)
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"订单已发货,不能取消订单!\"}");
        //                return;
        //            }
        //            if (model.status == (int)Common.EnumCollection.OrderStatus.待发货)
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"订单已支付,不能取消订单!\"}");
        //                return;
        //            }
        //            model.status = (int)Common.EnumCollection.OrderStatus.已取消;
        //            if (!bll.Update(model))
        //            {
        //                context.Response.Write("{\"status\": 0, \"msg\": \"取消订单失败!\"}");
        //                return;
        //            }
        //            //##??
        //            int check_revert1 = RequestHelper.GetFormInt("check_revert");
        //            if (check_revert1 == 1)
        //            {
        //                //如果存在积分换购则返还会员积分
        //                if (model.user_id > 0 && model.use_point < 0)
        //                {
        //                    new BLL.user_pointlist().Add(model.user_id, model.use_point, ((int)Common.EnumCollection.UserPointType.订单取消返还).ToString(), "取消订单返还积分,订单号:" + model.order_no_child);
        //                }
        //                //如果已支付则退还金额到会员账户
        //                if (model.user_id > 0 && model.payment_status == (int)Common.EnumCollection.OrderPaymentStatus.已支付 && model.order_amount > 0)
        //                {
        //                    //用户暂无余额不考虑
        //                    //new BLL.user_amount_log().Add(model.user_id, model.user_name, model.order_amount, "取消订单退还金额,订单号:" + model.order_no);
        //                }
        //            }
        //            new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, Common.EnumCollection.ActionEnum.Cancel.ToString(), "取消订单号:" + model.order_no); //记录日志
        //            context.Response.Write("{\"status\": 1, \"msg\": \"取消订单成功!\"}");
        //            break;

        //    }

        //}
        #endregion


        #region 判断是否登陆以及是否开启静态====================
        private int get_builder_status()
        {
            //取得管理员登录信息
            Model.sys_manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
            if (adminInfo == null)
            {
                return(-1);
            }
            else if (!new BLL.manager_role().Exists(adminInfo.role_id, "sys_builder_html", EnumCollection.ActionEnum.Build.ToString()))
            {
                return(-2);
            }
            else if (siteConfig.staticstatus != 2)
            {
                return(-3);
            }
            else
            {
                return(1);
            }
        }
コード例 #3
0
ファイル: admin_ajax.ashx.cs プロジェクト: eryueren/OScms
        private void delete_category(HttpContext context)
        {
            //取得管理员登录信息
            Model.managers.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
            if (adminInfo == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}");
                return;
            }
            int category_id = OSRequest.GetQueryInt("category_id");

            if (category_id == 0)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"参数错误!\"}");
                return;
            }
            BLL.contents.article_category bll = new BLL.contents.article_category();
            new BLL.managers.manager_log().Add(adminInfo.id, adminInfo.user_name, OSEnums.ActionEnum.Edit.ToString(), "删除栏目:" + bll.GetTitle(category_id)); //记录日志
            bll.Delete(category_id);
            context.Response.Write("{\"status\": 1, \"msg\": \"栏目删除成功!\"}");
        }
コード例 #4
0
ファイル: admin_ajax.ashx.cs プロジェクト: eryueren/OScms
 private int GetIsLoginAndIsStaticstatus()
 {
     Model.configs.siteconfig siteConfig = new BLL.configs.siteconfig().loadConfig();
     //取得管理员登录信息
     Model.managers.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
     if (adminInfo == null)
     {
         return(-1);
     }
     else if (!new BLL.managers.manager_role().Exists(adminInfo.role_id, "app_builder_html", OSEnums.ActionEnum.Build.ToString()))
     {
         return(-2);
     }
     else if (siteConfig.staticstatus != 2)
     {
         return(-3);
     }
     else
     {
         return(1);
     }
 }
コード例 #5
0
        private void edit_order_status(HttpContext context)
        {
            //取得管理员登录信息
            Model.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
            if (adminInfo == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}");
                return;
            }
            //取得站点配置信息
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
            //取得订单配置信息
            Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig();

            string order_no = MXRequest.GetString("order_no");
            string edit_type = MXRequest.GetString("edit_type");
            if (order_no == "")
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"传输参数有误,无法获取订单号!\"}");
                return;
            }
            if (edit_type == "")
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"无法获取修改订单类型!\"}");
                return;
            }

            BLL.orders bll = new BLL.orders();
            Model.orders model = bll.GetModel(order_no);
            if (model == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"订单号不存在或已被删除!\"}");
                return;
            }
            switch (edit_type.ToLower())
            {
                case "order_confirm": //确认订单
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认订单的权限!\"}");
                        return;
                    }
                    if (model.status > 1)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能重复处理!\"}");
                        return;
                    }
                    model.status = 2;
                    model.confirm_time = DateTime.Now;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单确认失败!\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认订单号:" + model.order_no); //记录日志
                    #region 发送短信或邮件
                    if (orderConfig.confirmmsg > 0)
                    {
                        switch (orderConfig.confirmmsg)
                        {
                            case 1: //短信通知
                                if (string.IsNullOrEmpty(model.mobile))
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}");
                                    return;
                                }
                                Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.confirmcallindex); //取得短信内容
                                if (smsModel == null)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}");
                                    return;
                                }
                                //替换标签
                                string msgContent = smsModel.content;
                                msgContent = msgContent.Replace("{webname}", siteConfig.webname);
                                msgContent = msgContent.Replace("{username}", model.user_name);
                                msgContent = msgContent.Replace("{orderno}", model.order_no);
                                msgContent = msgContent.Replace("{amount}", model.order_amount.ToString());
                                //发送短信
                                string tipMsg = string.Empty;
                                bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
                                if (!sendStatus)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}");
                                    return;
                                }
                                break;
                            case 2: //邮件通知
                                //取得用户的邮箱地址
                                if (model.user_id > 0)
                                {
                                    Model.users userModel = new BLL.users().GetModel(model.user_id);
                                    if (userModel == null || string.IsNullOrEmpty(userModel.email))
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}");
                                        return;
                                    }
                                    //取得邮件模板内容
                                    Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.confirmcallindex);
                                    if (mailModel == null)
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}");
                                        return;
                                    }
                                    //替换标签
                                    string mailTitle = mailModel.maill_title;
                                    mailTitle = mailTitle.Replace("{username}", model.user_name);
                                    string mailContent = mailModel.content;
                                    mailContent = mailContent.Replace("{webname}", siteConfig.webname);
                                    mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
                                    mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
                                    mailContent = mailContent.Replace("{username}", model.user_name);
                                    mailContent = mailContent.Replace("{orderno}", model.order_no);
                                    mailContent = mailContent.Replace("{amount}", model.order_amount.ToString());
                                    //发送邮件
                                    MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
                                        siteConfig.emailfrom, userModel.email, mailTitle, mailContent);
                                }
                                break;
                        }
                    }
                    #endregion
                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功!\"}");
                    break;
                case "order_payment": //确认付款
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认付款的权限!\"}");
                        return;
                    }
                    if (model.status > 1 || model.payment_status == 2)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已确认,不能重复处理!\"}");
                        return;
                    }
                    model.payment_status = 2;
                    model.payment_time = DateTime.Now;
                    model.status = 2;
                    model.confirm_time = DateTime.Now;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单确认付款失败!\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认付款订单号:" + model.order_no); //记录日志
                    #region 发送短信或邮件
                    if (orderConfig.confirmmsg > 0)
                    {
                        switch (orderConfig.confirmmsg)
                        {
                            case 1: //短信通知
                                if (string.IsNullOrEmpty(model.mobile))
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}");
                                    return;
                                }
                                Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.confirmcallindex); //取得短信内容
                                if (smsModel == null)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}");
                                    return;
                                }
                                //替换标签
                                string msgContent = smsModel.content;
                                msgContent = msgContent.Replace("{webname}", siteConfig.webname);
                                msgContent = msgContent.Replace("{username}", model.user_name);
                                msgContent = msgContent.Replace("{orderno}", model.order_no);
                                msgContent = msgContent.Replace("{amount}", model.order_amount.ToString());
                                //发送短信
                                string tipMsg = string.Empty;
                                bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
                                if (!sendStatus)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}");
                                    return;
                                }
                                break;
                            case 2: //邮件通知
                                //取得用户的邮箱地址
                                if (model.user_id > 0)
                                {
                                    Model.users userModel = new BLL.users().GetModel(model.user_id);
                                    if (userModel == null || string.IsNullOrEmpty(userModel.email))
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}");
                                        return;
                                    }
                                    //取得邮件模板内容
                                    Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.confirmcallindex);
                                    if (mailModel == null)
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}");
                                        return;
                                    }
                                    //替换标签
                                    string mailTitle = mailModel.maill_title;
                                    mailTitle = mailTitle.Replace("{username}", model.user_name);
                                    string mailContent = mailModel.content;
                                    mailContent = mailContent.Replace("{webname}", siteConfig.webname);
                                    mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
                                    mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
                                    mailContent = mailContent.Replace("{username}", model.user_name);
                                    mailContent = mailContent.Replace("{orderno}", model.order_no);
                                    mailContent = mailContent.Replace("{amount}", model.order_amount.ToString());
                                    //发送邮件
                                    MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
                                        siteConfig.emailfrom, userModel.email, mailTitle, mailContent);
                                }
                                break;
                        }
                    }
                    #endregion
                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认付款成功!\"}");
                    break;
                case "order_express": //确认发货
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认发货的权限!\"}");
                        return;
                    }
                    if (model.status > 2 || model.express_status == 2)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已完成或已发货,不能重复处理!\"}");
                        return;
                    }
                    int express_id = MXRequest.GetFormInt("express_id");
                    string express_no = MXRequest.GetFormString("express_no");
                    if (express_id == 0)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"请选择配送方式!\"}");
                        return;
                    }
                    model.express_id = express_id;
                    model.express_no = express_no;
                  
                    model.express_time = DateTime.Now;
                    string ret = "";
                    if (model.payment_id == 3 && model.express_status != 2)
                    { 
                        //通知微信支付,改变发货状态
                        FaHuoProc fahuo = new FaHuoProc();

                        BLL.wx_payment_wxpay payBll = new BLL.wx_payment_wxpay();
                        Model.wx_payment_wxpay paymentInfo = payBll.GetModelByWid(model.wid.Value);
                        Dictionary<string, object> fahuoDict = fahuo.fahuomgr(paymentInfo, model);
                        string errcode = fahuoDict["errcode"].ToString();
                        string errmsg = fahuoDict["errmsg"].ToString();
                        model.fahuoCode = errcode;
                        model.fahuoMsg = errmsg;
                        if (errcode == "0")
                        {
                            model.express_status = 2;
                        }
                        else
                        {
                            ret = "通知微信支付,改变发货状态失败:"+errmsg;
                        }
                    }
                    model.express_status = 2;
                    if (!bll.Update(model))
                    {
                        ret += "订单发货失败!";
                        context.Response.Write("{\"status\": 0, \"msg\": \"" + ret + "\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认发货订单号:" + model.order_no); //记录日志
                    #region 发送短信或邮件
                    if (orderConfig.expressmsg > 0)
                    {
                        switch (orderConfig.expressmsg)
                        {
                            case 1: //短信通知
                                if (string.IsNullOrEmpty(model.mobile))
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}");
                                    return;
                                }
                                Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.expresscallindex); //取得短信内容
                                if (smsModel == null)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}");
                                    return;
                                }
                                //替换标签
                                string msgContent = smsModel.content;
                                msgContent = msgContent.Replace("{webname}", siteConfig.webname);
                                msgContent = msgContent.Replace("{username}", model.user_name);
                                msgContent = msgContent.Replace("{orderno}", model.order_no);
                                msgContent = msgContent.Replace("{amount}", model.order_amount.ToString());
                                //发送短信
                                string tipMsg = string.Empty;
                                bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
                                if (!sendStatus)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}");
                                    return;
                                }
                                break;
                            case 2: //邮件通知
                                //取得用户的邮箱地址
                                if (model.user_id > 0)
                                {
                                    Model.users userModel = new BLL.users().GetModel(model.user_id);
                                    if (userModel == null || string.IsNullOrEmpty(userModel.email))
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}");
                                        return;
                                    }
                                    //取得邮件模板内容
                                    Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.expresscallindex);
                                    if (mailModel == null)
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}");
                                        return;
                                    }
                                    //替换标签
                                    string mailTitle = mailModel.maill_title;
                                    mailTitle = mailTitle.Replace("{username}", model.user_name);
                                    string mailContent = mailModel.content;
                                    mailContent = mailContent.Replace("{webname}", siteConfig.webname);
                                    mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
                                    mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
                                    mailContent = mailContent.Replace("{username}", model.user_name);
                                    mailContent = mailContent.Replace("{orderno}", model.order_no);
                                    mailContent = mailContent.Replace("{amount}", model.order_amount.ToString());
                                    //发送邮件
                                    MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
                                        siteConfig.emailfrom, userModel.email, mailTitle, mailContent);
                                }
                                break;
                        }
                    }
                    #endregion
                    context.Response.Write("{\"status\": 1, \"msg\": \"订单发货成功!\"}");
                    break;
                case "order_complete": //完成订单=========================================
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Confirm.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有确认完成订单的权限!\"}");
                        return;
                    }
                    if (model.status > 2)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已经完成,不能重复处理!\"}");
                        return;
                    }
                    model.status = 3;
                    model.complete_time = DateTime.Now;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"确认订单完成失败!\"}");
                        return;
                    }
                    //给会员增加积分检查升级
                    if (model.user_id > 0 && model.point > 0)
                    {
                        new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "购物获得积分,订单号:" + model.order_no, true);
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Confirm.ToString(), "确认交易完成订单号:" + model.order_no); //记录日志
                    #region 发送短信或邮件
                    if (orderConfig.completemsg > 0)
                    {
                        switch (orderConfig.completemsg)
                        {
                            case 1: //短信通知
                                if (string.IsNullOrEmpty(model.mobile))
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >对方未填写手机号码!\"}");
                                    return;
                                }
                                Model.sms_template smsModel = new BLL.sms_template().GetModel(orderConfig.completecallindex); //取得短信内容
                                if (smsModel == null)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >短信通知模板不存在!\"}");
                                    return;
                                }
                                //替换标签
                                string msgContent = smsModel.content;
                                msgContent = msgContent.Replace("{webname}", siteConfig.webname);
                                msgContent = msgContent.Replace("{username}", model.user_name);
                                msgContent = msgContent.Replace("{orderno}", model.order_no);
                                msgContent = msgContent.Replace("{amount}", model.order_amount.ToString());
                                //发送短信
                                string tipMsg = string.Empty;
                                bool sendStatus = new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
                                if (!sendStatus)
                                {
                                    context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送短信<br/ >" + tipMsg + "\"}");
                                    return;
                                }
                                break;
                            case 2: //邮件通知
                                //取得用户的邮箱地址
                                if (model.user_id > 0)
                                {
                                    Model.users userModel = new BLL.users().GetModel(model.user_id);
                                    if (userModel == null || string.IsNullOrEmpty(userModel.email))
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >该用户不存在或没有填写邮箱地址。\"}");
                                        return;
                                    }
                                    //取得邮件模板内容
                                    Model.mail_template mailModel = new BLL.mail_template().GetModel(orderConfig.completecallindex);
                                    if (mailModel == null)
                                    {
                                        context.Response.Write("{\"status\": 1, \"msg\": \"订单确认成功,但无法发送邮件<br/ >邮件通知模板不存在。\"}");
                                        return;
                                    }
                                    //替换标签
                                    string mailTitle = mailModel.maill_title;
                                    mailTitle = mailTitle.Replace("{username}", model.user_name);
                                    string mailContent = mailModel.content;
                                    mailContent = mailContent.Replace("{webname}", siteConfig.webname);
                                    mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
                                    mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
                                    mailContent = mailContent.Replace("{username}", model.user_name);
                                    mailContent = mailContent.Replace("{orderno}", model.order_no);
                                    mailContent = mailContent.Replace("{amount}", model.order_amount.ToString());
                                    //发送邮件
                                    MXMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
                                        siteConfig.emailfrom, userModel.email, mailTitle, mailContent);
                                }
                                break;
                        }
                    }
                    #endregion
                    context.Response.Write("{\"status\": 1, \"msg\": \"确认订单完成成功!\"}");
                    break;
                case "order_cancel": //取消订单==========================================
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Cancel.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有取消订单的权限!\"}");
                        return;
                    }
                    if (model.status > 2)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已经完成,不能取消订单!\"}");
                        return;
                    }
                    model.status = 4;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"取消订单失败!\"}");
                        return;
                    }
                    int check_revert1 = MXRequest.GetFormInt("check_revert");
                    if (check_revert1 == 1)
                    {
                        //如果存在积分换购则返还会员积分
                        if (model.user_id > 0 && model.point < 0)
                        {
                            new BLL.user_point_log().Add(model.user_id, model.user_name, (model.point * -1), "取消订单返还积分,订单号:" + model.order_no, false);
                        }
                        //如果已支付则退还金额到会员账户
                        if (model.user_id > 0 && model.payment_status == 2 && model.order_amount > 0)
                        {
                            new BLL.user_amount_log().Add(model.user_id, model.user_name, MXEnums.AmountTypeEnum.BuyGoods.ToString(), model.order_amount, "取消订单退还金额,订单号:" + model.order_no);
                        }
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Cancel.ToString(), "取消订单号:" + model.order_no); //记录日志
                    context.Response.Write("{\"status\": 1, \"msg\": \"取消订单成功!\"}");
                    break;
                case "order_invalid": //作废订单==========================================
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Invalid.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有作废订单的权限!\"}");
                        return;
                    }
                    if (model.status != 3)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单尚未完成,不能作废订单!\"}");
                        return;
                    }
                    model.status = 5;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"作废订单失败!\"}");
                        return;
                    }
                    int check_revert2 = MXRequest.GetFormInt("check_revert");
                    if (check_revert2 == 1)
                    {
                        //扣除购物赠送的积分
                        if (model.user_id > 0 && model.point > 0)
                        {
                            new BLL.user_point_log().Add(model.user_id, model.user_name, (model.point * -1), "作废订单扣除积分,订单号:" + model.order_no, false);
                        }
                        //退还金额到会员账户
                        if (model.user_id > 0 && model.order_amount > 0)
                        {
                            new BLL.user_amount_log().Add(model.user_id, model.user_name, MXEnums.AmountTypeEnum.BuyGoods.ToString(), model.order_amount, "取消订单退还金额,订单号:" + model.order_no);
                        }
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Invalid.ToString(), "作废订单号:" + model.order_no); //记录日志
                    context.Response.Write("{\"status\": 1, \"msg\": \"作废订单成功!\"}");
                    break;
                case "edit_accept_info": //修改收货信息====================================
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有修改收货信息的权限!\"}");
                        return;
                    }
                    if (model.express_status == 2)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已经发货,不能修改收货信息!\"}");
                        return;
                    }
                    string accept_name = MXRequest.GetFormString("accept_name");
                    string province = MXRequest.GetFormString("province");
                    string city = MXRequest.GetFormString("city");
                    string area = MXRequest.GetFormString("area");
                    string address = MXRequest.GetFormString("address");
                    string post_code = MXRequest.GetFormString("post_code");
                    string mobile = MXRequest.GetFormString("mobile");
                    string telphone = MXRequest.GetFormString("telphone");

                    if (accept_name == "")
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"请填写收货人姓名!\"}");
                        return;
                    }
                    if (area == "")
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"请选择所在地区!\"}");
                        return;
                    }
                    if (address == "")
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"请填写详细的送货地址!\"}");
                        return;
                    }
                    if (mobile == "" && telphone == "")
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"联系手机或电话至少填写一项!\"}");
                        return;
                    }

                    model.accept_name = accept_name;
                    model.area = province + "," + city + "," + area;
                    model.address = address;
                    model.post_code = post_code;
                    model.mobile = mobile;
                    model.telphone = telphone;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"修改收货人信息失败!\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改收货信息,订单号:" + model.order_no); //记录日志
                    context.Response.Write("{\"status\": 1, \"msg\": \"修改收货人信息成功!\"}");
                    break;
                case "edit_order_remark": //修改订单备注=================================
                    string remark = MXRequest.GetFormString("remark");
                    if (remark == "")
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"请填写订单备注内容!\"}");
                        return;
                    }
                    model.remark = remark;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"修改订单备注失败!\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改订单备注,订单号:" + model.order_no); //记录日志
                    context.Response.Write("{\"status\": 1, \"msg\": \"修改订单备注成功!\"}");
                    break;
                case "edit_real_amount": //修改商品总金额================================
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有修改商品金额的权限!\"}");
                        return;
                    }
                    if (model.status > 1)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能修改金额!\"}");
                        return;
                    }
                    decimal real_amount = MXRequest.GetFormDecimal("real_amount", 0);
                    model.real_amount = real_amount;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"修改商品总金额失败!\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改商品金额,订单号:" + model.order_no); //记录日志
                    context.Response.Write("{\"status\": 1, \"msg\": \"修改商品总金额成功!\"}");
                    break;
                case "edit_express_fee": //修改配送费用==================================
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有配送费用的权限!\"}");
                        return;
                    }
                    if (model.status > 1)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能修改金额!\"}");
                        return;
                    }
                    decimal express_fee = MXRequest.GetFormDecimal("express_fee", 0);
                    model.express_fee = express_fee;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"修改配送费用失败!\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改配送费用,订单号:" + model.order_no); //记录日志
                    context.Response.Write("{\"status\": 1, \"msg\": \"修改配送费用成功!\"}");
                    break;
                case "edit_payment_fee": //修改支付手续费=================================
                    //检查权限
                    if (!new BLL.manager_role().Exists(adminInfo.role_id, "order_list", MXEnums.ActionEnum.Edit.ToString()))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"您没有修改支付手续费的权限!\"}");
                        return;
                    }
                    if (model.status > 1)
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"订单已经确认,不能修改金额!\"}");
                        return;
                    }
                    decimal payment_fee = MXRequest.GetFormDecimal("payment_fee", 0);
                    model.payment_fee = payment_fee;
                    if (!bll.Update(model))
                    {
                        context.Response.Write("{\"status\": 0, \"msg\": \"修改支付手续费失败!\"}");
                        return;
                    }
                    new BLL.manager_log().Add(adminInfo.id, adminInfo.user_name, MXEnums.ActionEnum.Edit.ToString(), "修改支付手续费,订单号:" + model.order_no); //记录日志
                    context.Response.Write("{\"status\": 1, \"msg\": \"修改支付手续费成功!\"}");
                    break;
            }

        }
コード例 #6
0
 private int GetIsLoginAndIsStaticstatus()
 {
     Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
     //取得管理员登录信息
     Model.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
     if (adminInfo == null)
         return -1;
     else if (!new BLL.manager_role().Exists(adminInfo.role_id, "app_builder_html", MXEnums.ActionEnum.Build.ToString()))
         return -2;
     else if (siteConfig.staticstatus != 2)
         return -3;
     else
         return 1;
 }
コード例 #7
0
        private void saveQuestionOptions()
        {
            int    id       = RequestHelper.GetFormInt("id");
            int    group    = RequestHelper.GetFormInt("group", 0);
            int    type     = RequestHelper.GetFormInt("type", 0);
            int    chapter  = RequestHelper.GetFormInt("chapter", 0);
            string title    = RequestHelper.GetFormString("title");
            int    score    = RequestHelper.GetFormInt("score", 0);
            string answers  = RequestHelper.GetFormString("answers");
            string analysis = RequestHelper.GetFormString("analysis");
            string options  = RequestHelper.GetFormString("options");

            Appoa.Web.UI.ManagePage mngPage = new Web.UI.ManagePage();
            BLL.common_questions    bll     = new BLL.common_questions();
            Model.common_questions  model   = bll.GetModel(id);

            if (model != null)
            {
                #region 修改题目信息
                model.group_id = group;
                model.type     = type;
                model.data_id  = chapter;
                model.number   = 0;
                model.title    = title;
                model.answer   = (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 ||
                                  model.type == (int)EnumCollection.questions_type.判断题) ? answers.Trim().ToUpper() : answers.Trim();
                model.score    = score;
                model.analysis = HttpUtility.UrlDecode(analysis, System.Text.Encoding.UTF8);

                if (bll.Update(model))
                {
                    try
                    {
                        #region  择题设置选项
                        if (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 || model.type == (int)EnumCollection.questions_type.判断题)
                        {
                            JArray               optionArr = JsonConvert.DeserializeObject <JArray>(options);
                            BLL.common_answers   anBll     = new BLL.common_answers();
                            Model.common_answers anModel   = null;

                            List <int> ids = new List <int>();
                            foreach (JObject obj in optionArr)
                            {
                                ids.Add(Convert.ToInt32(obj["options_id"].ToString()));
                            }

                            DataTable dt = anBll.GetList(" question_id = " + model.id);
                            foreach (DataRow item in dt.Rows)
                            {
                                int afid = Convert.ToInt32(item["id"]);
                                if (afid > 0)
                                {
                                    if (!ids.Contains(afid))
                                    {
                                        anBll.Delete(afid);
                                    }
                                }
                            }

                            foreach (JObject item in optionArr)
                            {
                                int options_id = Convert.ToInt32(item["options_id"]);
                                anModel = anBll.GetModel(options_id);
                                if (anModel != null)
                                {
                                    #region 修改选项
                                    anModel.question_id = model.id;
                                    anModel.options     = item["options"].ToString();
                                    anModel.contents    = item["options_contents"].ToString();
                                    anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                    if (anBll.Update(anModel))
                                    {
                                        mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改选项信息,主键:" + options_id); //记录日志
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 添加选项
                                    anModel             = new Model.common_answers();
                                    anModel.question_id = model.id;
                                    anModel.options     = item["options"].ToString();
                                    anModel.contents    = item["options_contents"].ToString();
                                    anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                    anModel.add_time    = System.DateTime.Now;

                                    int anid = anBll.Add(anModel);
                                    if (anid > 0)
                                    {
                                        mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加选项信息,主键:" + anid); //记录日志
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }
                    catch (Exception e)
                    {
                        writeMsgError("系统错误:" + e.Message);
                    }

                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改试题信息,主键:" + model.id); //记录日志

                    writeMsgSuccess("修改题目信息成功");
                }
                else
                {
                    writeMsgError("修改题目信息失败");
                }
                #endregion
            }
            else
            {
                #region 添加题目信息
                model          = new Model.common_questions();
                model.group_id = group;
                model.type     = type;
                model.data_id  = chapter;
                model.number   = 0;
                model.title    = title;
                model.answer   = (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 ||
                                  model.type == (int)EnumCollection.questions_type.判断题) ? answers.Trim().ToUpper() : answers.Trim();
                model.score    = score;
                model.analysis = HttpUtility.UrlDecode(analysis, System.Text.Encoding.UTF8);
                model.add_time = System.DateTime.Now;

                int qid = bll.Add(model);
                if (qid > 0)
                {
                    try
                    {
                        #region  择题设置选项
                        if (model.type == (int)EnumCollection.questions_type.单选题 || model.type == (int)EnumCollection.questions_type.多选题 || model.type == (int)EnumCollection.questions_type.判断题)
                        {
                            JArray               optionArr = JsonConvert.DeserializeObject <JArray>(options);
                            BLL.common_answers   anBll     = new BLL.common_answers();
                            Model.common_answers anModel   = null;

                            foreach (JObject item in optionArr)
                            {
                                int options_id = Convert.ToInt32(item["options_id"]);
                                if (options_id > 0)
                                {
                                    #region 修改选项
                                    anModel = anBll.GetModel(options_id);
                                    if (anModel != null)
                                    {
                                        anModel.question_id = qid;
                                        anModel.options     = item["options"].ToString();
                                        anModel.contents    = item["options_contents"].ToString();
                                        anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                        if (anBll.Update(anModel))
                                        {
                                            mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改选项信息,主键:" + options_id); //记录日志
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 添加选项
                                    anModel             = new Model.common_answers();
                                    anModel.question_id = qid;
                                    anModel.options     = item["options"].ToString();
                                    anModel.contents    = item["options_contents"].ToString();
                                    anModel.score       = Convert.ToInt32(item["options_score"].ToString());
                                    anModel.add_time    = System.DateTime.Now;

                                    int anid = anBll.Add(anModel);
                                    if (anid > 0)
                                    {
                                        mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加选项信息,主键:" + anid); //记录日志
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }
                    catch (Exception e)
                    {
                        writeMsgError("系统错误:" + e.Message);
                    }

                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加试题信息,主键:" + qid); //记录日志

                    writeMsgSuccess("添加题目信息成功");
                }
                else
                {
                    writeMsgError("添加题目信息失败");
                }
                #endregion
            }
        }
コード例 #8
0
        private void saveWordVoice()
        {
            int    id          = RequestHelper.GetFormInt("id");
            int    group       = RequestHelper.GetFormInt("group");
            int    school      = RequestHelper.GetFormInt("school");
            string school_name = RequestHelper.GetFormString("school_name");
            int    chapter     = RequestHelper.GetFormInt("chapter");
            string title       = RequestHelper.GetFormString("title");
            string userids     = RequestHelper.GetFormString("userids");
            string words       = RequestHelper.GetFormString("words");

            Appoa.Web.UI.ManagePage mngPage = new Web.UI.ManagePage();
            BLL.common_resource     bll     = new BLL.common_resource();
            Model.common_resource   model   = bll.GetModel(id);

            if (model != null)
            {
                model.group_id = group;
                if (model.group_id == (int)EnumCollection.resource_group.公共资源)
                {
                    model.school_id   = 0;
                    model.school_name = "";
                }
                else
                {
                    model.school_id   = school;
                    model.school_name = school_name;
                }

                model.data_id = chapter;
                model.user_id = mngPage.GetAdminInfo().id;

                model.title      = title;
                model.path       = words;
                model.share_user = userids;

                if (bll.Update(model))
                {
                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改英文发音资源信息,主键:" + id); //记录日志

                    writeMsgSuccess("保存成功");
                }
                else
                {
                    writeMsgError("保存失败");
                }
            }
            else
            {
                model          = new Model.common_resource();
                model.from_id  = (int)EnumCollection.resource_from.精品微课;
                model.group_id = group;
                model.type     = (int)EnumCollection.resource_type.英文发音;

                if (model.group_id == (int)EnumCollection.resource_group.公共资源)
                {
                    model.school_id   = 0;
                    model.school_name = "";
                }
                else
                {
                    model.school_id   = school;
                    model.school_name = school_name;
                }
                model.data_id = chapter;
                model.user_id = mngPage.GetAdminInfo().id;

                model.title      = title;
                model.cover      = "";
                model.path       = words;
                model.qrcode     = "";
                model.file_name  = "";
                model.extend     = "";
                model.likn_url   = "";
                model.add_time   = System.DateTime.Now;
                model.share_user = userids;

                int row = bll.Add(model);
                if (row > 0)
                {
                    model.id     = row;
                    model.qrcode = "/QrCode.aspx?type=re&id=" + row;
                    bll.Update(model);

                    mngPage.AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加英文发音资源信息,主键:" + row); //记录日志

                    writeMsgSuccess("保存成功");
                }
                else
                {
                    writeMsgError("保存失败");
                }
            }
        }
コード例 #9
0
ファイル: admin_ajax.ashx.cs プロジェクト: uwitec/MWMS
 private int get_builder_status()
 {
     //取得管理员登录信息
     Model.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
     if (adminInfo == null)
         return -1;
     else if (!new BLL.manager_role().Exists(adminInfo.role_id, "sys_builder_html", DTEnums.ActionEnum.Build.ToString()))
         return -2;
     else if (siteConfig.staticstatus != 2)
         return -3;
     else
         return 1;
 }
コード例 #10
0
ファイル: admin_ajax.ashx.cs プロジェクト: eyren/OScms
        private void edit_category(HttpContext context)
        {
            //取得管理员登录信息
            Model.managers.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
            if (adminInfo == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}");
                return;
            }

            int category1 = OSRequest.GetFormInt("Category1");
            int category2 = OSRequest.GetFormInt("Category2");
            if (category1 == category2)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"移动目录跟目的目录不能相同!\"}");
                return;
            }

            BLL.contents.article_category bll = new BLL.contents.article_category();
            Model.contents.article_category model = bll.GetModel(category2);

            if (model.class_list.IndexOf("," + category1 + ",") > 0)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"父级本不能向其子级转移!\"}");
                return;
            }

            if (bll.GetModel(category1).parent_id == category2)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"移动目录已经在目的目录里!\"}");
                return;
            }

            DataTable dt = bll.GetList(0, "class_list like '%," + category1 + ",%'", "class_layer asc").Tables[0];
            if (dt.Rows != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    int id = Convert.ToInt32(dt.Rows[i]["id"]);
                    string class_list = dt.Rows[i]["class_list"].ToString();
                    int new_channel_id = model.channel_id;
                    string new_class_list = model.class_list + class_list.Substring(class_list.IndexOf("," + category1 + ",")).TrimStart(',');
                    string new_class_layer = new_class_list.Trim(',').Split(',').Length.ToString();
                    if (i == 0)
                    {
                        bll.UpdateField(id, "channel_id=" + new_channel_id + ", parent_id=" + category2 + ", class_list='" + new_class_list + "',class_layer=" + new_class_layer);
                    }
                    else
                    {
                        bll.UpdateField(id, "channel_id=" + new_channel_id + ", class_list='" + new_class_list + "',class_layer=" + new_class_layer);
                    }
                }
            }

            new BLL.managers.manager_log().Add(adminInfo.id, adminInfo.user_name, OSEnums.ActionEnum.Edit.ToString(), "移动栏目:" + bll.GetModel(category1).title); //记录日志
            context.Response.Write("{\"status\": 1, \"msg\": \"栏目转移成功!\"}");
        }
コード例 #11
0
ファイル: admin_ajax.ashx.cs プロジェクト: eyren/OScms
 private void delete_category(HttpContext context)
 {
     //取得管理员登录信息
     Model.managers.manager adminInfo = new Web.UI.ManagePage().GetAdminInfo();
     if (adminInfo == null)
     {
         context.Response.Write("{\"status\": 0, \"msg\": \"未登录或已超时,请重新登录!\"}");
         return;
     }
     int category_id = OSRequest.GetQueryInt("category_id");
     if (category_id == 0)
     {
         context.Response.Write("{\"status\": 0, \"msg\": \"参数错误!\"}");
         return;
     }
     BLL.contents.article_category bll = new BLL.contents.article_category();
     new BLL.managers.manager_log().Add(adminInfo.id, adminInfo.user_name, OSEnums.ActionEnum.Edit.ToString(), "删除栏目:" + bll.GetTitle(category_id)); //记录日志
     bll.Delete(category_id);
     context.Response.Write("{\"status\": 1, \"msg\": \"栏目删除成功!\"}");
 }