Beispiel #1
0
    public void DataBinds()
    {
        int pageCount = 0;
        int Counts    = 0;

        //每页显示的数据设置
        if (this.txtPageSize.Value.ToString() != "")
        {
            if (this.txtPageSize.Value.Trim().Length >= 5)
            {
                Pager.PageSize         = 100;
                this.txtPageSize.Value = "100";
            }
            else
            {
                Pager.PageSize = this.txtPageSize.Value.Trim().ToInt(0);
            }
        }

        List <Hi.Model.BD_DisType> LType = new Hi.BLL.BD_DisType().GetList(Pager.PageSize, Pager.CurrentPageIndex, " Id", false, " and CompID=" + CompID + " and isnull(ParentId,0)=0 and isnull(dr,0)=0 ", out pageCount, out Counts);

        LType = LType.OrderBy(L => L.SortIndex).ToList();
        this.rptDisTypeList.DataSource = LType;
        this.rptDisTypeList.DataBind();
        Pager.RecordCount = Counts;
        page = Pager.CurrentPageIndex.ToString();
    }
Beispiel #2
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        List <Hi.Model.BD_Distributor> dis = new Hi.BLL.BD_Distributor().GetList("", " Compid=" + CompID + "", "");

        foreach (Hi.Model.BD_Distributor model in dis)
        {
            new Hi.BLL.BD_Distributor().Delete(model.ID);
            List <Hi.Model.BD_DisAddr> Daddr = new Hi.BLL.BD_DisAddr().GetList("", " disid='" + model.ID + "'", "");
            foreach (Hi.Model.BD_DisAddr mo in Daddr)
            {
                new Hi.BLL.BD_DisAddr().Delete(mo.ID);
            }
            List <Hi.Model.SYS_Users> user = new Hi.BLL.SYS_Users().GetList("", " disid='" + model.ID + "' and type=5", "");
            foreach (Hi.Model.SYS_Users mo in user)
            {
                new Hi.BLL.SYS_Users().Delete(mo.ID);
            }
        }
        List <Hi.Model.BD_DisType> Dtype = new Hi.BLL.BD_DisType().GetList("", " Compid=" + CompID + "", "");

        foreach (Hi.Model.BD_DisType model in Dtype)
        {
            new Hi.BLL.BD_DisType().Delete(model.ID);
        }
    }
Beispiel #3
0
    public string DelType(string id)
    {
        string json = string.Empty;

        if (!string.IsNullOrEmpty(id))
        {
            List <Hi.Model.BD_DisType> List = new Hi.BLL.BD_DisType().GetList(null, " CompID=" + CompID + " and isnull(dr,0)=0  and  ParentId=" + id, null);
            if (List.Count > 0)
            {
                return("{\"result\":false,\"code\":\"此类别下还有子级类别,请先删除子级类别!\"}");
            }
            List <Hi.Model.BD_Distributor> Dis = new Hi.BLL.BD_Distributor().GetList(null, " CompID=" + CompID + " and isnull(dr,0)=0  and   DisTypeID=" + id, null);
            if (Dis.Count > 0)
            {
                return("{\"result\":false,\"code\":\"此分类已被使用,不允许删除!\"}");
            }
            List <Hi.Model.BD_DisPrice> disp = new Hi.BLL.BD_DisPrice().GetList(null, " CompID=" + CompID + " and type=" + 1 + " and( One=" + id + " or two=" + id + " or three=" + id + ") and dr=0", null);
            if (disp.Count > 0)
            {
                return("{\"result\":false,\"code\":\"此区域下有代理商价格,不允许删除!\"}");
            }

            Hi.Model.BD_DisType type = new Hi.BLL.BD_DisType().GetModel(id.ToInt(0));
            type.dr         = 1;
            type.ts         = DateTime.Now;
            type.modifyuser = UserID;
            if (new Hi.BLL.BD_DisType().Update(type))
            {
                return("{\"result\":true,\"code\":\"操作成功\"}");
            }
        }
        return(json);
    }
Beispiel #4
0
    public string grtdistype(int CompID)
    {
        StringBuilder sb = new StringBuilder();

        List <Hi.Model.BD_DisType> tl = new Hi.BLL.BD_DisType().GetList("", " CompID=" + CompID + " and isnull(IsEnabled,0)=0 and isnull(dr,0)=0", "");

        if (tl != null && tl.Count > 0)
        {
            //代理商分类一级
            List <Hi.Model.BD_DisType> tl1 = tl.FindAll(p => p.ParentId == 0);

            if (tl1 != null && tl1.Count > 0)
            {
                sb.Append("<div class=\"sorts\">");

                sb.AppendFormat("<div class=\"sorts1\"><i class=\"arrow2\"></i><a href=\"javascript:;\" class=\"a1\" tip=\"\">{0}</a></div>", "全部");
                sb.Append("</div>");

                foreach (var item in tl1)
                {
                    sb.Append("<div class=\"sorts\">");
                    sb.AppendFormat("<div class=\"sorts1\"><i class=\"arrow2\"></i><a href=\"javascript:;\" class=\"a1\" tip=\"{1}\">{0}</a></div>", item.TypeName, item.ID);

                    //代理商分类二级
                    List <Hi.Model.BD_DisType> tl2 = tl.FindAll(p => p.ParentId == item.ID);
                    if (tl2 != null && tl2.Count > 0)
                    {
                        sb.Append("<ul class=\"sorts2\" tipdis=\"no\" style=\"display:none;\">");
                        foreach (var item2 in tl2)
                        {
                            sb.Append("<li>");
                            sb.AppendFormat("<i class=\"arrow3\"></i><a href=\"javascript:;\" class=\"a1\"  tip=\"{1}\">{0}</a>", item2.TypeName, item2.ID);
                            //代理商分类三级
                            List <Hi.Model.BD_DisType> tl3 = tl.FindAll(p => p.ParentId == item2.ID);

                            if (tl3 != null && tl3.Count > 0)
                            {
                                sb.Append("<ul class=\"sorts3\" tipdis=\"no\" style=\"display:none;\">");
                                foreach (var item3 in tl3)
                                {
                                    sb.AppendFormat("<li><a href=\"javascript:;\" tip=\"{1}\">{0}</a></li>", item3.TypeName, item3.ID);
                                }
                                sb.Append("</ul>");
                            }
                            sb.Append("</li>");
                        }
                        sb.Append("</ul>");
                    }
                    sb.Append("</div>");
                }
            }
        }

        return(sb.ToString());
    }
Beispiel #5
0
    public void TreeData(int ParentId, string str = "")
    {
        chidString = str;
        List <Hi.Model.BD_DisType> list = new Hi.BLL.BD_DisType().GetList(null, "  CompID=" + Compid.ToInt(0) + "  and isnull(dr,0)=0  and ParentId=" + ParentId.ToString(), "sortindex");

        foreach (Hi.Model.BD_DisType item in list)
        {
            chidString += "{ id :" + item.ID + ",pId:" + ParentId + ",name:\"" + item.TypeName + "\",isParent:\"" + (ParentId == 0 ? "true" : "false") + "\"},";
            TreeData(item.ID, chidString);
        }
    }
Beispiel #6
0
    /// <summary>
    /// 判断属性值是否存在
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    public bool IsExistsType(string name, string value, string id)
    {
        bool bfg = false;

        if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(value))
        {
            List <Hi.Model.BD_DisType> List = new Hi.BLL.BD_DisType().GetList("", name + "='" + value + "' and id<>'" + id + "' and CompID=" + CompID + " and isnull(dr,0)=0", "");
            if (List.Count > 0)
            {
                bfg = true;
            }
        }
        return(bfg);
    }
Beispiel #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!string.IsNullOrEmpty(id))
         {
             Hi.Model.BD_DisType type = new Hi.BLL.BD_DisType().GetModel(id.ToInt(0));
             if (type != null)
             {
                 txt_txtTypename.Value = type.TypeName;
                 hid_TypeId.Value      = id;
             }
         }
     }
 }
Beispiel #8
0
    public bool CheckDisCategory(string value, int index, out int typeID)
    {
        List <Hi.Model.BD_DisType> disList = new Hi.BLL.BD_DisType().GetList("", " CompId=" + CompID + " and TypeName='" + value + "' and IsEnabled = 0 and dr =0", "");

        if (disList != null && disList.Count == 1)
        {
            typeID = disList[0].ID;
            return(true);
        }
        else
        {
            Eroor       = true;
            TitleError += "Excel行号为:&nbsp;<i error>" + (index + TitleIndex + 1) + "</i> &nbsp;&nbsp;的数据有误。代理商分类:“" + value + "”错误!请修改后重新导入。<br/>";
            typeID      = 0;
            return(false);
        }
    }
