Beispiel #1
0
        public async Task <ActionResult> IuputFromExcel(OemDataViewModel model)
        {
            DataTable data = new DataTable();
            await Task.Run(() =>
            {
                string strExcel = "";

                OpenFileDialog openFileDialog   = new OpenFileDialog();
                openFileDialog.InitialDirectory = "c:\\";    //注意这里写路径时要用c:\\而不是c:\
                openFileDialog.Filter           = "文本文件|*.*|C#文件|*.cs|所有文件|*.*";
                openFileDialog.RestoreDirectory = true;
                openFileDialog.FilterIndex      = 1;
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    strExcel = openFileDialog.FileName;
                }
                data = ExcelToDataTable(strExcel);
            });

            return(Json(data));
        }
Beispiel #2
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public async Task <ActionResult> Query(OemDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (OemDataServiceClient client = new OemDataServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.LotNumber))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.LotNumber.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.OrderNumber))
                            {
                                where.AppendFormat(" {0} OrderNumber LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.OrderNumber.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.PackageNo))
                            {
                                where.AppendFormat(" {0} PackageNo LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.PackageNo.ToString().Trim().ToUpper());
                            }

                            if (!string.IsNullOrEmpty(model.PnName))
                            {
                                where.AppendFormat(" {0} PnName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.PnName.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.Grade))
                            {
                                where.AppendFormat(" {0} Grade LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Grade.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.Color))
                            {
                                where.AppendFormat(" {0} Color LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Color.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.PsSubCode))
                            {
                                where.AppendFormat(" {0} PsSubCode LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.PsSubCode.ToString().Trim().ToUpper());
                            }
                            if (!string.IsNullOrEmpty(model.Status))
                            {
                                where.AppendFormat(" {0} Status LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Status.ToString().Trim().ToUpper());
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <OemData> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.OemDataList  = result.Data;
                        }
                    });
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", model));
            }
            else
            {
                return(View(model));
            }
        }