Example #1
0
        public ActionResult SendEmail(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupplierRequest supplierRequest = db.SupplierRequests.Where(x => x.SupplierRequestID == id).FirstOrDefault();
            var             supplierEmail   = supplierRequest.email;
            var             email           = (from s in db.maintenanceSuppliers
                                               where supplierRequest.SupplierID == s.SupplierID
                                               select s.Supplier_Email
                                               ).FirstOrDefault();
            var ItermRequired = supplierRequest.ProductName;
            var quantiy       = supplierRequest.ProductQuantity;

            EmailService em = new EmailService();

            em.SendRegMail(email, "*****Request for quote*****", "\n Good Day" + "\n Please note that the following items are requested" + " " + "Item" + ItermRequired, "\n Quantity" + " " + quantiy + "\n This email was created on the" + " " + System.DateTime.UtcNow + "\n SmartRes System");

            if (supplierRequest == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #2
0
        public async Task <int> AddAsync(SupplierRequest entity)
        {
            var sproc = "sp_InsertSupplier";

            using (var connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection")))
            {
                var qparametes = new DynamicParameters();
                qparametes.Add("@CompanyName", entity.CompanyName);
                qparametes.Add("@ContactName", entity.ContactName);
                qparametes.Add("@ContactTitle", entity.ContactTitle);
                qparametes.Add("@Address", entity.Address);
                qparametes.Add("@City", entity.City);
                qparametes.Add("@Region", entity.Region);
                qparametes.Add("@PostalCode", entity.PostalCode);
                qparametes.Add("@Country", entity.Country);
                qparametes.Add("@Phone", entity.Phone);
                qparametes.Add("@Fax", entity.Fax);
                qparametes.Add("@HomePage", entity.HomePage);

                connection.Open();
                var result = await connection.ExecuteAsync(sproc, qparametes, commandType : CommandType.StoredProcedure);

                return(result);
            }
        }
        public async Task <DataRespond> insertAsync([FromForm] SupplierRequest supplier)
        {
            DataRespond data = new DataRespond();

            try
            {
                Supplier s = new Supplier();
                s.suppliername = supplier.suppliername;
                s.phonenumber  = supplier.phonenumber;
                s.address      = supplier.address;
                s.email        = supplier.email;
                s.activity     = supplier.activity == 0 ? true : false;
                DateTime creday = DateTime.ParseExact(supplier.createday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                s.createday = creday;//2019-12-10
                s.picture   = await m_image.uploadFile(supplier.picture);

                data.success = true;
                m_supplier.insert(s);
                data.messger = "Insert success";
            }catch (Exception e)
            {
                data.success = false;
                data.error   = e;
                data.messger = e.Message;
            }

            return(data);
        }
Example #4
0
        async Task <SupplierViewModel> bindSupplierViewModel(SupplierRequest response)
        {
            var model = new SupplierViewModel()
            {
                SupplierRequestId    = response.SupplierRequestId,
                SuplierTypeRequest   = await this.supplierRequest.GetSupplierTypeRequestMaster(),
                RequestTypeMaster    = await this.supplierRequest.GetRequestTypeMaster(),
                CategoryMaster       = await this.supplierRequest.GetCategoryMaster(),
                SuplierTypeRequestId = response.SuplierTypeRequestId,
                RequestTypeMasterId  = response.RequestTypeMasterId,
                RequesterName        = response.RequesterName,
                Department           = response.Department,
                SupplierName         = response.SupplierName,
                Street              = response.Street,
                Address1            = response.Address1,
                Address2            = response.Address2,
                City                = response.City,
                PostalCode          = response.PostalCode,
                Country             = response.Country,
                FirstName           = response.FirstName,
                LastName            = response.LastName,
                EmailId             = response.EmailId,
                ContactPhone        = response.ContactPhone,
                CategoryMasterNames = string.Join(',', response.SupplierRequestCategoryMapping.Select(x => x.CategoryMaster.Category).ToList())
            };

            return(model);
        }
Example #5
0
        /// <summary>
        /// 获取数据列表(分页)
        /// </summary>
        public PageModel GetDataListForPage(SupplierRequest request)
        {
            #region 模糊搜索条件
            var where = new Where <TbSupplier>();
            if (!string.IsNullOrWhiteSpace(request.SupplierName))
            {
                where.And(d => d.SupplierName.Like(request.SupplierName));
            }
            #endregion

            try
            {
                var data = Db.Context.From <TbSupplier>()
                           .Select(
                    TbSupplier._.All
                    , TbUser._.UserName.As("InsertUserName"))
                           .LeftJoin <TbUser>((a, c) => a.InsertUserCode == c.UserCode)
                           .Where(where)
                           .OrderByDescending(p => p.ID)
                           .ToPageList(request.rows, request.page);
                return(data);
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            SupplierRequest supplierRequest = db.SupplierRequests.Find(id);

            db.SupplierRequests.Remove(supplierRequest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
        public ActionResult Index(SupplierRequest request)
        {
            //var materialList = this.BasisDataService.GetSupplierList(new SupplierRequest());
            //this.ViewBag.ChannelId = new SelectList(classList, "ID", "Name");
            this.ViewData["BasisDataService"] = this.BasisDataService;
            var result = this.BasisDataService.GetSupplierList(request);

            return(View(result));
        }
Example #8
0
        // Viewmodel 2 Entities
        private damco_supplier SupplierRequest2Entity(SupplierRequest data)
        {
            var entity = new damco_supplier
            {
                name = data.name,
            };

            return(entity);
        }
Example #9
0
        public async Task <IActionResult> Add(SupplierRequest suppliers)
        {
            var supplierEntity = mapper.Map <SupplierRequest>(suppliers);

            var data = await unitOfWork.Suppliers.AddAsync(suppliers);

            var resultEnity = mapper.Map <Suppliers>(suppliers);

            return(CreatedAtRoute("GetSupplierInfo", new { id = resultEnity.SupplierId }, suppliers));
        }
Example #10
0
 public ActionResult Edit([Bind(Include = "SupplierRequestID,ProductName,ProductQuantity,email")] SupplierRequest supplierRequest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplierRequest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplierRequest));
 }
Example #11
0
        public ItemResult <object> CreateSupplier(SupplierRequest supplierRequest)
        {
            var result = ItemResult <object> .SuccessResult;

            try
            {
                result.data = _suppliersService.AddSupplier(SupplierRequest2Entity(supplierRequest));
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #12
0
        // GET: SupplierRequests/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupplierRequest supplierRequest = db.SupplierRequests.Find(id);

            if (supplierRequest == null)
            {
                return(HttpNotFound());
            }
            return(View(supplierRequest));
        }
Example #13
0
        public ActionResult Create([Bind(Include = "SupplierRequestID,ProductName,ProductQuantity,email,SupplierID")] SupplierRequest supplierRequest)
        {
            if (ModelState.IsValid)
            {
                var email = (from s in db.maintenanceSuppliers
                             where supplierRequest.SupplierID == s.SupplierID
                             select s.Supplier_Email
                             ).FirstOrDefault();
                supplierRequest.email = email;

                db.SupplierRequests.Add(supplierRequest);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.SupplierID = new SelectList(db.maintenanceSuppliers, "SupplierID", "Supplier", supplierRequest.SupplierID);

            return(View(supplierRequest));
        }
        public async Task <string> upfileAsync([FromForm] SupplierRequest file)
        {
            Supplier supplier = new Supplier();

            try
            {
                supplier.suppliername = file.suppliername;
                supplier.phonenumber  = file.phonenumber;
                supplier.address      = file.address;
                supplier.email        = file.email;
                supplier.activity     = file.activity == 0 ? true : false;
                supplier.createday    = DateTime.ParseExact(file.createday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                supplier.picture      = await m_image.uploadFile(file.picture);
            }
            catch (Exception e)
            {
                supplier.picture = e.Message;
            }
            return("update khong thanh chong");
        }
        public JsonResult Post(SupplierRequest request)
        {
            _logger.LogInformation("Data Insertion started" + JsonSerializer.Serialize(request.ToString()));
            int status = StatusCodes.Status200OK;
            var result = ItemResult <object> .SuccessResult;

            try
            {
                result = _supplierFacade.CreateSupplier(request);
                _logger.LogInformation("Data Insertion completed" + request.ToString());
            }
            catch (Exception ex)
            {
                _logger.LogError("Error in api/v1/supplier:" + ex.Message);
                status = StatusCodes.Status500InternalServerError;
                result.Failed(ex.Message);
            }
            return(new JsonResult(result)
            {
                StatusCode = status
            });
        }
Example #16
0
        public IEnumerable <Supplier> GetSupplierList(SupplierRequest request = null)
        {
            request = request ?? new SupplierRequest();
            using (var dbContext = new BasisDataDbContext())
            {
                IQueryable <Supplier> supplier = dbContext.Suppliers;

                if (!string.IsNullOrEmpty(request.Name))
                {
                    supplier = supplier.Where(u => u.Name.Contains(request.Name));
                }
                if (!string.IsNullOrEmpty(request.Contact))
                {
                    supplier = supplier.Where(u => u.Contact.Contains(request.Contact));
                }
                if (!string.IsNullOrEmpty(request.Address))
                {
                    supplier = supplier.Where(u => u.Address.Contains(request.Address));
                }
                return(supplier.OrderByDescending(u => u.ID).ToPagedList(request.PageIndex, request.PageSize));
            }
        }
Example #17
0
 public void AddSupplierRequest(SupplierRequest supplierRequest)
 {
     throw new NotImplementedException();
 }
Example #18
0
        public static IEnumerable <SupplierRequest> GetSupplierRequests(SupplierRequest suppliersearch)
        {
            var paramList = new List <ParameterValue>();

            if (!String.IsNullOrEmpty(suppliersearch.RequesterID.ToString()))
            {
                paramList.Add(new ParameterValue("RequesterID", suppliersearch.RequesterID));
            }

            var dataSet = DataFacade.GetDataSet("SupplierRequestGet", paramList.ToArray());

            var returnList = new List <SupplierRequest>();

            foreach (var requestItem in dataSet.Tables["Table"].Rows.Cast <DataRow>().Select(x => new SupplierRequest
            {
                Requester =
                    dataSet.Tables["Table1"].Rows.Cast <DataRow>().Where(
                        y => (int)y["RequesterID"] == (int)x["RequesterID"]).Select(
                        y => new Requester
                {
                    RequesterID = Convert.ToInt32(y["RequesterID"]),
                    RequestDate = Convert.ToDateTime(y["RequestDate"]),
                    SiteName = y["SiteName"].ToString(),
                    SiteNumber = y["SiteNumber"].ToString(),
                    EmailAddress = y["EmailAddress"].ToString(),
                    ContactNo = y["ContactNo"].ToString(),
                    RequesterName = y["RequesterName"].ToString()
                }).FirstOrDefault(),
                Supplier =
                    dataSet.Tables["Table2"].Rows.Cast <DataRow>().Where(
                        y => (int)y["RequesterID"] == (int)x["RequesterID"]).Select(
                        y => new Supplier
                {
                    SupplierID = (int)y["SupplierID"],
                    SupplierName = y["SupplierName"].ToString(),
                    Address1 = y["Address1"].ToString(),
                    Address2 = y["Address2"].ToString(),
                    City = y["City"].ToString(),
                    Province = y["Province"].ToString(),
                    PostalCode = Convert.ToInt32(y["PostalCode"]),
                    Phone = y["Phone"].ToString(),
                    ContactName = y["ContactName"].ToString(),
                    Cellphone = y["Cellphone"].ToString(),
                    VATNo = y["VATNo"].ToString(),
                    Fax = y["Fax"].ToString(),
                    EMail = y["EMail"].ToString()
                }).FirstOrDefault()
            }))
            {
                requestItem.SupplierProduct =
                    dataSet.Tables["Table3"].Rows.Cast <DataRow>().Where(
                        x => (int)x["SupplierID"] == requestItem.Supplier.SupplierID).Select(x => new SupplierProduct
                {
                    SupplierID           = (int)x["SupplierID"],
                    RetailBarcode        = x["RetailBarcode"].ToString(),
                    RetailPackSize       = x["RetailPackSize"].ToString(),
                    Ranging              = x["Ranging"].ToString(),
                    OuterCaseCode        = x["OuterCaseCode"].ToString(),
                    PackBarcode          = x["PackBarcode"].ToString(),
                    ProductCode          = x["ProductCode"].ToString(),
                    ProductDescription   = x["ProductDescription"].ToString(),
                    ISISRetailItemNaming = x["ISISRetailItemNaming"].ToString(),
                    Category             = x["Category"].ToString(),
                    Brand        = x["Brand"].ToString(),
                    UOMType      = x["UOMType"].ToString(),
                    PackSizeCase = Convert.ToInt32(x["PackSizeCase"]),
                    CaseCost     = Convert.ToDecimal(x["CaseCost"]),
                    Cost         = Convert.ToDecimal(x["Cost"])
                })
                    .ToList();

                returnList.Add(requestItem);
            }

            return(returnList);
        }
Example #19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (base.IsValid == false)
            {
                MessageBox.Show(AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER);
                return;
            }

            if (txtEmail1.Text != String.Empty && !Regex.IsMatch(txtEmail1.Text, Constants.EMAILPATTERN))
            {
                txtEmail1.Focus();
                MessageBox.Show(Resources.frmSupplierDataEntry_btnSave_Click_Please_Enter_Valid_Email_Address_, Constants.ALERTMESSAGEHEADER);
                return;
            }

            if (txtEmail2.Text != String.Empty && !Regex.IsMatch(txtEmail2.Text, Constants.EMAILPATTERN))
            {
                txtEmail2.Focus();
                MessageBox.Show(Resources.frmSupplierDataEntry_btnSave_Click_Please_Enter_Valid_Email_Address_, Constants.ALERTMESSAGEHEADER);
                return;
            }

            var request = new SupplierRequest {
                Supplier = CurrentItem.Entity
            };

            if (MdiMode == FormMode.Add)
            {
                request.Supplier = new Supplier {
                    Address = new Address()
                };
            }
            request.Supplier.CSTNumber            = txtCSTNumber.Text;
            request.Supplier.PANNumber            = txtPANWNumber.Text;
            request.Supplier.Address.AddressLine1 = txtAddressL1.Text;
            request.Supplier.Address.AddressLine2 = txtAddressL2.Text;
            request.Supplier.Address.City         = txtCity.Text;
            request.Supplier.Address.Country      = cboCountry.Text;
            request.Supplier.Address.Fax          = txtFax.Text;
            request.Supplier.Address.Phone        = txtPhone.Text;
            request.Supplier.Address.PostalCode   = txtPostalCode.Text;
            request.Supplier.Address.State        = cboState.Text;

            request.Supplier.CompanyName    = txtComapnyName.Text;
            request.Supplier.ContactName    = txtContactName.Text;
            request.Supplier.SupplierStatus = rdoActive.Checked ? SupplierStatus.Active : SupplierStatus.InActive;

            request.Supplier.Properties = new SupplierProperties
            {
                AccountNumber = txtacNumber.Text,
                BankName      = txtbankNumber.Text,
                DOB           = dtDob.Value,
                Email1        = txtEmail1.Text,
                Email2        = txtEmail2.Text,
                FirstName     = txtFname.Text,
                LastName      = txtLname.Text,
                MiddleName    = txtMname.Text,
                Note          = txtNote.Text,
                Website       = txtWebsite.Text
            };
            request.Supplier.VATNumber = txtVatNumber.Text;

            var supplierResponse = _supplierService.SaveSupplier(request);

            if (false == supplierResponse.IsValid)
            {
                MessageBox.Show(supplierResponse.AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER);
                return;
            }

            groupBox.Enabled = groupBox1.Enabled = groupBox2.Enabled = btnSave.Enabled = false;
            MessageBox.Show(Resources.frmSupplierDataEntry_btnSave_Click_Record_saved_);
        }
Example #20
0
        public async Task <long> Add(SupplierViewModel model)
        {
            var request = new SupplierRequest()
            {
                SuplierTypeRequestId = model.SuplierTypeRequestId,
                RequestTypeMasterId  = model.RequestTypeMasterId,
                RequesterName        = model.RequesterName,
                Department           = model.Department,
                SupplierName         = model.SupplierName,
                Street            = model.Street,
                Address1          = model.Address1,
                Address2          = model.Address2,
                City              = model.City,
                PostalCode        = model.PostalCode,
                Country           = model.Country,
                FirstName         = model.FirstName,
                LastName          = model.LastName,
                EmailId           = model.EmailId,
                ContactPhone      = model.ContactPhone,
                IsApprovalPending = true,
                CreatedBy         = model.CreatedBy,
                IsEditable        = true
            };

            this._context.SupplierRequest.Add(request);
            await this._context.CompleteAsync();

            var categoryMaster = new List <SupplierRequestCategoryMapping>();

            foreach (var item in model.CategoryMaster)
            {
                if (item.IsSelected)
                {
                    categoryMaster.Add(new SupplierRequestCategoryMapping()
                    {
                        SupplierRequestId = request.SupplierRequestId,
                        CategoryMasterId  = item.CategoryMasterId
                    });
                }
                ;
            }
            this._context.SupplierCategoryMappingRepository.Add(categoryMaster);
            await this._context.CompleteAsync();

            var roleApprovalList = await GetRoleApprovalMasterList(1);

            var roleApprovals = new List <SupplierRequestApprovalLog>();

            foreach (var item in roleApprovalList)
            {
                roleApprovals.Add(new SupplierRequestApprovalLog()
                {
                    SupplierRequestId    = request.SupplierRequestId,
                    RoleApprovalMasterId = item.RoleApprovalMasterId,
                    OrderBy = item.OrderBy
                });
            }
            this._context.SupplierRequestApprovalLog.Add(roleApprovals);
            await this._context.CompleteAsync();

            request.SupplierRequestApprovalId = roleApprovals.Where(x => !x.IsApproved.GetValueOrDefault()).OrderBy(x => x.OrderBy).FirstOrDefault().SupplierRequestApprovalId;
            this._context.SupplierRequest.Update(request);
            await this._context.CompleteAsync();

            return(request.SupplierRequestId);
        }
Example #21
0
 public IEnumerable <SupplierRequest> GetSupplierRequests(SupplierRequest suppliersearch)
 {
     return(SupplierDao.GetSupplierRequests(suppliersearch));
 }
Example #22
0
        //
        // GET: /Ims/Supplier/
        public ActionResult Index(SupplierRequest request)
        {
            var result = this.ImsService.GetSupplierList(request);

            return(View(result));
        }
 public void  Add(SupplierRequest supplierRequest)
 {
     context.SupplierRequest.Add(supplierRequest);
 }
 public void Update(SupplierRequest supplierRequest)
 {
     context.SupplierRequest.Update(supplierRequest);
 }
Example #25
0
        public JsonResult Datatable(SupplierRequest request)
        {
            #region 自定义动作
            if (!string.IsNullOrEmpty(request.customActionType))
            {
                string[]   id_Array = Request.Params.GetValues("id[]");
                List <int> ids      = new List <int>();
                foreach (string i in id_Array)
                {
                    ids.Add(int.Parse(i));
                }

                switch (request.customActionType)
                {
                case "group_action":

                    switch (request.customActionName)
                    {
                    case "delete":
                        this.ImsService.DeleteSupplier(ids);
                        break;
                    }
                    break;

                case "delete":
                    this.ImsService.DeleteSupplier(ids);
                    break;
                }
            }
            #endregion

            var allSuppliers = this.ImsService.GetSupplierList(null);

            IEnumerable <Supplier> filterSuppliers = allSuppliers;

            #region 搜索
            if (!string.IsNullOrEmpty(request.search))
            {
                var isNameSearchable = Convert.ToBoolean(Request["columns[1][searchable]"]);
            }
            else if (request.action == "filter")
            {
                var NameFilter         = Convert.ToString(Request["name"]).ToLower().Trim();
                var PlatFormFilter     = Convert.ToString(Request["platform"]).ToLower().Trim();
                var URLFilter          = Convert.ToString(Request["url"]).ToLower().Trim();
                var CSFilter           = Convert.ToString(Request["cs"]).ToLower().Trim();
                var CSPhoneFilter      = Convert.ToString(Request["csphone"]).ToLower().Trim();
                var ContactFilter      = Convert.ToString(Request["contact"]).ToLower().Trim();
                var ContactPhoneFilter = Convert.ToString(Request["contactphone"]).ToLower().Trim();

                var isNameSearchable = Convert.ToBoolean(Request["columns[1][searchable]"].ToString());

                if (isNameSearchable)
                {
                    filterSuppliers = filterSuppliers.Where(c => c.Name.ToLower().Contains(NameFilter));
                }

                var isPlatFormSearchable = Convert.ToBoolean(Request["columns[2][searchable]"].ToString());


                if (isPlatFormSearchable)
                {
                    filterSuppliers = filterSuppliers.Where(c => c.Platform.ToLower().Contains(PlatFormFilter));
                }

                var isURLSearchable = Convert.ToBoolean(Request["columns[3][searchable]"].ToString());

                if (isURLSearchable)
                {
                    filterSuppliers = filterSuppliers.Where(c => c.URL.ToLower().Contains(URLFilter));
                }

                var isCSSearchable = Convert.ToBoolean(Request["columns[4][searchable]"].ToString());

                if (isCSSearchable)
                {
                    filterSuppliers = filterSuppliers.Where(c => c.CS.ToLower().Contains(CSFilter));
                }

                var isCSPhoneSearchable = Convert.ToBoolean(Request["columns[5][searchable]"].ToString());

                if (isCSPhoneSearchable)
                {
                    filterSuppliers = filterSuppliers.Where(c => c.CSPhone.ToLower().Contains(CSPhoneFilter));
                }

                var isContactSearchable = Convert.ToBoolean(Request["columns[6][searchable]"].ToString());

                if (isContactSearchable)
                {
                    filterSuppliers = filterSuppliers.Where(c => c.Contact.ToLower().Contains(ContactFilter));
                }
                var isContactPhoneSearchable = Convert.ToBoolean(Request["columns[7][searchable]"].ToString());

                if (isContactPhoneSearchable)
                {
                    filterSuppliers = filterSuppliers.Where(c => c.ContactPhone.ToLower().Contains(ContactPhoneFilter));
                }
            }
            else if (request.action == "filter_cancel")
            {
                filterSuppliers = allSuppliers;
            }
            else
            {
                filterSuppliers = allSuppliers;
            }
            #endregion

            #region 排序
            var isNameSortable         = Convert.ToBoolean(Request["columns[1][orderable]"]);
            var isPlatFormSortable     = Convert.ToBoolean(Request["columns[2][orderable]"]);
            var isUrlSortable          = Convert.ToBoolean(Request["columns[3][orderable]"]);
            var isCsSortable           = Convert.ToBoolean(Request["columns[4][orderable]"]);
            var isCsPhoneSortable      = Convert.ToBoolean(Request["columns[5][orderable]"]);
            var isContactSortable      = Convert.ToBoolean(Request["columns[6][orderable]"]);
            var isContactPhoneSortable = Convert.ToBoolean(Request["columns[7][orderable]"]);


            var sortColumnIndex = Convert.ToInt32(Request["order[0][column]"]);

            Func <Supplier, string> orderingFunction = (c =>
                                                        sortColumnIndex == 1 && isNameSortable ? c.Name :
                                                        sortColumnIndex == 2 && isNameSortable ? c.Platform :
                                                        sortColumnIndex == 3 && isNameSortable ? c.URL :
                                                        sortColumnIndex == 4 && isNameSortable ? c.CS :
                                                        sortColumnIndex == 5 && isNameSortable ? c.CSPhone.ToString() :
                                                        sortColumnIndex == 6 && isNameSortable ? c.Contact :
                                                        sortColumnIndex == 7 && isNameSortable ? c.ContactPhone.ToString() :

                                                        "");
            var sortDirection = Request["order[0][dir]"]; // asc or desc

            if (sortDirection == "asc")
            {
                filterSuppliers = filterSuppliers.OrderBy(orderingFunction);
            }

            if (sortDirection == "desc")
            {
                filterSuppliers = filterSuppliers.OrderByDescending(orderingFunction);
            }

            #endregion

            var displayedSuppliers = filterSuppliers.Skip(request.start).Take(request.length);
            var result             = from c in displayedSuppliers
                                     select new[] {
                Convert.ToString(c.ID)
                , c.Name
                , c.Platform
                , c.URL                            //StringUtil.CutString(StringUtil.RemoveHtml(c.Content), 100)
                , c.CS
                , c.CSPhone
                , c.Contact
                , c.ContactPhone
                , StringUtil.CutString(c.Address, 100)
                , Convert.ToString(c.ID)
            };
            return(Json(new
            {
                draw = request.draw,//param.sEcho,
                recordsTotal = allSuppliers.Count(),
                recordsFiltered = filterSuppliers.Count(),
                data = result
            },
                        JsonRequestBehavior.AllowGet));
        }
Example #26
0
        /// <summary>
        /// 获取分页列表数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ActionResult GetGridJson(SupplierRequest request)
        {
            var data = _supplier.GetDataListForPage(request);

            return(Content(data.ToJson()));
        }
        public JsonResult Datatable(SupplierRequest request)
        {
            #region 自定义动作
            if (!string.IsNullOrEmpty(request.customActionType))
            {
                string[]   id_Array = Request.Params.GetValues("id[]");
                List <int> ids      = new List <int>();
                foreach (string i in id_Array)
                {
                    ids.Add(int.Parse(i));
                }

                switch (request.customActionType)
                {
                case "group_action":

                    switch (request.customActionName)
                    {
                    case "delete":
                        this.ImsService.DeleteAgent(ids);
                        break;
                    }
                    break;

                case "delete":
                    this.ImsService.DeleteAgent(ids);
                    break;
                }
            }
            #endregion

            var allAgents = this.ImsService.GetAgentList(null);

            IEnumerable <Agent> filterAgents = allAgents;

            #region 搜索
            if (!string.IsNullOrEmpty(request.search))
            {
                var isNameSearchable = Convert.ToBoolean(Request["columns[1][searchable]"]);
            }
            else if (request.action == "filter")
            {
                var NameFilter         = Convert.ToString(Request["name"]).ToLower().Trim();
                var CodeFilter         = Convert.ToString(Request["code"]).ToLower().Trim();
                var ConsigneeFilter    = Convert.ToString(Request["consignee"]).ToLower().Trim();
                var ConsigneeTelFilter = Convert.ToString(Request["consigneetel"]).ToLower().Trim();
                var CSFilter           = Convert.ToString(Request["cs"]).ToLower().Trim();
                var CSQQFilter         = Convert.ToString(Request["csqq"]).ToLower().Trim();
                var EmailFilter        = Convert.ToString(Request["email"]).ToLower().Trim();
                var ManagerFilter      = Convert.ToString(Request["manager"]).ToLower().Trim();
                var ManagerPhoneFilter = Convert.ToString(Request["managerphone"]).ToLower().Trim();


                var isNameSearchable = Convert.ToBoolean(Request["columns[1][searchable]"].ToString());

                if (isNameSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.AgentName.ToLower().Contains(NameFilter));
                }

                var isCodeSearchable = Convert.ToBoolean(Request["columns[2][searchable]"].ToString());


                if (isCodeSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.AgentCode.ToLower().Contains(CodeFilter));
                }

                var isConsigeeSearchable = Convert.ToBoolean(Request["columns[3][searchable]"].ToString());

                if (isConsigeeSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.Consignee.ToLower().Contains(ConsigneeFilter));
                }

                var isConsigeeTelearchable = Convert.ToBoolean(Request["columns[4][searchable]"].ToString());

                if (isConsigeeTelearchable)
                {
                    filterAgents = filterAgents.Where(c => c.ConsigneeTel.ToLower().Contains(ConsigneeTelFilter));
                }

                var isCSSearchable = Convert.ToBoolean(Request["columns[5][searchable]"].ToString());

                if (isCSSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.CS.ToLower().Contains(CSFilter));
                }

                var isCSQQSearchable = Convert.ToBoolean(Request["columns[6][searchable]"].ToString());

                if (isCSQQSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.CSQQ.ToLower().Contains(CSQQFilter));
                }


                var isEmailSearchable = Convert.ToBoolean(Request["columns[7][searchable]"].ToString());

                if (isEmailSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.Email.ToLower().Contains(EmailFilter));
                }

                var isMangerSearchable = Convert.ToBoolean(Request["columns[7][searchable]"].ToString());

                if (isMangerSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.Email.ToLower().Contains(ManagerFilter));
                }

                var isManagerPhoneSearchable = Convert.ToBoolean(Request["columns[7][searchable]"].ToString());

                if (isManagerPhoneSearchable)
                {
                    filterAgents = filterAgents.Where(c => c.Email.ToLower().Contains(ManagerPhoneFilter));
                }
            }
            else if (request.action == "filter_cancel")
            {
                filterAgents = allAgents;
            }
            else
            {
                filterAgents = allAgents;
            }
            #endregion

            #region 排序
            var isNameSortable         = Convert.ToBoolean(Request["columns[1][orderable]"]);
            var isCodeFormSortable     = Convert.ToBoolean(Request["columns[2][orderable]"]);
            var isConSigneeSortable    = Convert.ToBoolean(Request["columns[3][orderable]"]);
            var isConSigneeTelSortable = Convert.ToBoolean(Request["columns[4][orderable]"]);
            var isCsSortable           = Convert.ToBoolean(Request["columns[5][orderable]"]);
            var isCsQQSortable         = Convert.ToBoolean(Request["columns[6][orderable]"]);
            var isEmailSortable        = Convert.ToBoolean(Request["columns[7][orderable]"]);
            var isManagerSortable      = Convert.ToBoolean(Request["columns[8][orderable]"]);
            var isManagerPhoneSortable = Convert.ToBoolean(Request["columns[9][orderable]"]);

            var sortColumnIndex = Convert.ToInt32(Request["order[0][column]"]);

            Func <Agent, string> orderingFunction = (c =>
                                                     sortColumnIndex == 1 && isNameSortable ? c.AgentName :
                                                     sortColumnIndex == 2 && isCodeFormSortable ? c.AgentCode :
                                                     sortColumnIndex == 3 && isConSigneeSortable ? c.Consignee :
                                                     sortColumnIndex == 4 && isConSigneeTelSortable ? c.ConsigneeTel :
                                                     sortColumnIndex == 5 && isCsSortable ? c.CS:
                                                     sortColumnIndex == 6 && isCsQQSortable ? c.CSQQ :
                                                     sortColumnIndex == 7 && isEmailSortable ? c.Email :
                                                     sortColumnIndex == 8 && isManagerSortable ? c.SaleManager :
                                                     sortColumnIndex == 9 && isManagerPhoneSortable ? c.SaleMangerMobile :
                                                     "");
            var sortDirection = Request["order[0][dir]"]; // asc or desc

            if (sortDirection == "asc")
            {
                filterAgents = filterAgents.OrderBy(orderingFunction);
            }

            if (sortDirection == "desc")
            {
                filterAgents = filterAgents.OrderByDescending(orderingFunction);
            }

            #endregion

            var displayedSuppliers = filterAgents.Skip(request.start).Take(request.length);
            var result             = from c in displayedSuppliers
                                     select new[] {
                Convert.ToString(c.ID)
                , c.AgentName
                , c.AgentCode
                , c.Consignee                            //StringUtil.CutString(StringUtil.RemoveHtml(c.Content), 100)
                , c.ConsigneeTel
                , c.CS
                , c.CSQQ
                , c.Email
                , c.SaleManager
                , c.SaleMangerMobile
                , Convert.ToString(c.ID)
            };
            return(Json(new
            {
                draw = request.draw,//param.sEcho,
                recordsTotal = allAgents.Count(),
                recordsFiltered = filterAgents.Count(),
                data = result
            },
                        JsonRequestBehavior.AllowGet));
        }