Beispiel #9
0
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        string Typename = Common.NoHTML(txtTypeNames.Value.Trim());
        string id       = Common.NoHTML(hideTypeIds.Value.Trim());
        //string sortid = txtSortIndexs.Value.Trim();
        //string typecode = txtTypecodes.Value.Trim();
        int Result = 0;

        if (string.IsNullOrEmpty(Typename))
        {
            JScript.AlertMethod(this, "分类名称不能为空", JScript.IconOption.错误, "function (){ location.replace('" + ("DisTypeList.aspx?page=" + Pager.CurrentPageIndex + "") + "'); }");
            return;
        }
        if (IsExistsType("TypeName", Typename, id))
        {
            JScript.AlertMethod(this, "此分类名已存在", JScript.IconOption.错误, "function (){ location.replace('" + ("DisTypeList.aspx?page=" + Pager.CurrentPageIndex + "") + "'); }");
            return;
        }
        if (int.TryParse(id, out Result))
        {
            Hi.Model.BD_DisType DisType = new Hi.BLL.BD_DisType().GetModel(Result);
            if (DisType != null)
            {
                DisType.TypeName = Typename;
                //DisType.SortIndex = sortid;
                //DisType.TypeCode = typecode;
                DisType.ts         = DateTime.Now;
                DisType.modifyuser = 0;
                if (new Hi.BLL.BD_DisType().Update(DisType))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Result2", "<script>location.href='DisTypeList.aspx?page=" + Pager.CurrentPageIndex + "&lefttype=" + Request["lefttype"] + "&type=" + Request["type"] + "';</script>");
                }
            }
            else
            {
                JScript.AlertMethod(this, "此分类不存在", JScript.IconOption.错误, "function (){ location.replace('" + ("DisTypeList.aspx?page=" + Pager.CurrentPageIndex + "") + "'); }");
                return;
            }
        }
        else
        {
            JScript.AlertMethod(this, "分类ID错误", JScript.IconOption.错误, "function (){ location.replace('" + ("DisTypeList.aspx?page=" + Pager.CurrentPageIndex + "") + "'); }");
            return;
        }
    }
Beispiel #10
0
    /// <summary>
    /// 最新 的排序号
    /// </summary>
    /// <returns></returns>
    public static int NewCateId()
    {
        List <int> intList = new List <int>();
        List <Hi.Model.BD_DisType> goodsCategoryList = new Hi.BLL.BD_DisType().GetAllList();

        if (goodsCategoryList != null && goodsCategoryList.Count > 0)
        {
            foreach (var item in goodsCategoryList)
            {
                intList.Add(Convert.ToInt32(string.IsNullOrEmpty(item.SortIndex) ? "0" : item.SortIndex));
            }
            return(intList.Max() != 0 ? intList.Max() + 1 : 1000);
        }
        else
        {
            return(1000);
        }
    }
Beispiel #11
0
    protected string Simage(object obj)
    {
        string image = "../images/menu_plus.gif";

        if (obj != null)
        {
            List <Hi.Model.BD_DisType> l = new Hi.BLL.BD_DisType().GetList(null, " CompID='" + CompID + "' and isnull(dr,0)=0 and  ParentId=" + obj.ToString(), null);
            if (l.Count > 0)
            {
                image = "../images/menu_plus.gif";
            }
            else
            {
                image = "../images/menu_minus.gif";
            }
            return(image);
        }
        return(image);
    }
Beispiel #12
0
    /// <summary>
    /// 查询父类下所有子集
    /// </summary>
    /// <param name="ParentId">父Id</param>
    /// <returns></returns>
    public string FindChild(string ParentId, string Str = "")
    {
        ChildString = Str;
        List <Hi.Model.BD_DisType> LType = new Hi.BLL.BD_DisType().GetList("", "  CompID=" + CompID + " and ParentId='" + ParentId + "' and isnull(dr,0)=0", " sortindex asc");

        foreach (Hi.Model.BD_DisType model in LType)
        {
            ChildString += "<tr id='" + model.ID + "' parentid='" + model.ParentId + "' bgcolor='#fcfeff' style='height: 26px;width: 100%;display: none;'>";
            ChildString += "<td> <div class=\"tcle\"><img id='Openimg' height='9' src='" + Simage(model.ID) + "' width='9' border='0' />&nbsp; <span class='span'>" + model.TypeName + "</span></div></td>";

            ChildString += Str == "" ? "<td><div class=\"tcle\"> <a href='javascript:;' tip='" + model.ID + "' Pname='" + model.TypeName + @"' class='TypeChildAdd'>添加下级</a> | " : "<td><div class=\"tcle\"> ";

            ChildString += "<a class='TypeEdit' href='javascript:;' tip='" + model.ID + "' sortid ='" + model.SortIndex + "'   Pname='" + model.TypeName + @"' >编辑</a> |
                <a href='javascript:;'  tip='" + model.ID + @"'  class='TypeDel'>移除</a>
                </div></td>";
            ChildString += "</tr>";
            FindChild(model.ID.ToString(), ChildString);
        }
        return(ChildString);
    }
Beispiel #13
0
    public string page = "1";//默认初始页
    protected void Page_Load(object sender, EventArgs e)
    {
        List <Hi.Model.BD_DisType> list = new Hi.BLL.BD_DisType().GetAllList();

        if (list != null && list.Count > 0)
        {
            foreach (var type in list)
            {
                if (string.IsNullOrEmpty(type.SortIndex) || Convert.ToInt32(type.SortIndex) < 1000)
                {
                    type.SortIndex  = NewCateId().ToString();
                    type.ts         = DateTime.Now;
                    type.modifyuser = UserID;
                    new Hi.BLL.BD_DisType().Update(type);
                }
            }
        }

        if (!IsPostBack)
        {
            if (Request.Form["Action"] != null)
            {
                if (Request.Form["Action"] == "Del")
                {
                    Response.Write(DelType(Request.Form["Id"]));
                    Response.End();
                }
            }
            if (Request.QueryString["page"] != null)
            {
                page = Request.QueryString["page"].ToString();
                Pager.CurrentPageIndex = Convert.ToInt32(page);
            }
            DataBinds();
        }
    }
