protected void Page_Load(object sender, EventArgs e)
        {
            int id = RequestTool.RequestInt("id", 0);

            model = B_Lebi_Supplier_User.GetModel(id);
            if (model == null)
            {
                if (!Power("supplier_user_add", "添加用户"))
                {
                    AjaxNoPower();
                }
                model = new Lebi_Supplier_User();
            }
            else
            {
                if (!Power("supplier_user_edit", "编辑用户"))
                {
                    AjaxNoPower();
                }
            }
            user = B_Lebi_User.GetModel(model.User_id);
            if (user == null)
            {
                user = new Lebi_User();
            }
        }
Example #2
0
        /// <summary>
        /// 编辑用户
        /// 20141124 未考虑用户同意(拒绝)的功能
        /// </summary>
        public void User_Edit()
        {
            int id = RequestTool.RequestInt("id", 0);
            Lebi_Supplier_User model = B_Lebi_Supplier_User.GetModel("Supplier_id=" + CurrentSupplier.id + " and id =" + id);

            if (model == null)
            {
                if (!Power("supplier_user_add", "添加用户"))
                {
                    AjaxNoPower();
                    return;
                }
                model = new Lebi_Supplier_User();
            }
            else
            {
                if (!Power("supplier_user_edit", "编辑用户"))
                {
                    AjaxNoPower();
                    return;
                }
            }
            string UserName = RequestTool.RequestSafeString("UserName");

            B_Lebi_Supplier_User.SafeBindForm(model);
            if (model.id == 0)
            {
                Lebi_User user = B_Lebi_User.GetModel("UserName=lbsql{'" + UserName + "'}");
                if (user == null)
                {
                    Response.Write("{\"msg\":\"" + Tag("用户不存在") + "\"}");
                    return;
                }
                int count = B_Lebi_Supplier_User.Counts("User_id=" + user.id + " and Supplier_id=" + CurrentSupplier.id + "");
                if (count > 0)
                {
                    Response.Write("{\"msg\":\"" + Tag("不能重复添加") + "\"}");
                    return;
                }
                model.User_id     = user.id;
                model.Supplier_id = CurrentSupplier.id;
                B_Lebi_Supplier_User.Add(model);
                model.id = B_Lebi_Supplier_User.GetMaxId();
                Log.Add("添加用户", "Supplier_User", model.id.ToString(), CurrentSupplier, "用户:" + CurrentUser.UserName);
            }
            else
            {
                if (model.User_id == CurrentSupplier.User_id)
                {
                    model.Type_id_SupplierUserStatus = 9011;//不能锁定所有者
                }
                B_Lebi_Supplier_User.Update(model);
                Log.Add("编辑用户", "Supplier_User", model.id.ToString(), CurrentSupplier, "用户:" + CurrentUser.UserName);
            }
            Response.Write("{\"msg\":\"OK\",\"id\":\"" + model.id + "\"}");
        }
Example #3
0
        /// <summary>
        /// 当前供应商用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static Lebi_Supplier_User CurrentSupplierUser(Lebi_User user)
        {
            Lebi_Supplier_User model       = null;
            string             supplierid_ = CookieTool.GetCookieString("supplier");
            int supplierid = 0;

            int.TryParse(supplierid_, out supplierid);
            if (supplierid > 0)
            {
                model = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011");
            }
            if (model == null)
            {
                model = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", "").FirstOrDefault();
            }
            if (model == null)
            {
                model = new Lebi_Supplier_User();
            }
            return(model);
        }
