コード例 #1
0
        public ContentResult ToAdd(BasePostCode para)
        {
            if (string.IsNullOrWhiteSpace(para.PostName))
            {
                return(Content("快递公司名不能为空"));
            }
            if (RepeatHelper.NoRepeat("BasePostCode", "PostName", para.PostName, para.ID) > 0)
            {
                return(Content("快递公司名已存在"));
            }
            if (!string.IsNullOrWhiteSpace(para.PostCode))
            {
                if (RepeatHelper.NoRepeat("BasePostCode", "PostCode", para.PostCode, para.ID) > 0)
                {
                    return(Content("快递公司代号已存在"));
                }
            }
            int rtn = para.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
コード例 #2
0
        public ContentResult ToEdit(BasePostCode para)
        {
            if (string.IsNullOrWhiteSpace(para.PostName))
            {
                return(Content("快递公司名不能为空"));
            }
            if (RepeatHelper.NoRepeat("BasePostCode", "PostName", para.PostName, para.ID) > 0)
            {
                return(Content("快递公司名已存在"));
            }
            if (!string.IsNullOrWhiteSpace(para.PostCode))
            {
                if (RepeatHelper.NoRepeat("BasePostCode", "PostCode", para.PostCode, para.ID) > 0)
                {
                    return(Content("快递公司代号已存在"));
                }
            }
            int rtn = para.UpdateByID();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
コード例 #3
0
ファイル: jf_GoodsController.cs プロジェクト: Haute998/WalkTd
        public ActionResult ToEditGoods(jf_Goods goods)
        {
            jf_Goods OldGoods  = jf_Goods.GetEntityByID(goods.ID);
            string   oldImgUrl = OldGoods.Main_img;//原来的图片

            if (oldImgUrl.Contains("?"))
            {
                oldImgUrl = oldImgUrl.SubStringSafe(0, oldImgUrl.IndexOf("?"));
            }
            string msg = "";

            if (RepeatHelper.NoRepeat("jf_Goods", "GoodsName", goods.GoodsName, goods.ID) > 0)
            {
                msg         = "该礼品已存在!";
                goods.error = msg;
                return(View("EditGoods", goods));
            }
            OldGoods.GoodsName = goods.GoodsName;
            var file = Request.Files[0];

            if (file.ContentLength > 0 && file != null)
            {
                if (file.ContentLength > 5242880)
                {
                    msg         = "上传图片不能超过5MB!";
                    goods.error = msg;
                    return(View("EditGoods", goods));
                }
                if (!Directory.Exists(Server.MapPath("~/images/jf_Goods/")))
                {
                    Directory.CreateDirectory(Server.MapPath("~/images/jf_Goods/"));
                }
                string path = Request.MapPath("~/");
                string ext  = Path.GetExtension(file.FileName); //获得文件扩展名
                OldGoods.Main_img = "/images/jf_Goods/G_" + OldGoods.ID + ext;
                string saveName = OldGoods.Main_img;            //实际保存文件名

                try
                {
                    string delFile = Server.MapPath("~") + oldImgUrl;
                    System.IO.File.Delete(delFile);
                }
                catch (Exception ex) { }


                file.SaveAs(path + saveName);
            }
            OldGoods.Main_img     = OldGoods.Main_img + "?" + DateTime.Now.ToString("yyyyMMddHHmmss");
            OldGoods.SaleIntegral = goods.SaleIntegral;
            OldGoods.Quantity     = goods.Quantity;
            if (OldGoods.EditByID() > 0)
            {
                goods.error = "ok";
            }
            else
            {
                goods.error = "修改礼品失败!";
            }
            return(View("EditGoods", goods));
        }
コード例 #4
0
ファイル: B_MenuController.cs プロジェクト: Haute998/WalkTd
        public ContentResult MenusToAdd(B_Menu menu)
        {
            menu.IsShow  = Request["IsShow"] != null && Request["IsShow"].ToString() == "on" ? true : false;
            menu.IsValid = Request["IsValid"] != null && Request["IsValid"].ToString() == "on" ? true : false;
            menu.IsRobot = Request["IsRobot"] != null && Request["IsRobot"].ToString() == "on" ? false : true;

            if (string.IsNullOrWhiteSpace(menu.MenuName))
            {
                return(Content("名称不能为空"));
            }
            if (RepeatHelper.NoRepeat("B_Menu", "MenuName", menu.MenuName, menu.ID) > 0)
            {
                return(Content("菜单名已存在"));
            }
            if (!string.IsNullOrWhiteSpace(menu.MenuUrl) && RepeatHelper.NoRepeat("B_Menu", "MenuUrl", menu.MenuUrl, menu.ID) > 0)
            {
                return(Content("菜单链接已存在"));
            }

            int rtn = menu.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                bool hasMainMenuTag          = false;
                bool hasError                = false;
                List <B_MenuRights> muRights = null;
                if (string.IsNullOrWhiteSpace(menu.MenuUrl) == false)
                {
                    menu.MenuUrl = menu.MenuUrl.Trim().TrimEnd('/');
                    try
                    {
                        string[] arrUrl = menu.MenuUrl.TrimStart('/').Split('/');
                        Type     type   = Type.GetType("WeBusiness.Controllers." + arrUrl[0] + "Controller");
                        muRights = BaseAuthorizeHelper.GetBOMenuRightsByControllerType(type, arrUrl[1], out hasMainMenuTag);
                    }
                    catch (Exception ex)
                    {
                        DAL.Log.Instance.Write(ex.ToString(), "BOMenu_Add");
                        hasError = true;
                    }
                }

                if (hasMainMenuTag && muRights != null)
                {
                    B_MenuRights.RelevanceList(rtn, muRights);
                }
                if (hasError)
                {
                    return(Content("添加菜单成功,但菜单没有添加权限!"));
                }


                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
コード例 #5
0
        public ContentResult ToAdd(SYSICodeIntegralSet para)
        {
            if (string.IsNullOrWhiteSpace(para.CodePrefix))
            {
                return(Content("前缀不能为空"));
            }
            if (RepeatHelper.NoRepeat("SYSICodeIntegralSet", "CodePrefix", para.CodePrefix, para.ID) > 0)
            {
                return(Content("该前缀已存在"));
            }
            int rtn = para.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
コード例 #6
0
        public ContentResult ToEdit(BaseParameters para)
        {
            if (string.IsNullOrWhiteSpace(para.NickName))
            {
                return(Content("参数名称不能为空"));
            }
            if (RepeatHelper.NoRepeat("BaseParameters", "ParametersKey", para.ParametersKey, para.ID) > 0)
            {
                return(Content("唯一标识已存在"));
            }
            int rtn = para.SYSEditByID();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
コード例 #7
0
ファイル: B_RoleController.cs プロジェクト: Haute998/WalkTd
        public ContentResult B_RoleToEdit(B_Role role)
        {
            if (string.IsNullOrWhiteSpace(role.RoleName))
            {
                return(Content("角色名不能为空"));
            }
            if (RepeatHelper.NoRepeat("B_Role", "RoleName", role.RoleName, role.ID) > 0)
            {
                return(Content("角色名已存在"));
            }
            int rtn = role.UpdateByID();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
コード例 #8
0
ファイル: B_RoleController.cs プロジェクト: Haute998/WalkTd
        public ContentResult B_RoleToAdd(B_Role role)
        {
            if (string.IsNullOrWhiteSpace(role.RoleName))
            {
                return(Content("角色名不能为空"));
            }
            if (RepeatHelper.NoRepeat("B_Role", "RoleName", role.RoleName, role.ID) > 0)
            {
                return(Content("角色名已存在"));
            }
            int rtn = role.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
コード例 #9
0
        public ContentResult ToEdit(SYSICodeIntegralSet para)
        {
            if (string.IsNullOrWhiteSpace(para.CodePrefix))
            {
                return(Content("前缀不能为空"));
            }
            if (RepeatHelper.NoRepeat("SYSICodeIntegralSet", "CodePrefix", para.CodePrefix, para.ID) > 0)
            {
                return(Content("该前缀已存在"));
            }
            int rtn = para.UpdateByID();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
コード例 #10
0
        public ContentResult ToEdit(LotteryActivitys para)
        {
            if (string.IsNullOrWhiteSpace(para.Title))
            {
                return(Content("活动标题不能为空"));
            }
            if (RepeatHelper.NoRepeat("LotteryActivitys", "Title", para.Title, para.ID) > 0)
            {
                return(Content("活动标题已存在"));
            }
            para.IsValid = true;
            int rtn = para.EditByID();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
コード例 #11
0
        public ContentResult ToAdd(LotteryActivitys para)
        {
            para.IsValid = true;
            if (string.IsNullOrWhiteSpace(para.Title))
            {
                return(Content("fail|活动标题不能为空"));
            }
            if (RepeatHelper.NoRepeat("LotteryActivitys", "Title", para.Title, para.ID) > 0)
            {
                return(Content("fail|活动标题已存在"));
            }
            int rtn = para.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok|" + rtn));
            }
            return(Content("fail|添加出错"));
        }
コード例 #12
0
ファイル: jf_GoodsController.cs プロジェクト: Haute998/WalkTd
        public ActionResult ToAddGoods(jf_Goods goods)
        {
            string msg = "";

            if (RepeatHelper.NoRepeat("jf_Goods", "GoodsName", goods.GoodsName, goods.ID) > 0)
            {
                msg         = "该礼品名称已存在!";
                goods.error = msg;
                return(View("AddGoods", goods));
            }
            var    file = Request.Files[0];
            string path = Request.MapPath("~/");
            string ext  = Path.GetExtension(file.FileName);//获得文件扩展名

            if (!Directory.Exists(Server.MapPath("~/images/jf_Goods/")))
            {
                Directory.CreateDirectory(Server.MapPath("~/images/jf_Goods/"));
            }
            if (file.ContentLength == 0 || file == null)
            {
                msg         = "上传的图片没有内容!";
                goods.error = msg;
                return(View("AddGoods", goods));
            }
            if (file.ContentLength > 5242880)
            {
                msg         = "上传图片不能超过5MB!";
                goods.error = msg;
                return(View("AddGoods", goods));
            }

            goods.PublishStat = "未上架";
            int rtn = goods.AddGoods(ext, CurrentUser.UserName);

            if (rtn > 0)
            {
                file.SaveAs(path + goods.Main_img);
                return(RedirectToAction("GoodsDetailEdit", "jf_Goods", new { id = goods.ID }));
            }
            msg         = "礼品添加失败!";
            goods.error = msg;
            return(View("AddGoods", goods));
        }
コード例 #13
0
        public ContentResult ToAdd(SYSMNotify notify)
        {
            if (string.IsNullOrWhiteSpace(notify.Title))
            {
                return(Content("标题不能为空"));
            }
            if (RepeatHelper.NoRepeat("SYSMNotify", "Title", notify.Title, notify.ID) > 0)
            {
                return(Content("标题已存在"));
            }
            notify.OperCreate = CurrentUser.UserName;
            notify.DatCreate  = DateTime.Now;
            notify.DatEdit    = DateTime.Now;
            notify.OperEdit   = CurrentUser.UserName;
            int rtn = notify.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
コード例 #14
0
        public ContentResult ToEdit(SYSNotify para)
        {
            if (string.IsNullOrWhiteSpace(para.MsgType))
            {
                return(Content("消息类别不能为空"));
            }
            if (string.IsNullOrWhiteSpace(para.MsgCode))
            {
                return(Content("消息代号不能为空"));
            }
            if (RepeatHelper.NoRepeat("SYSNotify", "MsgCode", para.MsgCode, para.ID) > 0)
            {
                return(Content("消息代号已存在"));
            }
            int rtn = para.EditByID();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("保存出错"));
        }
コード例 #15
0
        public ContentResult ToAdd(BaseParameters para)
        {
            if (string.IsNullOrWhiteSpace(para.ParametersKey))
            {
                return(Content("唯一标识不能为空"));
            }
            if (string.IsNullOrWhiteSpace(para.NickName))
            {
                return(Content("参数名称不能为空"));
            }
            if (RepeatHelper.NoRepeat("BaseParameters", "ParametersKey", para.ParametersKey, para.ID) > 0)
            {
                return(Content("唯一标识已存在"));
            }
            int rtn = para.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
コード例 #16
0
        public ContentResult ToAdd(SYSNotify para)
        {
            if (string.IsNullOrWhiteSpace(para.MsgType))
            {
                return(Content("消息类别不能为空"));
            }
            if (string.IsNullOrWhiteSpace(para.MsgCode))
            {
                return(Content("消息代号不能为空"));
            }
            if (RepeatHelper.NoRepeat("SYSNotify", "MsgCode", para.MsgCode, para.ID) > 0)
            {
                return(Content("消息代号已存在"));
            }
            int rtn = para.InsertAndReturnIdentity();

            if (rtn > 0)
            {
                return(Content("ok"));
            }
            return(Content("添加出错"));
        }
コード例 #17
0
ファイル: C_UserController.cs プロジェクト: Haute998/WalkTd
        public ActionResult DirectlyIndex_inport()
        {
            C_UserType usertype = C_UserType.GetMaxLevel_UserType();



            int    idLen = C_User.GetTopUseID().ToString().Length;
            string idDQ  = (C_User.GetTopUseID() + 1).ToString();

            if (idLen < 5)
            {
                string zero = new string('0', 5 - idLen);
                idDQ = zero + idDQ;
            }
            string msg = "";

            try
            {
                var    file = Request.Files[0];
                string path = Request.MapPath("~/");
                string ext  = Path.GetExtension(file.FileName);//获得文件扩展名
                if (!Directory.Exists(Server.MapPath("~/Codetxt/")))
                {
                    Directory.CreateDirectory(Server.MapPath("~/Codetxt/"));
                }
                if (file.ContentLength == 0 || file == null)
                {
                    msg = "上传的文件没有内容!";
                    TempData["ToIndex_err"] = msg;
                    return(View());
                }
                if (file.ContentLength > 3242880)
                {
                    msg = "上传的文件不能超过3MB!!";
                    TempData["ToIndex_err"] = msg;
                    return(View());
                }
                if (ext != ".txt")
                {
                    msg = "上传文件格式不对!";
                    TempData["ToIndex_err"] = msg;
                    return(View());
                }
                string DatNow = DateTime.Now.ToString("yyyyMMddHHmmss");
                file.SaveAs(Server.MapPath("~/Codetxt/" + DatNow + ".txt"));
                StreamReader sr = new StreamReader(Server.MapPath("~/Codetxt/" + DatNow + ".txt"), Encoding.Default);
                String       line;
                var          i        = 0;
                int          idDQ_num = 0;
                while ((line = sr.ReadLine()) != null)
                {
                    i++;
                    if (i == 1)
                    {
                        continue;
                    }
                    try
                    {
                        string[] list = line.ToString().Split(',');
                        if (string.IsNullOrWhiteSpace(list[0]) || string.IsNullOrWhiteSpace(list[1]))
                        {
                            continue;
                        }
                        if (C_User.GetPhoneCnt(list[1]) > 0 || C_User.GetNameCnt(list[0]) > 0)
                        {
                            SYSLog.add("导入失败(数据重复):手机号-" + list[1] + "||经销商名称-" + list[0], "电脑端后台用户" + CurrentUser.Name + "(" + CurrentUser.UserName + ")", CurrentURL, "导入用户", "电脑后台");
                            DAL.Log.Instance.Write("数据重复:手机号-" + list[1] + "||经销商名称-" + list[0], "导入用户失败");
                            continue;
                        }

                        /* var ls = idDQ.Length;
                         * if (Convert.ToInt32(idDQ)==idDQ_num)
                         * {
                         *   idDQ = (idDQ_num + 1).ToString();
                         *   idDQ_num = Convert.ToInt32(idDQ);
                         * }
                         * else
                         * {
                         *   idDQ_num = Convert.ToInt32(idDQ);0
                         * }
                         * if (ls > idDQ.ToString().Length)
                         * {
                         *   int length1 = ls - idDQ.ToString().Length;
                         *   if (length1 == 5) idDQ = "00000" + idDQ;
                         *   if (length1 == 4) idDQ = "0000" + idDQ;
                         *   if (length1 == 3) idDQ = "000" + idDQ;
                         *   if (length1 == 2) idDQ = "00" + idDQ;
                         *   if (length1 == 1) idDQ = "0" + idDQ;
                         * }*/
                        C_User para = new C_User();
                        para.state        = "已审核";
                        para.Chief        = 0;
                        para.C_UserTypeID = 1;
                        para.UserName     = usertype.TypeCode + (C_User.GetTopUseID() + 1 + 10000);
                        //经销商名称 联系人 联系方式 省份 市区 城镇 详细地址

                        para.Name       = list[0];
                        para.Phone      = list[2];
                        para.PassWord   = para.Phone.Substring(para.Phone.Length - 6, 6);
                        para.Card       = "";
                        para.Identifier = usertype.TypeCode + (C_User.GetTopUseID() + 1 + 10000);
                        para.wxNo       = list[1];
                        if (list.Count() > 4)
                        {
                            para.Province = string.IsNullOrWhiteSpace(list[3]) ? "" : list[4];
                        }
                        if (list.Count() > 5)
                        {
                            para.City = string.IsNullOrWhiteSpace(list[4]) ? "" : list[5];
                        }
                        if (list.Count() > 6)
                        {
                            para.Area = string.IsNullOrWhiteSpace(list[5]) ? "" : list[6];
                        }
                        if (list.Count() > 7)
                        {
                            para.WxQRCode = string.IsNullOrWhiteSpace(list[6]) ? "" : list[7];
                        }
                        para.DatCreate = DateTime.Now;
                        if (string.IsNullOrWhiteSpace(para.UserName))
                        {
                            return(Content("经销商编号不能为空"));
                        }
                        if (string.IsNullOrWhiteSpace(para.Name))
                        {
                            return(Content("姓名不能为空"));
                        }
                        if (string.IsNullOrWhiteSpace(para.Identifier))
                        {
                            return(Content("授权编号不能为空"));
                        }
                        if (RepeatHelper.NoRepeat("C_User", "Identifier", para.Identifier, para.ID) > 0)
                        {
                            return(Content("授权编号已存在"));
                        }



                        para.InsertAndReturnIdentity();
                    }
                    catch (Exception e)
                    {
                        DAL.Log.Instance.Write(e.Message, "导入用户失败");
                        continue;
                    }
                }
                sr.Close();
                System.IO.File.Delete(Server.MapPath("~/Codetxt/" + DatNow + ".txt"));
                msg = "导入成功!";
                TempData["ToIndex_err"] = msg;
                return(View("DirectlyIndex"));
            }
            catch
            {
                msg = "导入失败,文件太大!!";
                TempData["ToIndex_err"] = msg;
                return(View("DirectlyIndex"));
            }
        }