Beispiel #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((HttpContext.Current.Session["UserModel"] as LoginModel) != null)
        {
            CompID = (HttpContext.Current.Session["UserModel"] as LoginModel).CompID;
        }

        object obj2 = Request["action"];

        if (obj2 != null)
        {
            if (obj2.ToString() == "yanz")//验证是否还存在下级分类
            {
                int id = 0;
                if (Request["id"] != null)
                {
                    id = Convert.ToInt32(Request["id"]);
                }
                Response.Write(GetMinCategory(id));
                Response.End();
            }
        }
        if (!IsPostBack)
        {
            object obj = Request.QueryString["type"];
            if (obj != null)
            {
                type = obj.ToString();
                if (!Util.IsEmpty(type))
                {
                    if (Request.QueryString["disId"] != null)
                    {
                        disID = Request.QueryString["disId"];
                    }
                    else
                    {
                        disID = "0";
                    }

                    if (type == "1")//商品分类
                    {
                        IsExepand = Common.RsertFolding(type, CompID);
                        string strwhere = string.Empty;
                        List <Hi.Model.SYS_GType> FindList = new List <Hi.Model.SYS_GType>();
                        List <Hi.Model.SYS_GType> l        = new Hi.BLL.SYS_GType().GetList("id,TypeName,ParentId", "isnull(dr,0)=0 and isenabled=1 ", " id");
                        if (string.IsNullOrWhiteSpace(Request["val"]))
                        {
                            FindList = l.Where(T => T.ParentId == 0).ToList();
                        }
                        else
                        {
                            string SearchValue = Request["val"].Replace("'", "''");
                            List <Hi.Model.SYS_GType> ParentList = new List <Hi.Model.SYS_GType>();
                            strwhere += " isnull(dr,0)=0 and isenabled=1 and TypeName like '%" + SearchValue + "%'";
                            FindList  = new Hi.BLL.SYS_GType().GetList("id,TypeName,ParentId", strwhere, " id");
                            foreach (Hi.Model.SYS_GType model in FindList)
                            {
                                //string NewName = model.CategoryName.Replace(SearchValue, "<i style='color:red'>" + SearchValue + "</i>");
                                string NewName     = model.TypeName;
                                var    ParentModel = l.Where(T => T.ID == model.ParentId).ToList();
                                if (ParentModel.Count > 0)
                                {
                                    NewName = ParentModel[0].TypeName + " > " + NewName;
                                }
                                model.TypeName = NewName;
                                ParentList.Add(model);
                            }
                            FindList = ParentList;
                        }
                        if (l.Count > 0 && FindList.Count > 0)
                        {
                            BindHTML(l, FindList, type);
                        }
                    }
                    else if (type == "2")//代理商区域
                    {
                        List <Hi.Model.BD_DisArea> FindList = new List <Hi.Model.BD_DisArea>();
                        List <Hi.Model.BD_DisArea> ll       = new Hi.BLL.BD_DisArea().GetList("id,AreaName,ParentId", "CompanyID=" + this.CompID + " and isnull(dr,0)=0 ", "");
                        FindList = ll.Where(T => T.ParentID == 0).ToList();
                        if (ll.Count > 0 && FindList.Count > 0)
                        {
                            BindHTML(ll, FindList, type);
                        }
                    }
                    else if (type == "3")//代理商分类
                    {
                        List <Hi.Model.BD_DisType> FindList = new List <Hi.Model.BD_DisType>();
                        List <Hi.Model.BD_DisType> lll      = new Hi.BLL.BD_DisType().GetList("id,ParentId,TypeName", "compid=" + this.CompID + " and isnull(dr,0)=0 ", "");
                        FindList = lll.Where(T => T.ParentId == 0).ToList();
                        if (lll.Count > 0 && FindList.Count > 0)
                        {
                            BindHTML(lll, FindList, type);
                        }
                    }
                    else if (type == "4")//代理商地址
                    {
                        List <Hi.Model.BD_DisAddr> llll = new Hi.BLL.BD_DisAddr().GetList("id,Address", "disid=" + disID + " and isnull(dr,0)=0", "");
                        if (llll.Count > 0)
                        {
                            BindHTML(llll, llll, type);
                        }
                    }
                    else if (type == "5")
                    {//代理商管理员
                        List <Hi.Model.BD_Distributor> lllll = new Hi.BLL.BD_Distributor().GetList("id,DisName", "compid=" + this.CompID + " and isnull(dr,0)=0", "Id desc");
                        if (lllll.Count > 0)
                        {
                            BindHTML(lllll, lllll, type);
                        }
                    }
                    else if (type == "6")
                    {//代理商管理员
                        List <Hi.Model.BD_Distributor> lllll = new Hi.BLL.BD_Distributor().GetList("id,DisName", "compid=" + this.CompID + " and isnull(dr,0)=0 and AuditState=2 and IsEnabled=1", "Id asc");
                        if (lllll.Count > 0)
                        {
                            BindHTML(lllll, lllll, type);
                        }
                    }
                }
            }
        }
    }