Example #4
0
        //public static bool CheckPower(string code, string name)
        //{
        //    if (!Power(code, name))
        //    {
        //        NoPower();
        //        return false;
        //    }
        //    return true;
        //}
        //public static void NoPower()
        //{
        //    HttpContext.Current.Response.Write("{\"msg\":\"权限不足\"}");
        //    HttpContext.Current.Response.End();
        //}
        #endregion

        /// <summary>
        /// 供应商账号登录
        /// </summary>
        /// <param name="user"></param>
        /// <param name="type">账号类型</param>
        /// <param name="supplierid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool Login(Lebi_User user, string type, int supplierid, out string msg, int adminlogin = 0)
        {
            msg = "OK";
            Lebi_Supplier_User supplieruser = null;
            Lebi_Supplier      supplier     = null;

            if (supplierid == 0)
            {
                string supplierid_ = CookieTool.GetCookieString("supplier");
                //int supplierid = 0;
                int.TryParse(supplierid_, out supplierid);
            }
            //string and = "";
            //if (type != "")
            //{
            //    and = " and Supplier_id in (select id from [Lebi_Supplier] where Supplier_Group_id in (select id from [Lebi_Supplier_Group] where type='" + type + "'))";
            //}
            if (supplierid > 0)
            {
                supplier = B_Lebi_Supplier.GetModel(supplierid);
                if (supplier != null)
                {
                    Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id);
                    if (group.type == type || type == "")
                    {
                        supplieruser = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011");
                    }
                }
            }
            if (supplieruser == null)
            {
                List <Lebi_Supplier_User> users = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", "");
                if (type == "")
                {
                    foreach (Lebi_Supplier_User u in users)
                    {
                        supplier = B_Lebi_Supplier.GetModel(u.Supplier_id);
                        if (supplier != null)
                        {
                            supplieruser = u;
                            break;
                        }
                    }
                    //supplieruser = users.FirstOrDefault();
                    //if (supplieruser == null)
                    //{
                    //    msg = "User_id = " + user.id + " and Type_id_SupplierUserStatus=9011";
                    //    return false;
                    //}
                    //supplier = B_Lebi_Supplier.GetModel(supplieruser.Supplier_id);
                }
                else
                {
                    foreach (Lebi_Supplier_User u in users)
                    {
                        supplier = B_Lebi_Supplier.GetModel(u.Supplier_id);
                        if (supplier == null)
                        {
                            continue;
                        }
                        Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id);
                        if (group.type == type)
                        {
                            supplieruser = u;
                            break;
                        }
                    }
                }
            }
            if (supplieruser == null)
            {
                Log.Add("登陆失败", "Login", "", supplier, "账号:" + user.UserName);
                msg = "登陆失败";
                return(false);
            }
            if (supplier == null)
            {
                Log.Add("登陆失败:账号不存在或不可用", "Login", "", supplier, "账号:" + user.UserName);
                msg = "账号不存在或不可用";
                return(false);
            }
            if (supplier.Type_id_SupplierStatus != 442)
            {
                Log.Add("登陆失败:供应商账号不可用", "Login", "", supplier, "账号:" + user.UserName);
                msg = "供应商账号不可用";
                return(false);
            }
            supplier.Time_Last = supplier.Time_This;
            supplier.Time_This = DateTime.Now;
            supplier.Count_Login++;
            supplier.IP_Last = supplier.IP_This;
            supplier.IP_This = RequestTool.GetClientIP();
            Shop.Tools.CookieTool.SetCookieString("supplier", supplier.id.ToString(), 60 * 24);
            B_Lebi_Supplier.Update(supplier);
            if (adminlogin == 0)
            {
                Log.Add("登陆系统", "Login", "", supplier, "账号:" + user.UserName);
            }
            return(true);
        }
