Esempio n. 1
0
        /// <summary>
        /// 查询分页
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPage()
        {
            string         CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            int            PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int            PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);
            string         SupName   = WebUtil.GetFormValue <string>("SupName", string.Empty);
            string         SupNum    = WebUtil.GetFormValue <string>("SupNum", string.Empty);
            string         Phone     = WebUtil.GetFormValue <string>("Phone", string.Empty);
            int            SupType   = WebUtil.GetFormValue <int>("SupType", -1);
            SupplierEntity entity    = new SupplierEntity();

            entity.SupName = SupName;
            entity.SupNum  = SupNum;
            entity.SupType = SupType;
            entity.Phone   = Phone;
            PageInfo pageInfo = new PageInfo();

            pageInfo.PageIndex = PageIndex;
            pageInfo.PageSize  = PageSize;
            SupplierProvider                provider = new SupplierProvider(CompanyID);
            List <SupplierEntity>           list     = provider.GetList(entity, ref pageInfo);
            DataListResult <SupplierEntity> result   = new DataListResult <SupplierEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
Esempio n. 2
0
        public ActionResult Auto(string supName)
        {
            SupplierProvider      provider = new SupplierProvider();
            List <SupplierEntity> list     = provider.GetList();

            if (!list.IsNullOrEmpty() && !supName.IsEmpty())
            {
                list = list.Where(a => a.SupNum.Contains(supName) || a.SupName.Contains(supName)).ToList();
            }
            list = list.IsNull() ? new List <SupplierEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (SupplierEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("SupNum", t.SupNum);
                jsonObject.AddProperty("SupName", t.SupName);
                jsonObject.AddProperty("ContactName", t.ContactName);
                jsonObject.AddProperty("Phone", t.Phone);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
Esempio n. 3
0
        /// <summary>
        /// 查询供应商列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetList()
        {
            string                          CompanyID = WebUtil.GetFormValue <string>("CompanyID");
            SupplierProvider                provider  = new SupplierProvider(CompanyID);
            List <SupplierEntity>           list      = provider.GetList();
            DataListResult <SupplierEntity> result    = new DataListResult <SupplierEntity>()
            {
                Code = (int)EResponseCode.Success, Message = "响应成功", Result = list
            };

            return(Content(JsonHelper.SerializeObject(result)));
        }
Esempio n. 4
0
        /// <summary>
        /// 供应商下拉列表
        /// </summary>
        /// <param name="roleNum"></param>
        /// <returns></returns>
        public static string GetSupNameList(string SupNum)
        {
            SupplierProvider      provider = new SupplierProvider();
            List <SupplierEntity> list     = provider.GetList();
            StringBuilder         sb       = new StringBuilder();
            string storeTemplate           = "<option value='{0}' {1}>{2}</option>";

            if (!list.IsNullOrEmpty())
            {
                foreach (SupplierEntity store in list)
                {
                    sb.AppendFormat(storeTemplate, store.SupNum, store.SupNum == SupNum ? "selected='selected'" : string.Empty, store.SupName);
                }
            }
            return(sb.ToString());
        }
Esempio n. 5
0
        public ActionResult GetSupplierList()
        {
            int                   pageIndex = WebUtil.GetFormValue <int>("pageIndex", 1);
            int                   pageSize  = WebUtil.GetFormValue <int>("pageSize", 15);
            string                SupNum    = WebUtil.GetFormValue <string>("SupNum", string.Empty);
            SupplierProvider      provider  = new SupplierProvider();
            SupplierEntity        entity    = new SupplierEntity();
            List <SupplierEntity> list      = provider.GetList();

            if (!list.IsNullOrEmpty())
            {
                List <SupplierEntity> listResult = list.Where(a => a.SupNum.Contains(SupNum) || a.SupName.Contains(SupNum)).ToList();
                List <SupplierEntity> returnList = listResult.Skip((pageIndex - 1) * pageSize).Take(pageSize).OrderByDescending(a => a.ID).ToList();
                string json = ConvertJson.ListToJson <SupplierEntity>(returnList, "List");
                this.ReturnJson.AddProperty("Data", new JsonObject(json));
                this.ReturnJson.AddProperty("RowCount", listResult.Count);
            }
            return(Content(this.ReturnJson.ToString()));
        }
Esempio n. 6
0
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            string                SupNum   = WebUtil.GetFormValue <string>("SupNum", string.Empty);
            SupplierProvider      provider = new SupplierProvider();
            SupplierEntity        entity   = new SupplierEntity();
            List <SupplierEntity> list     = provider.GetList();

            if (!list.IsNullOrEmpty())
            {
                List <SupplierEntity> listResult = list.Where(a => a.SupNum.Contains(SupNum) || a.SupName.Contains(SupNum)).ToList();
                listResult = listResult.IsNull() ? new List <SupplierEntity>() : listResult;
                if (listResult.IsNotNull())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("序号 "));
                    dt.Columns.Add(new DataColumn("供应商编号"));
                    dt.Columns.Add(new DataColumn("供应商名称"));
                    dt.Columns.Add(new DataColumn("电话"));
                    dt.Columns.Add(new DataColumn("传真"));
                    dt.Columns.Add(new DataColumn("Email"));
                    dt.Columns.Add(new DataColumn("联系人"));
                    dt.Columns.Add(new DataColumn("地址"));
                    dt.Columns.Add(new DataColumn("描述"));
                    int count = 1;
                    foreach (SupplierEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = count;
                        row[1] = t.SupNum;
                        row[2] = t.SupName;
                        row[3] = t.Phone;
                        row[4] = t.Fax;
                        row[5] = t.Email;
                        row[6] = t.ContactName;
                        row[7] = t.Address;
                        row[8] = t.Description;
                        dt.Rows.Add(row);
                        count++;
                    }
                    string filePath = Server.MapPath("~/UploadFiles/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("供应商管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                    NPOIExcel excel    = new NPOIExcel("供应商管理", "供应商", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
                }
                else
                {
                    this.ReturnJson.AddProperty("d", "无数据导出!")
                    ;
                }
            }
            return(Content(this.ReturnJson.ToString()));
        }