Beispiel #15
0
    /// <summary>
    /// 通过OpenID获取经销商个人信息
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ResultDisInfo GetUserInfo(string JSon)
    {
        try
        {
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count == 0 && JInfo["OpenID"].ToString().Trim() == "")
            {
                return(new ResultDisInfo()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            Hi.Model.SYS_Users user = new Common().GetUserByOpenID(JInfo["OpenID"].ToString());
            if (user == null || user.IsEnabled == 0 || user.dr == 1)
            {
                return new ResultDisInfo()
                       {
                           Result = "T", Description = "用户异常"
                       }
            }
            ;
            Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(JInfo["DisID"].ToString()));
            if (dis == null || dis.IsEnabled == 0 || dis.dr == 1)
            {
                return new ResultDisInfo()
                       {
                           Result = "T", Description = "经销商异常"
                       }
            }
            ;
            Hi.Model.BD_DisType disType = new Hi.BLL.BD_DisType().GetModel(dis.DisTypeID);
            string DisTypeName          = string.Empty;
            if (disType != null)
            {
                DisTypeName = disType.TypeName;
            }
            Hi.Model.BD_DisArea area = new Hi.BLL.BD_DisArea().GetModel(dis.AreaID);
            string AreaName          = string.Empty;
            if (area != null)
            {
                AreaName = area.AreaName;
            }
            return(new ResultDisInfo()
            {
                Result = "T",
                Description = "获取成功",
                DisName = dis.DisName,
                DisTypeName = DisTypeName,
                AreaName = AreaName,
                DisPrincipal = dis.Principal,
                DisPhone = dis.Phone,
                IsCheck = dis.IsCheck.ToString(),
                CreditType = dis.CreditType.ToString(),
                UserName = user.UserName,
                UserSex = user.Sex,
                UserPhone = user.Phone,
                PrePaymentMoney = new Hi.BLL.PAY_PrePayment().sums(dis.ID, dis.CompID).ToString()
            });
        }
        catch
        {
            Common.CatchInfo(JSon, "GetResellerInfo");
            return(new ResultDisInfo()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }
Beispiel #16
0
    /// <summary>
    /// 获取经销商详情
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ResultResellerDetail GetResellerDetail(string JSon)
    {
        string UserID = string.Empty;
        string CompID = string.Empty;
        string DisID  = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompID"].ToString().Trim() == "" || JInfo["ResellerID"].ToString().Trim() == "")
            {
                return new ResultResellerDetail()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;
            UserID = JInfo["UserID"].ToString();
            CompID = JInfo["CompID"].ToString();
            DisID  = JInfo["ResellerID"].ToString();
            //判断登录信息是否异常
            Hi.Model.SYS_Users one = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out one, Int32.Parse(CompID)))
            {
                return(new ResultResellerDetail()
                {
                    Result = "F", Description = "登录信息异常"
                });
            }
            //判断核心企业信息是否异常
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Int32.Parse(CompID));
            if (comp == null || comp.dr == 1 || comp.IsEnabled == 0 || comp.AuditState == 0)
            {
                return new ResultResellerDetail()
                       {
                           Result = "F", Description = "核心企业信息异常"
                       }
            }
            ;
            //判断经销商信息是否异常
            Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(Int32.Parse(DisID));
            if (dis == null)
            {
                return new ResultResellerDetail()
                       {
                           Result = "F", Description = "经销商信息异常"
                       }
            }
            ;
            if (dis.dr == 1)
            {
                return new ResultResellerDetail()
                       {
                           Result = "F", Description = "经销商已被删除"
                       }
            }
            ;
            if (dis.AuditState == 0)
            {
                return new ResultResellerDetail()
                       {
                           Result = "F", Description = "经销商未审核"
                       }
            }
            ;
            #endregion
            //获取经销商的返回信息
            class_ver3.Reseller res = new class_ver3.Reseller();
            res.ResellerID   = dis.ID.ToString();
            res.ResellerName = dis.DisName;
            //拼接经销商地址
            string area = string.Empty;
            area += dis.Province;
            if (dis.City != "市辖区")
            {
                area += dis.City;
            }
            area                  += dis.Area;
            area                  += dis.Address;
            res.ResellerAddr       = area;
            res.ResellerProvince   = dis.Province;
            res.ResellerCity       = dis.City;
            res.ResellerArea       = dis.Area;
            res.Address            = dis.Address;
            res.ResellerCode       = dis.DisCode;
            res.ResellerClassifyID = dis.DisTypeID.ToString();
            //根据经销商分类ID获取分类名称
            Hi.Model.BD_DisType dis_type = new Hi.BLL.BD_DisType().GetModel(dis.DisTypeID);
            if (dis_type != null)
            {
                res.ResellerClassify = dis_type.TypeName;
            }
            else
            {
                res.ResellerClassify = "";
            }
            res.Zip       = dis.Zip;
            res.Tel       = dis.Tel;
            res.Fax       = dis.Fax;
            res.Principal = dis.Principal;
            res.Phone     = dis.Phone;
            res.AreaID    = dis.AreaID.ToString();
            //根据经销商区域ID获取区域名称
            Hi.Model.BD_DisArea dis_area = new Hi.BLL.BD_DisArea().GetModel(dis.AreaID);
            if (dis_area != null)
            {
                res.AreaName = dis_area.AreaName;
            }
            else
            {
                res.AreaName = "";
            }
            res.IsEnabled = dis.IsEnabled.ToString();
            res.ts        = dis.ts.ToString();
            #region //获取此经销商的开票信息
            List <Hi.Model.BD_DisAccount> list_disinvoce = new Hi.BLL.BD_DisAccount().GetList("", "DisID=" + dis.ID + " and isnull(dr,0)=0", "CreateDate desc");
            List <class_ver3.Invoce>      list_invoce    = new List <class_ver3.Invoce>();
            if (list_disinvoce != null && list_disinvoce.Count > 0)
            {
                //循环赋值开票信息的返回信息
                foreach (Hi.Model.BD_DisAccount dis_invoce in list_disinvoce)
                {
                    class_ver3.Invoce invoce = new class_ver3.Invoce();
                    invoce.InvoceID   = dis_invoce.ID.ToString();
                    invoce.TRNumber   = ClsSystem.gnvl(dis_invoce.TRNumber, "");
                    invoce.InvoceType = invoce.TRNumber == "" ? "普通发票" : "增值税发票";
                    invoce.Rise       = dis_invoce.Rise;
                    invoce.Content    = dis_invoce.Content;
                    invoce.OBank      = dis_invoce.OBank;
                    invoce.OAccount   = dis_invoce.OAccount;
                    list_invoce.Add(invoce);
                }
            }
            #endregion

            #region//获取经销商的管理员登录账号
            //先从SYS_CompUser表中取出对应sys_user表的ID
            List <Hi.Model.SYS_CompUser> list_compuser = new Hi.BLL.SYS_CompUser().GetList("UserID",
                                                                                           "DisID=" + dis.ID + " and UType = 5 and isnull(dr,0)=0 and isnull(IsEnabled,0)=1 and isnull(IsAudit,0)=2", "");
            //根据userid取出sys_user表数据,赋值给返回信息
            Hi.Model.SYS_Users user    = new Hi.BLL.SYS_Users().GetModel(list_compuser[0].UserID);
            class_ver3.Account account = new class_ver3.Account();
            if (user != null && user.AuditState == 2 && user.IsEnabled == 1 && user.dr == 0)
            {
                account.AccountID = user.ID.ToString();
                account.UserName  = user.UserName;
                account.TrueName  = user.TrueName;
                account.Phone     = user.Phone;
                account.ts        = user.ts.ToString();
            }
            #endregion
            res.InvoceList = list_invoce;
            res.Account    = account;


            string  sqlstr = string.Format(@"select b.DisID, a.type, a.validDate, a.fileName 
                    from YZT_Annex a, YZT_FCmaterials b where b.dr=0 and a.dr=0 and
                    b.DisID={0} and b.ID=a.fcID and a.fileAlias=4", DisID);
            DataSet ds     = SqlHelper.Query(SqlHelper.LocalSqlServer, sqlstr);
            if (ds.Tables.Count > 0)
            {
                List <class_ver3.FCMaterial> materials = new List <class_ver3.FCMaterial>();
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    class_ver3.FCMaterial fcMaterial = new class_ver3.FCMaterial();

                    fcMaterial.category  = Common.GetAnnexDescription(SqlHelper.GetInt(r["type"]));
                    fcMaterial.validDate = SqlHelper.GetString(r["validDate"]);

                    DateTime expireDate = SqlHelper.GetDateTime(r["validDate"]);
                    if (expireDate != null && !string.IsNullOrEmpty(fcMaterial.validDate))
                    {
                        fcMaterial.dateDiff = (expireDate - DateTime.Now).Days;
                    }

                    fcMaterial.fileUrl = SqlHelper.GetString(r["fileName"]);
                    if (!string.IsNullOrEmpty(fcMaterial.fileUrl))
                    {
                        fcMaterial.fileUrl = ConfigurationManager.AppSettings["OssImgPath"] + "/UploadFile/" + fcMaterial.fileUrl;
                    }
                    fcMaterial.DisID = SqlHelper.GetInt(r["DisID"]);
                    materials.Add(fcMaterial);
                }
                res.FCMaterialList = materials;
            }

            return(new ResultResellerDetail()
            {
                Result = "T", Description = "获取成功", Reseller = res
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetResellerDetail:" + JSon);
            return(new ResultResellerDetail()
            {
                Result = "F", Description = "获取失败"
            });
        }
    }
Beispiel #17
0
    /// <summary>
    /// 获取经销商分类列表
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ResultResellerClassify GetResellerClassifyList(string JSon)
    {
        string UserID = string.Empty;
        string CompID = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompID"].ToString().Trim() == "")
            {
                return new ResultResellerClassify()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;
            UserID = JInfo["UserID"].ToString();
            CompID = JInfo["CompID"].ToString();
            //判断登录信息是否正确
            Hi.Model.SYS_Users one = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out one, Int32.Parse(CompID)))
            {
                return(new ResultResellerClassify()
                {
                    Result = "F", Description = "登录信息异常"
                });
            }
            //判断核心企业信息是否异常
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Int32.Parse(CompID));
            if (comp == null || comp.dr == 1 || comp.IsEnabled == 0 || comp.AuditState == 0)
            {
                return new ResultResellerClassify()
                       {
                           Result = "F", Description = "核心企业信息异常"
                       }
            }
            ;
            #endregion
            //获取对应核心企业的经销商分类列表
            List <Hi.Model.BD_DisType> list_distype = new Hi.BLL.BD_DisType().GetList("", "CompID = " + CompID + " and isnull(dr,0)=0 ", "SortIndex");
            if (list_distype != null && list_distype.Count > 0)
            {
                //循环经销商分类列表,将值赋给返回参数
                List <class_ver3.ResellerClassify> list_resellerclassify = new List <class_ver3.ResellerClassify>();

                class_ver3.ResellerClassify resellerclassify = null;
                foreach (Hi.Model.BD_DisType distype in list_distype)
                {
                    resellerclassify              = new class_ver3.ResellerClassify();
                    resellerclassify.ClassifyID   = distype.ID.ToString();
                    resellerclassify.ClassifyName = distype.TypeName;
                    resellerclassify.ClassifyCode = ClsSystem.gnvl(distype.TypeCode, "");
                    resellerclassify.ParentID     = distype.ParentId.ToString();
                    resellerclassify.SortIndex    = distype.SortIndex.ToString();
                    resellerclassify.Remark       = ClsSystem.gnvl(distype.Remark, "");
                    list_resellerclassify.Add(resellerclassify);
                }
                return(new ResultResellerClassify()
                {
                    Result = "T", Description = "获取成功", ResellerClassifyList = list_resellerclassify
                });
            }
            return(new ResultResellerClassify()
            {
                Result = "T", Description = "获取成功"
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetResellerClassifyList:" + JSon);
            return(new ResultResellerClassify()
            {
                Result = "F", Description = "获取失败"
            });
        }
    }