Example #5
0
        /// <summary>
        /// 编辑商家
        /// </summary>
        public void User_Edit()
        {
            if (!EX_Admin.Power("supplier_user_edit", "编辑商家"))
            {
                AjaxNoPower();
                return;
            }
            int       id                  = RequestTool.RequestInt("id", 0);
            string    UserName            = RequestTool.RequestString("UserName");
            int       Level_id            = RequestTool.RequestInt("Level_id", 0);
            int       IsCash              = RequestTool.RequestInt("IsCash", 0);
            int       IsSupplierTransport = RequestTool.RequestInt("IsSupplierTransport", 0);
            Lebi_User user                = new Lebi_User();

            if (UserName != "")
            {
                user = B_Lebi_User.GetModel("UserName=lbsql{'" + UserName + "'}");
                if (user == null)
                {
                    Response.Write("{\"msg\":\"帐号不存在\"}");
                    return;
                }
                string where = "User_id='" + user.id + "'";
                if (id > 0)
                {
                    where += " and id!=" + id + "";
                }
                int count = B_Lebi_Supplier.Counts(where);
                if (count > 0)
                {
                    Response.Write("{\"msg\":\"此帐号已注册\"}");
                    return;
                }
            }
            if (IsCash == 1 && IsSupplierTransport == 0)
            {
                Response.Write("{\"msg\":\"独立收款的商家必须独立发货\"}");
                return;
            }
            Lebi_Supplier model = B_Lebi_Supplier.GetModel(id);

            //model.IsCash = 0;
            //model.IsSupplierTransport = 0;
            if (model == null)
            {
                model = new Lebi_Supplier();
            }
            B_Lebi_Supplier.SafeBindForm(model);
            model.Name              = Language.RequestString("Name");
            model.Description       = Language.RequestString("Description");
            model.ClassName         = Language.RequestString("ClassName");
            model.SEO_Title         = Language.RequestString("SEO_Title");
            model.SEO_Keywords      = Language.RequestString("SEO_Keywords");
            model.SEO_Description   = Language.RequestString("SEO_Description");
            model.Supplier_Group_id = Level_id;
            if (model.id == 0)
            {
                Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(Level_id);
                if (group != null)
                {
                    model.Supplier_Group_id = group.id;
                    model.Money_Service     = group.ServicePrice;
                    model.Money_Margin      = group.MarginPrice;
                    model.BillingDays       = group.BillingDays;
                }
                model.User_id  = user.id;
                model.UserName = user.UserName;
                B_Lebi_Supplier.Add(model);
                model.id = B_Lebi_Supplier.GetMaxId();
            }
            else
            {
                if (IsSupplierTransport != model.IsSupplierTransport)
                {
                    string sql = "update [Lebi_Order_Product] set IsSupplierTransport=" + model.IsSupplierTransport + " where Supplier_id=" + id + "";
                    Common.ExecuteSql(sql);
                    string sql2 = "update [Lebi_Product] set IsSupplierTransport=" + model.IsSupplierTransport + " where Supplier_id=" + id + "";
                    Common.ExecuteSql(sql2);
                }
                user = B_Lebi_User.GetModel(model.User_id);
                B_Lebi_Supplier.Update(model);
            }
            if (model.Type_id_SupplierStatus == 442)
            {
                try
                {
                    Lebi_Supplier_User suser = B_Lebi_Supplier_User.GetModel("User_id=" + model.User_id + " and Supplier_id=" + model.id + "");
                    if (suser == null)
                    {
                        suser            = new Lebi_Supplier_User();
                        suser.RemarkName = user.RealName;
                        if (suser.RemarkName == "")
                        {
                            suser.RemarkName = user.UserName;
                        }
                        suser.Supplier_id = model.id;
                        suser.User_id     = model.User_id;
                        suser.Type_id_SupplierUserStatus = 9011;
                        B_Lebi_Supplier_User.Add(suser);
                    }
                    else
                    {
                        suser.Supplier_id = model.id;
                        suser.User_id     = model.User_id;
                        suser.Type_id_SupplierUserStatus = 9011;
                        B_Lebi_Supplier_User.Update(suser);
                    }
                }
                catch
                { }
            }
            if (model.Domain != "")
            {
                ThemeUrl.CreateURLRewrite_shop();
            }
            if (model.Type_id_SupplierStatus == 444) //如果状态冻结 商品全部冻结 by lebi.kingdge 2015-02-09
            {
                string sql = "update [Lebi_Product] set Type_id_ProductStatus=103 where Supplier_id=" + id + "";
                Common.ExecuteSql(sql);
            }
            Log.Add("编辑商家信息", "Supplier_User", id.ToString(), CurrentAdmin, model.UserName);
            string result = "{\"msg\":\"OK\", \"id\":\"" + model.id + "\"}";

            Response.Write(result);
        }