Beispiel #18
0
    /// <summary>
    ///核心企业新增经销商
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ReseltResellerEdit AddReseller(string JSon)
    {
        string UserID = string.Empty;
        string CompID = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompID"].ToString().Trim() == "" || JInfo["Reseller"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;
            UserID = JInfo["UserID"].ToString();
            CompID = JInfo["CompID"].ToString();
            JsonData Reseller = JInfo["Reseller"];
            //判断登录信息是否异常
            Hi.Model.SYS_Users one = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out one, Int32.Parse(CompID)))
            {
                return(new ReseltResellerEdit()
                {
                    Result = "F", Description = "登录信息异常"
                });
            }
            //判断核心企业信息是否异常
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Int32.Parse(CompID));
            if (comp == null || comp.dr == 1 || comp.IsEnabled == 0 || comp.AuditState == 0)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "核心企业信息异常"
                       }
            }
            ;
            #endregion
            #region//判断传入的经销商信息是否正确
            string resellername = Common.NoHTML(Reseller["ResellerName"].ToString().Trim());
            string resellercode = Common.NoHTML(Reseller["ResellerCode"].ToString().Trim());
            string address      = Common.NoHTML(Reseller["Address"].ToString().Trim());
            if (resellername == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商名称"
                       }
            }
            ;
            //判断经销商名字是否已存在
            if (Common.DisExistsAttribute("DisName", resellername, CompID.ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商名称已经存在"
                       }
            }
            ;
            if (Reseller["ResellerProvince"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的省"
                       }
            }
            ;
            if (Reseller["ResellerCity"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的市"
                       }
            }
            ;
            if (Reseller["ResellerArea"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的区"
                       }
            }
            ;
            if (address == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商地址中的详细地址"
                       }
            }
            ;
            #endregion
            #region//判断登录信息的正确信
            JsonData account  = Reseller["Account"];
            string   username = Common.NoHTML(account["UserName"].ToString().Trim());
            string   truename = Common.NoHTML(account["TrueName"].ToString().Trim());
            if (account["UserName"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入登录账号"
                       }
            }
            ;
            //判断登录账号是否已经存在
            if (Common.GetUserExists(username))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "该登录账号已存在"
                       }
            }
            ;
            if (truename == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入姓名"
                       }
            }
            ;
            if (account["Phone"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请登录信息中的手机号码"
                       }
            }
            ;
            //判断手机号有没被注册过
            Regex Phonereg = new Regex("^0?(13[0-9]|15[012356789]|18[0-9]|14[57]|17[7])[0-9]{8}$");
            if (!Phonereg.IsMatch(account["Phone"].ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "登录信息中的手机号格式错误"
                       }
            }
            ;
            if (Common.GetUserExists("Phone", account["Phone"].ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "登录信息中的手机号已被注册"
                       }
            }
            ;
            #endregion
            //创建需要导入的经销商实体
            Hi.Model.BD_Distributor disModel = new Hi.Model.BD_Distributor();
            disModel.CompID  = comp.ID;
            disModel.DisCode = resellercode;
            disModel.DisName = resellername;
            //传入分类ID的话,判断分类ID是否正确
            if (Reseller["ResellerClassifyID"].ToString().Trim() != "" && Reseller["ResellerClassifyID"].ToString() != "0")
            {
                Hi.Model.BD_DisType distpye = new Hi.BLL.BD_DisType().GetModel(Int32.Parse(Reseller["ResellerClassifyID"].ToString().Trim()));

                if (distpye == null || distpye.CompID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商分类异常"
                           }
                }
                ;
                if (distpye.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商分类已被删除"
                           }
                }
                ;
                //if (distpye.IsEnabled != 0)
                //    return new ReseltResellerEdit() { Result = "F", Description = "此经销商分类已被禁用" };

                disModel.DisTypeID = distpye.ID;
            }
            else
            {
                disModel.DisTypeID = 0;
            }
            //传入区域ID的话,判断区域ID是否正确
            if (Reseller["AreaID"].ToString().Trim() != "" && Reseller["AreaID"].ToString() != "0")
            {
                Hi.Model.BD_DisArea disarea = new Hi.BLL.BD_DisArea().GetModel(Int32.Parse(Reseller["AreaID"].ToString().Trim()));
                if (disarea == null || disarea.CompanyID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商区域异常"
                           }
                }
                ;
                if (disarea.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商区域已被删除"
                           }
                }
                ;
                disModel.AreaID = disarea.ID;
            }
            else
            {
                disModel.AreaID = 0;
            }
            disModel.DisLevel = "";
            disModel.Province = Reseller["ResellerProvince"].ToString();
            disModel.City     = Reseller["ResellerCity"].ToString();
            disModel.Area     = Reseller["ResellerArea"].ToString();
            disModel.Address  = address;
            //没输入经销商中的联系人,需要将登录信息的姓名赋值给联系人
            string principal = Common.NoHTML(Reseller["Principal"].ToString().Trim());
            string phone     = Common.NoHTML(Reseller["Phone"].ToString().Trim());
            if (principal == "")
            {
                disModel.Principal = truename;
            }
            else
            {
                disModel.Principal = principal;
            }
            //没输入联系人手机号,需要将登录信息中的手机号赋值给联系人手机号
            if (phone == "")
            {
                disModel.Phone = account["Phone"].ToString();
            }
            else
            {
                disModel.Phone = phone;
            }
            disModel.Leading      = "";
            disModel.LeadingPhone = "";
            disModel.Licence      = "";
            disModel.Tel          = Common.NoHTML(Reseller["Tel"].ToString());
            disModel.Zip          = Common.NoHTML(Reseller["Zip"].ToString());
            disModel.Fax          = Common.NoHTML(Reseller["Fax"].ToString());
            disModel.Remark       = "";
            disModel.DisAccount   = 0;
            disModel.IsCheck      = 1;
            disModel.CreditType   = 0;
            disModel.CreditAmount = 0;
            disModel.Paypwd       = Common.md5("123456");
            disModel.AuditState   = 2;
            disModel.IsEnabled    = 1;
            disModel.CreateUserID = one.ID;
            disModel.CreateDate   = DateTime.Now;
            disModel.ts           = DateTime.Now;
            disModel.dr           = 0;
            disModel.modifyuser   = one.ID;
            //开启事务,并将dismodel插入经销商表中
            SqlConnection conn = new SqlConnection(SqlHelper.LocalSqlServer);
            //开启数据库连接
            if (conn.State.ToString().ToLower() != "open")
            {
                conn.Open();
            }
            //开启事务
            SqlTransaction mytran = conn.BeginTransaction();
            int            DisID  = 0;
            try
            {
                //在经销商表中插入一条数据
                if ((DisID = new Hi.BLL.BD_Distributor().Add(disModel, mytran)) > 0)
                {
                    //经销商表插入成功的话继续新增角色
                    List <Hi.Model.SYS_Role> list_role = new Hi.BLL.SYS_Role().GetList("", "isnull(dr,0)=0 and isenabled=1 and DisID=" + DisID + " and RoleName='企业管理员'", "");

                    if (list_role == null || list_role.Count == 0)
                    {
                        //新增角色(企业管理员)
                        Hi.Model.SYS_Role role = new Hi.Model.SYS_Role();
                        role.CompID       = comp.ID;
                        role.DisID        = DisID;
                        role.RoleName     = "企业管理员";
                        role.IsEnabled    = 1;
                        role.SortIndex    = "1";
                        role.CreateDate   = DateTime.Now;
                        role.CreateUserID = one.ID;
                        role.ts           = DateTime.Now;
                        role.modifyuser   = one.ID;
                        role.dr           = 0;
                        int Roid = new Hi.BLL.SYS_Role().Add(role, mytran);
                        //新增管理员用户和角色
                        Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
                        user.UserName = username;
                        // user.CompID = CompID;
                        // user.Type = 5;
                        // user.RoleID = Roid;
                        user.TrueName     = truename;
                        user.UserPwd      = Common.md5("123456");
                        user.Phone        = account["Phone"].ToString();
                        user.AuditState   = 2;
                        user.IsEnabled    = 1;
                        user.CreateUserID = one.ID;
                        user.CreateDate   = DateTime.Now;
                        user.ts           = DateTime.Now;
                        user.modifyuser   = one.ID;
                        int AddUserid = new Hi.BLL.SYS_Users().Add(user, mytran);
                        ///用户明细表
                        Hi.Model.SYS_CompUser CompUser = new Hi.Model.SYS_CompUser();
                        CompUser.CompID       = comp.ID;
                        CompUser.DisID        = DisID;
                        CompUser.CreateDate   = DateTime.Now;
                        CompUser.CreateUserID = one.ID;
                        CompUser.modifyuser   = one.ID;
                        CompUser.CType        = 2;
                        CompUser.UType        = 5;
                        CompUser.IsEnabled    = 1;
                        CompUser.IsAudit      = 2;
                        CompUser.RoleID       = 0;
                        CompUser.ts           = DateTime.Now;
                        CompUser.dr           = 0;
                        CompUser.UserID       = AddUserid;
                        int compuserid = new Hi.BLL.SYS_CompUser().Add(CompUser, mytran);
                        //新增角色用户
                        Hi.Model.SYS_RoleUser RoleUser = new Hi.Model.SYS_RoleUser();
                        RoleUser.FunType    = 1;
                        RoleUser.UserID     = AddUserid;
                        RoleUser.RoleID     = Roid;
                        RoleUser.IsEnabled  = true;
                        RoleUser.CreateUser = UserID;
                        RoleUser.CreateDate = DateTime.Now;
                        RoleUser.ts         = DateTime.Now;
                        RoleUser.dr         = 0;
                        int roleuserid = new Hi.BLL.SYS_RoleUser().Add(RoleUser, mytran);
                        //新增角色权限表
                        Hi.Model.SYS_RoleSysFun    rolesys = null;
                        List <Hi.Model.SYS_SysFun> funList = new Hi.BLL.SYS_SysFun().GetList("", " Type=2", "");
                        foreach (Hi.Model.SYS_SysFun sys in funList)
                        {
                            rolesys              = new Hi.Model.SYS_RoleSysFun();
                            rolesys.CompID       = comp.ID;
                            rolesys.DisID        = DisID;
                            rolesys.RoleID       = Roid;
                            rolesys.FunCode      = sys.FunCode;
                            rolesys.FunName      = sys.FunName;
                            rolesys.IsEnabled    = 1;
                            rolesys.CreateUserID = one.ID;
                            rolesys.CreateDate   = DateTime.Now;
                            rolesys.ts           = DateTime.Now;
                            rolesys.modifyuser   = one.ID;
                            if (new Hi.BLL.SYS_RoleSysFun().Add(rolesys, mytran) <= 0)
                            {
                                mytran.Rollback();
                                return(new ReseltResellerEdit()
                                {
                                    Result = "F", Description = "新增失败"
                                });
                            }
                        }
                        //新增收货地址
                        Hi.Model.BD_DisAddr addr = new Hi.Model.BD_DisAddr();
                        addr.Province     = disModel.Province;
                        addr.City         = disModel.City;
                        addr.Area         = disModel.Area;
                        addr.DisID        = DisID;
                        addr.Principal    = disModel.Principal;
                        addr.Phone        = disModel.Phone;
                        addr.Address      = disModel.Province + disModel.City + disModel.Area + disModel.Address;
                        addr.IsDefault    = 1;
                        addr.ts           = DateTime.Now;
                        addr.CreateDate   = DateTime.Now;
                        addr.CreateUserID = one.ID;
                        addr.modifyuser   = one.ID;
                        int addrid = new Hi.BLL.BD_DisAddr().Add(addr, mytran);
                        //判断所有表是否都插入成功了吗
                        if (Roid <= 0 || AddUserid <= 0 || compuserid <= 0 || roleuserid <= 0 || addrid <= 0)
                        {
                            mytran.Rollback();
                            return(new ReseltResellerEdit()
                            {
                                Result = "F", Description = "新增失败"
                            });
                        }
                    }
                    else
                    {
                        mytran.Rollback();
                        return(new ReseltResellerEdit()
                        {
                            Result = "F", Description = "新增失败"
                        });
                    }
                }
                else
                {
                    mytran.Rollback();
                    return(new ReseltResellerEdit()
                    {
                        Result = "F", Description = "新增失败"
                    });
                }
                mytran.Commit();
            }
            catch (Exception ex)
            {
                mytran.Rollback();
                Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddReseller:" + JSon);
                return(new ReseltResellerEdit()
                {
                    Result = "F", Description = "新增失败"
                });
            }
            finally
            {
                conn.Close();
                mytran.Dispose();
            }
            return(new ReseltResellerEdit()
            {
                Result = "T", Description = "新增成功"
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "AddReseller:" + JSon);
            return(new ReseltResellerEdit()
            {
                Result = "F", Description = "新增失败"
            });
        }
    }
Beispiel #19
0
    /// <summary>
    ///核心企业修改经销商信息
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ReseltResellerEdit EditReseller(string JSon)
    {
        string UserID = string.Empty;
        string CompID = string.Empty;
        string DisID  = string.Empty;

        try
        {
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo["UserID"].ToString().Trim() == "" || JInfo["CompID"].ToString().Trim() == "" || JInfo["Reseller"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;
            UserID = JInfo["UserID"].ToString();
            CompID = JInfo["CompID"].ToString();
            JsonData Reseller = JInfo["Reseller"];
            //判断登录信息是否异常
            Hi.Model.SYS_Users one = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out one, Int32.Parse(CompID)))
            {
                return(new ReseltResellerEdit()
                {
                    Result = "F", Description = "登录信息异常"
                });
            }
            //判断核心企业信息是否异常
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Int32.Parse(CompID));
            if (comp == null || comp.dr == 1 || comp.IsEnabled == 0 || comp.AuditState == 0)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "核心企业信息异常"
                       }
            }
            ;
            #endregion
            //判断经销商信息是否正常
            DisID = Reseller["ResellerID"].ToString();
            Hi.BLL.BD_Distributor   bll_dis = new Hi.BLL.BD_Distributor();
            Hi.Model.BD_Distributor dis     = bll_dis.GetModel(Int32.Parse(DisID));
            if (dis == null)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商信息异常"
                       }
            }
            ;
            if (dis.dr == 1)
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商已被删除"
                       }
            }
            ;
            if (Reseller["ts"].ToString() != dis.ts.ToString())
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商信息已被他人修改,请稍后再试"
                       }
            }
            ;
            string resellername = Common.NoHTML(Reseller["ResellerName"].ToString().Trim());
            string resellercode = Common.NoHTML(Reseller["ResellerCode"].ToString().Trim());
            string address      = Common.NoHTML(Reseller["Address"].ToString().Trim());
            //判断经销商修改的必填项
            if (resellername == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商名称"
                       }
            }
            ;
            //判断经销商名字是否已存在
            //if (Common.DisExistsAttribute("DisName", Reseller["ResellerName"].ToString(), CompID.ToString()))
            //List<Hi.Model.BD_Distributor> list_dis = bll_dis.GetList("", "DisName = '" + resellername + "' and ID <> " + dis.ID + "", "");
            //if(list_dis!=null&&list_dis.Count>0)
            if (Common.DisExistsAttribute("DisName", resellername, CompID.ToString(), dis.ID.ToString()))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "经销商名称已经存在"
                       }
            }
            ;
            if (Reseller["ResellerProvince"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的省"
                       }
            }
            ;
            if (Reseller["ResellerCity"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的市"
                       }
            }
            ;
            if (Reseller["ResellerArea"].ToString().Trim() == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请选择经销商地址中的区"
                       }
            }
            ;
            if (address == "")
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "请输入经销商地址中的详细地址"
                       }
            }
            ;
            //修改经销商信息
            dis.ts         = DateTime.Now;
            dis.modifyuser = one.ID;
            dis.DisCode    = resellercode;
            dis.DisName    = resellername;
            //Int32 classifyid= Reseller["ResellerClassifyID"].ToString().Trim() == "" ? 0 : Int32.Parse(Reseller["ResellerClassifyID"].ToString().Trim());
            //传入分类ID的话,判断分类ID是否正确
            if (Reseller["ResellerClassifyID"].ToString().Trim() != "" && Reseller["ResellerClassifyID"].ToString() != "0")
            {
                Hi.Model.BD_DisType distpye = new Hi.BLL.BD_DisType().GetModel(Int32.Parse(Reseller["ResellerClassifyID"].ToString().Trim()));

                if (distpye == null || distpye.CompID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商分类异常"
                           }
                }
                ;
                if (distpye.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商分类已被删除"
                           }
                }
                ;
                //if (distpye.IsEnabled !=0)
                //    return new ReseltResellerEdit() { Result = "F", Description = "此经销商分类已被禁用" };

                dis.DisTypeID = distpye.ID;
            }
            else
            {
                dis.DisTypeID = 0;
            }
            //dis.AreaID = Reseller["AreaID"].ToString().Trim() == "" ? 0 : Int32.Parse(Reseller["AreaID"].ToString().Trim());
            //传入区域ID的话,判断区域ID是否正确
            if (Reseller["AreaID"].ToString().Trim() != "" && Reseller["AreaID"].ToString() != "0")
            {
                Hi.Model.BD_DisArea disarea = new Hi.BLL.BD_DisArea().GetModel(Int32.Parse(Reseller["AreaID"].ToString().Trim()));
                if (disarea == null || disarea.CompanyID != comp.ID)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "经销商区域异常"
                           }
                }
                ;
                if (disarea.dr == 1)
                {
                    return new ReseltResellerEdit()
                           {
                               Result = "F", Description = "此经销商区域已被删除"
                           }
                }
                ;
                dis.AreaID = disarea.ID;
            }
            else
            {
                dis.AreaID = 0;
            }
            dis.Province = Reseller["ResellerProvince"].ToString();
            dis.City     = Reseller["ResellerCity"].ToString();
            dis.Area     = Reseller["ResellerArea"].ToString();
            dis.Address  = address;
            dis.Zip      = Common.NoHTML(Reseller["Zip"].ToString());
            dis.Tel      = Common.NoHTML(Reseller["Tel"].ToString());
            dis.Fax      = Common.NoHTML(Reseller["Fax"].ToString());
            string principal = Common.NoHTML(Reseller["Principal"].ToString().Trim());
            string phone     = Common.NoHTML(Reseller["Phone"].ToString().Trim());
            //如果联系人或联系人手机没输入,需要将登陆信息的联系人或手机号,赋值给联系人或手机
            if (principal == "" || phone == "")
            {
                //先获取sys_compuser表中disid对应的数据,一对一关系
                List <Hi.Model.SYS_CompUser> compuser = new Hi.BLL.SYS_CompUser().GetList("UserID",
                                                                                          "DisID=" + dis.ID + " and UType = 5 and isnull(dr,0)=0 and isnull(IsEnabled,0)=1 and isnull(IsAudit,0)=2", "");
                //通过Userid获取sys_users表数据
                Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(compuser[0].ID);
                if (user != null && user.AuditState == 2 && user.IsEnabled == 1 && user.dr == 0)
                {
                    //需要判断到底是传入的联系人为空,还是手机为空
                    if (principal == "")
                    {
                        dis.Principal = user.TrueName;
                    }
                    else
                    {
                        dis.Principal = principal;
                    }
                    if (phone == "")
                    {
                        dis.Phone = user.Phone;
                    }
                    else
                    {
                        dis.Phone = phone;
                    }
                }
            }
            else
            {
                dis.Principal = principal;
                dis.Phone     = phone;
            }
            //更新数据库
            if (bll_dis.Update(dis))
            {
                return new ReseltResellerEdit()
                       {
                           Result = "T", Description = "修改成功"
                       }
            }
            ;
            else
            {
                return new ReseltResellerEdit()
                       {
                           Result = "F", Description = "修改失败"
                       }
            };
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "EditReseller:" + JSon);
            return(new ReseltResellerEdit()
            {
                Result = "F", Description = "修改失败"
            });
        }
    }