Example #6
0
        /// <summary>
        /// 供应商登录
        /// </summary>
        public void User_Login()
        {
            string msg          = "";
            string userName     = RequestTool.RequestSafeString("userName");
            string UserPWD      = RequestTool.RequestSafeString("UserPWD");
            string code         = RequestTool.RequestString("code");
            string logintype    = RequestTool.RequestString("logintype", "supplier");
            int    saveusername = RequestTool.RequestInt("saveusername", 0);
            string loginerror   = "false";
            string Ststus       = "";

            if (SYS.Verifycode_SupplierLogin == "1")
            {
                try
                {
                    loginerror = (string)HttpContext.Current.Session["loginerror"];
                }
                catch
                {
                    loginerror = "false";
                }
                if (loginerror == "true")
                {
                    if (CurrentCheckCode != code)
                    {
                        Response.Write(Language.Tag("验证码错误", CurrentLanguage.Code));
                        return;
                    }
                }
            }
            //UserPWD = EX_Supplier.MD5(UserPWD);
            if (EX_User.UserLogin(userName, UserPWD))
            {
                Lebi_User CurrentUser = B_Lebi_User.GetModel("UserName=lbsql{'" + userName + "'}");
                if (EX_Supplier.Login(CurrentUser, logintype, 0, out msg))
                {
                    if (saveusername == 1)
                    {
                        Shop.Tools.CookieTool.SetCookieString("SupplierUserName", userName, 60 * 24);
                        Shop.Tools.CookieTool.SetCookieString("saveusername", "1", 60 * 24);
                    }
                    else
                    {
                        Shop.Tools.CookieTool.SetCookieString("SupplierUserName", "", -1);
                        Shop.Tools.CookieTool.SetCookieString("saveusername", "", -1);
                    }
                    Log.Add("登陆系统", "Login", CurrentUser.id.ToString(), CurrentUser.UserName);
                    Response.Write("OK");
                    return;
                }
                else
                {
                    Ststus = Language.Tag("未审核", CurrentLanguage.Code);
                    Lebi_Supplier_User model_supplier_user = B_Lebi_Supplier_User.GetList("User_id = " + CurrentUser.id + "", "").FirstOrDefault();
                    if (model_supplier_user != null)
                    {
                        switch (model_supplier_user.Type_id_SupplierUserStatus)
                        {
                        case 9010:
                            Ststus = Language.Tag("未审核", CurrentLanguage.Code);
                            break;

                        case 9012:
                            Ststus = Language.Tag("已停用", CurrentLanguage.Code);
                            break;
                        }
                    }
                    msg = Language.Tag("账号状态异常:", CurrentLanguage.Code) + Ststus;
                }
            }
            else
            {
                msg = Language.Tag("用户名或密码错误", CurrentLanguage.Code);
                if (SYS.Verifycode_SupplierLogin == "1")
                {
                    HttpContext.Current.Session["loginerror"] = "true";
                }
                Log.Add("登陆系统", "Login", "", CurrentUser, "[" + userName + "]用户名或密码错误");
            }
            Response.Write(msg);
        }
Example #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Supplier_User model)
 {
     D_Lebi_Supplier_User.Instance.Update(model);
 }
Example #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Supplier_User model)
 {
     return(D_Lebi_Supplier_User.Instance.Add(model));
 }
Example #9
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Supplier_User SafeBindForm(Lebi_Supplier_User model)
 {
     return(D_Lebi_Supplier_User.Instance.SafeBindForm(model));
 }