Beispiel #20
0
    /// <summary>
    /// 经销商获取个人信息
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public ResultDisInfo GetResellerInfo(string JSon)
    {
        try
        {
            #region JSon取值

            string userID = string.Empty;
            string disID  = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "")
            {
                userID = JInfo["UserID"].ToString();

                disID = JInfo["ResellerID"].ToString();
                //"{"LoginName":"def","PassWord":"******","OpenID":"def"}"
            }
            else
            {
                return(new ResultDisInfo()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            #endregion

            Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(userID));
            if (user == null || user.IsEnabled == 0 || user.dr == 1)
            {
                return new ResultDisInfo()
                       {
                           Result = "F", Description = "用户异常"
                       }
            }
            ;
            Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(int.Parse(disID));
            if (dis == null)
            {
                return new ResultDisInfo()
                       {
                           Result = "F", Description = "经销商异常"
                       }
            }
            ;
            Hi.Model.BD_DisType disType = new Hi.BLL.BD_DisType().GetModel(dis.DisTypeID);
            string DisTypeName          = string.Empty;
            if (disType != null)
            {
                DisTypeName = disType.TypeName;
            }
            Hi.Model.BD_DisArea area = new Hi.BLL.BD_DisArea().GetModel(dis.AreaID);
            string AreaName          = string.Empty;
            if (area != null)
            {
                AreaName = area.AreaName;
            }
            return(new ResultDisInfo()
            {
                Result = "T",
                Description = "获取成功",
                DisName = dis.DisName,
                DisTypeName = DisTypeName,
                AreaName = AreaName,
                DisPrincipal = dis.Principal,
                DisPhone = dis.Phone,
                IsCheck = dis.IsCheck.ToString(),
                CreditType = dis.CreditType.ToString(),
                UserName = user.UserName,
                UserSex = user.Sex,
                UserPhone = user.Phone,
                PrePaymentMoney = new Hi.BLL.PAY_PrePayment().sums(dis.ID, dis.CompID).ToString()
            });
        }
        catch
        {
            Common.CatchInfo(JSon, "GetResellerInfo");
            return(new ResultDisInfo()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }
Beispiel #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(Session["UserModel"] as LoginModel).IsExistRole)
        {
            Response.Redirect("~/Distributor/UserEdit.aspx", true);
        }

        //获取当前时间
        DateTime date = DateTime.Now;
        //当天0点0分
        DateTime day0 = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
        //获取当前时间加一天
        DateTime Sday = day0.AddDays(1);

        //当月第一天
        DateTime day1 = new DateTime(date.Year, date.Month, 1);
        //本月  最后一天  多加一天
        DateTime mothday = day1.AddMonths(1);

        user = new Hi.BLL.SYS_Users().GetModel(this.UserID);

        orderl = new Hi.BLL.DIS_Order().GetList("", " isnull(dr,0)=0 and Otype<>9 and OState<>6  and CompID=" + this.CompID + " and DisID=" + this.DisID, " CreateDate desc");
        if (orderl != null)
        {
            #region

            //当天订单数
            dayOrderCount = orderl.FindAll(
                p => (p.OState == 2 || p.OState == 3 || p.OState == 4 || p.OState == 5 || p.OState == 7) && p.CreateDate >= day0 && p.CreateDate < Sday).Count;

            //本月订单数
            orderCount = orderl.FindAll(
                p => (p.OState == 2 || p.OState == 3 || p.OState == 4 || p.OState == 5 || p.OState == 7) && p.CreateDate >= day1 && p.CreateDate < mothday).Count;

            #endregion
            orderll = orderl.FindAll(p => (p.PayState == 0 || p.PayState == 1));
        }
        List <Hi.Model.DIS_Suggest> suggest = new Hi.BLL.DIS_Suggest().GetList("", " isnull(dr,0)=0 and Stype=0 and isanswer=1 and DisUserID=" + this.UserID, "");
        message = suggest.Count;
        if (message == 0)
        {
            //imessage.Attributes.Add("style", "display:none");
        }
        price = Convert.ToDecimal(new Hi.BLL.PAY_PrePayment().sums(this.DisID, this.CompID)).ToString("0.00");
        dis   = new Hi.BLL.BD_Distributor().GetModel(this.DisID);
        if (dis != null)//add by hgh  出现为null值
        {
            //if ( dis.CreditType == 0)
            //{
            //lisalesorder.Attributes.Add("style", "background-color:#fbfbfb");
            //}

            Hi.Model.BD_DisType distypemodel = new Hi.BLL.BD_DisType().GetModel(dis.DisTypeID);
            if (distypemodel != null)
            {
                disType = distypemodel.TypeName;
            }
            Hi.Model.BD_DisArea disaddrmodel = new Hi.BLL.BD_DisArea().GetModel(dis.AreaID);
            if (disaddrmodel != null)
            {
                disAreaID = disaddrmodel.AreaName;
            }
        }
        #region 促销商品

        string    Cx_sql = string.Format(@"SELECT count(1) num from BD_Goods
where ID in (SELECT GoodsID from BD_PromotionDetail where ProID in
(SELECT ID from BD_Promotion where compID={0} and ProStartTime<=getdate() 
and ProStartTime<=GETDATE() and DATEADD(D,1,ProEndTime)>= getDate() and IsEnabled=1	))and ID not in (	
select GoodsID from BD_GoodsAreas where	compID={0} and DisID={1} and isnull(dr,0)=0)
and compid= {0} and ISNULL(dr,0)=0 and IsEnabled = 1 and IsOffLine=1 ", this.CompID, this.DisID);
        DataTable Cx_Dt  = SqlHelper.Query(SqlHelper.LocalSqlServer, Cx_sql).Tables[0];
        if (Cx_Dt != null)
        {
            if (Cx_Dt.Rows.Count > 0)
            {
                decimal sum_CX = Convert.ToDecimal(Cx_Dt.Rows[0]["num"]);
                Cx_Sum = sum_CX.ToString();
            }
        }

        #endregion

        #region  快过期商品 goods_Sum
        //当前时间
        DateTime now = DateTime.Now;
        //快到期时间
        DateTime today = now.AddDays(30);

        string goods_sql = string.Format(@"select * from YZT_GoodsStock s where s.validDate<='" + today + "'" + " and DisID=" + DisID + " and dr=0 ");

        DataTable goods_Dt = SqlHelper.Query(SqlHelper.LocalSqlServer, goods_sql).Tables[0];
        if (goods_Dt != null && goods_Dt.Rows.Count > 0)
        {
            goods_Sum = goods_Dt.Rows.Count.ToString();
        }
        #endregion

        #region 当天订购额
        //add by hgh  //包含已退订单金额、退单处理
        string daysql = "SELECT SUM(AuditAmount) as AuditAmount FROM [dbo].[DIS_Order] where ostate in (2,3,4,5,7) and DisID=" +
                        this.DisID + " and CompID=" + this.CompID + " and CreateDate>='" + day0 + "' and CreateDate<'" + Sday + "'";
        DataTable dayDt = SqlHelper.Query(SqlHelper.LocalSqlServer, daysql).Tables[0];
        if (dayDt != null)
        {
            if (dayDt.Rows.Count > 0)
            {
                decimal sumAmount = dayDt.Rows[0]["AuditAmount"].ToString() == ""
                    ? sum.ToString().ToDecimal()
                    : Convert.ToDecimal(dayDt.Rows[0]["AuditAmount"]);
                DaySum = (sumAmount).ToString("N");
            }
        }
        #endregion

        #region 本月订购额
        string    monthsql = "SELECT SUM(AuditAmount) as AuditAmount FROM DIS_Order where OState in (2,3,4,5,7) and isnull(dr,0)=0 and Otype<>9 and DisID=" + this.DisID + " and CompID=" + this.CompID + " and CreateDate>='" + day1 + "' and CreateDate<'" + mothday + "'";
        DataTable monthDt  = SqlHelper.Query(SqlHelper.LocalSqlServer, monthsql).Tables[0];
        if (monthDt != null)
        {
            if (monthDt.Rows.Count > 0)
            {
                decimal sumAmount = monthDt.Rows[0]["AuditAmount"].ToString() == "" ? sum.ToString().ToDecimal() : Convert.ToDecimal(monthDt.Rows[0]["AuditAmount"]);
                MonthSum = (sumAmount).ToString("N");
            }
        }
        #endregion

        #region 当天付款额
        //付款额    add by hgh  CompCollection_view 状态   and status!=3
        string daypaggersql = "SELECT SUM(Price) as Price FROM [dbo].[CompCollection_view] where DisID=" + this.DisID +
                              "and CompID=" + this.CompID + " and status!=3 and Date>='" + day0 + "' and Date<'" + Sday + "' AND vedf9=1 ";

        DataTable daypaggerdt = SqlHelper.Query(SqlHelper.LocalSqlServer, daypaggersql).Tables[0];
        if (daypaggerdt != null)
        {
            if (daypaggerdt.Rows.Count > 0)
            {
                decimal Price = daypaggerdt.Rows[0]["Price"].ToString() == ""
                    ? sum.ToString().ToDecimal()
                    : Convert.ToDecimal(daypaggerdt.Rows[0]["Price"]);
                DayPaymentSum = (Price).ToString("N");
            }
        }

        #endregion

        #region 本月付款额
        //本月付款额    add by hgh  CompCollection_view 状态   and status!=3
        string paggersql = "SELECT SUM(Price) as Price FROM [dbo].[CompCollection_view] where OrderID not in (select ID from Dis_Order where ISNULL(dr,0)=0 and Otype=9) and DisID=" + this.DisID + "  and status!=3 and CompID=" + this.CompID + " and Date>='" + day1 + "' and Date<'" + mothday + "' AND vedf9=1 ";

        DataTable paggerdt = SqlHelper.Query(SqlHelper.LocalSqlServer, paggersql).Tables[0];
        if (paggerdt != null)
        {
            if (paggerdt.Rows.Count > 0)
            {
                decimal Price = paggerdt.Rows[0]["Price"].ToString() == "" ? sum.ToString().ToDecimal() : Convert.ToDecimal(paggerdt.Rows[0]["Price"]);
                PaymentSum = (Price).ToString("N");
            }
        }
        #endregion

        #region 本月应付额
        //本月应付额

        decimal AuditAmount = 0;
        decimal payAmount   = 0;
        decimal payyzf      = 0;

        //赊销订单  未支付的
        //string ArrearageSql = "SELECT SUM(AuditAmount) as AuditAmount FROM [dbo].[ArrearageRpt_view] where DisID=" + user.DisID + "and CompID=" + user.CompID + " and CreateDate>='" + day1 + "' and CreateDate<='" + Sday + "'";

        //DataTable ArrearageDt = SqlHelper.Query(SqlHelper.LocalSqlServer, ArrearageSql).Tables[0];
        //if (ArrearageDt != null)
        //{
        //    if (ArrearageDt.Rows.Count > 0)
        //    {
        //        AuditAmount = ArrearageDt.Rows[0]["AuditAmount"].ToString() == "" ? sum.ToString().ToDecimal() : Convert.ToDecimal(ArrearageDt.Rows[0]["AuditAmount"]);
        //    }
        //}

        //未支付订单金额
        //string paysql = "  select SUM(AuditAmount) as AuditAmount from DIS_Order where (( Otype=1 and OState not in (-1,0,1)  and PayState in (0,1) ) or( Otype<>1 and OState=2   and PayState in (0,1) )) and OState<>6 and ReturnState=0 and isnull(dr,0)=0 and Otype!=9 and CompID=" + this.CompID + " and DisID=" + this.DisID + " and CreateDate>='" + day1 + "' and CreateDate<='" + Sday + "'";

        //DataTable payDt = SqlHelper.Query(SqlHelper.LocalSqlServer, paysql).Tables[0];
        //if (payDt != null && payDt.Rows.Count > 0)
        //{
        //    payAmount = payDt.Rows[0]["AuditAmount"].ToString() == "" ? 0 : payDt.Rows[0]["AuditAmount"].ToString().ToDecimal(0);
        //}
        //paysql = "  select SUM(PayedAmount) as PayedAmount from DIS_Order where (( Otype=1 and OState not in (-1,0,1)  and PayState in (0,1) ) or( Otype<>1 and OState=2   and PayState in (0,1) )) and OState<>6 and ReturnState=0 and isnull(dr,0)=0 and Otype!=9 and CompID=" + this.CompID + " and DisID=" + this.DisID + " and CreateDate>='" + day1 + "' and CreateDate<='" + Sday + "'";
        //payDt = SqlHelper.Query(SqlHelper.LocalSqlServer, paysql).Tables[0];
        //if (payDt != null && payDt.Rows.Count > 0)
        //{
        //    payyzf = payDt.Rows[0]["PayedAmount"].ToString() == "" ? 0 : payDt.Rows[0]["PayedAmount"].ToString().ToDecimal(0);
        //}
        //PayableSum = (payAmount - payyzf + AuditAmount).ToString("N");


        //edit by hgh   正常合同 总额-已付
        string    paysql = "  select SUM(AuditAmount)-SUM(PayedAmount) as AuditAmount from DIS_Order where OState in(2,3,5) and isnull(dr,0)=0 and Otype!=9 and CompID=" + this.CompID + " and DisID=" + this.DisID + " and CreateDate>='" + day1 + "' and CreateDate<'" + Sday + "'";
        DataTable payDt  = SqlHelper.Query(SqlHelper.LocalSqlServer, paysql).Tables[0];
        if (payDt != null && payDt.Rows.Count > 0)
        {
            payAmount = payDt.Rows[0]["AuditAmount"].ToString() == "" ? 0 : payDt.Rows[0]["AuditAmount"].ToString().ToDecimal(0);
        }
        PayableSum = payAmount.ToString("N");
        #endregion

        #region 商家公告

        List <Hi.Model.BD_CompNews> LNew = new Hi.BLL.BD_CompNews().GetList("top 3 *", "isnull(dr,0)=0 and IsEnabled=1 and Compid=" + this.CompID + " ", " istop desc,createdate desc");
        string Html = "";
        if (LNew.Count > 0)
        {
            for (int i = 0; i < LNew.Count; i++)
            {
                if (LNew[i].ShowType == null)
                {
                    LNew[i].ShowType = "";
                }

                if (i <= 4)
                {
                    string type = LNew[i].ShowType == "1" ? "top" : LNew[i].ShowType == "2" ? "red" : LNew[i].ShowType == "1,2" ? "top red" : "";
                    Html += "<li class='" + type + "'><a title='" + LNew[i].NewsTitle + "' href=\"CompNewInfo.aspx?KeyID=" + Common.DesEncrypt(LNew[i].ID.ToString(), Common.EncryptKey) + "&Type=3\">【" + Common.GetCPNewStateName(LNew[i].NewsType) + "】" + (LNew[i].NewsTitle.Length > 16 ? LNew[i].NewsTitle.Substring(0, 16) + "..." : LNew[i].NewsTitle) + "</a>" + IsEnd(LNew[i].PmID) + (LNew[i].ShowType.IndexOf("1") >= 0 ? "<i class='newIcon'></i>" : "") + "<i class='date1'>" + LNew[i].CreateDate.ToString("yyyy-MM-dd") + "</i></li>";
                }
            }
            ULNewList.InnerHtml = Html;
        }
        else
        {
            //ULNewList.InnerHtml = "<li style='text-align:center'><span>暂无公告</span></li>";
            ULNewList.InnerHtml = "<div class='nomh-box'><i class='nomh-i'></i>暂无公告</div>";
        }
        #endregion

        if (!IsPostBack)
        {
            if (IsDisAdmin(this.UserID))
            {
                if (user.UserPwd == Util.md5("123456"))
                {
                    DisImport.Attributes.Add("style", "display:block");
                    zzc.Attributes.Add("style", "display:block");
                    return;
                }
            }
        }
    }