Exemplo n.º 1
0
        //获取经供应商转换所得生产厂商信息
        public Manufacturer GetSupplierToManufacturer(string materialCode, string orderNumber, Supplier s)
        {
            Manufacturer mf = null;

            if (s != null)
            {
                using (SupplierToManufacturerServiceClient clients = new SupplierToManufacturerServiceClient())
                {
                    PagingConfig cfg0 = new PagingConfig()
                    {
                        Where = string.Format(@"Key.MaterialCode='{0}' AND Key.SupplierCode='{1}'"
                                              , materialCode
                                              , s.Key)
                    };
                    MethodReturnResult <IList <SupplierToManufacturer> > result = clients.Gets(ref cfg0);
                    if (result.Code <= 0 && result.Data.Count > 0)
                    {
                        if (result.Data[0].Key.OrderNumber == "*")
                        {
                            using (ManufacturerServiceClient clientss = new ManufacturerServiceClient())
                            {
                                MethodReturnResult <Manufacturer> rsts = clientss.Get(result.Data[0].ManufacturerCode);
                                if (rsts.Data != null)
                                {
                                    mf = rsts.Data;
                                }
                            }
                        }
                        else
                        {
                            PagingConfig cfg1 = new PagingConfig()
                            {
                                Where = string.Format(@"Key.MaterialCode='{0}' AND Key.OrderNumber='{1}' AND Key.SupplierCode='{2}'"
                                                      , materialCode
                                                      , orderNumber
                                                      , s.Key)
                            };
                            MethodReturnResult <IList <SupplierToManufacturer> > results = clients.Gets(ref cfg1);
                            if (results.Code <= 0 && results.Data.Count > 0)
                            {
                                using (ManufacturerServiceClient clientss = new ManufacturerServiceClient())
                                {
                                    MethodReturnResult <Manufacturer> rsts = clientss.Get(results.Data[0].ManufacturerCode);
                                    if (rsts.Data != null)
                                    {
                                        mf = rsts.Data;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(mf);
        }
        //
        // GET: /ZPVM/SupplierToManufacturer/
        public async Task <ActionResult> Index()
        {
            using (SupplierToManufacturerServiceClient client = new SupplierToManufacturerServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <SupplierToManufacturer> > result = client.Gets(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new SupplierToManufacturerQueryViewModel()));
        }
        public async Task <ActionResult> Query(SupplierToManufacturerQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (SupplierToManufacturerServiceClient client = new SupplierToManufacturerServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.MaterialCode))
                            {
                                where.AppendFormat(" {0} Key.MaterialCode LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.MaterialCode.ToString().Trim().ToUpper());
                            }

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

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

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

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (SupplierToManufacturerServiceClient client = new SupplierToManufacturerServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <SupplierToManufacturer> > result = client.Gets(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> ExportToExcelWl(LotMaterialListViewModel model)
        {
            DataTable dt = new DataTable();
            MethodReturnResult <DataSet> result = new MethodReturnResult <DataSet>();

            using (LotQueryServiceClient client = new LotQueryServiceClient())

            {
                RPTLotMateriallistParameter param = new RPTLotMateriallistParameter();
                param.LotNumber = model.LotNumber;
                param.PageSize  = model.PageSize;
                param.PageNo    = -1;

                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key.LotNumber,ItemNo",
                        Where   = GetQueryCondition(model)
                    };

                    MethodReturnResult <DataSet> ds = client.GetRPTLotMaterialList(ref param);
                    dt = ds.Data.Tables[0];
                });
            }

            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.Thin;
            style.BorderLeft   = BorderStyle.Thin;
            style.BorderRight  = BorderStyle.Thin;
            style.BorderTop    = BorderStyle.Thin;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);

            ISheet ws = null;

            for (int j = 0; j < dt.Rows.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws = wb.CreateSheet();
                    IRow  row  = ws.CreateRow(0);
                    ICell cell = null;
                    #region //列名
                    foreach (DataColumn dc in dt.Columns)
                    {
                        cell           = row.CreateCell(row.Cells.Count);
                        cell.CellStyle = style;
                        cell.SetCellValue(dc.Caption);
                    }
                    #endregion
                    font.Boldweight = 5;
                }
                IRow rowData = ws.CreateRow(j + 1);
                #region //数据
                ICell cellData = null;

                foreach (DataColumn dc in dt.Columns)
                {
                    System.Data.DataRow obj = dt.Rows[j];
                    Manufacturer        mf  = null;
                    using (SupplierToManufacturerServiceClient clients = new SupplierToManufacturerServiceClient())
                    {
                        PagingConfig cfg0 = new PagingConfig()
                        {
                            Where = string.Format(@"Key.MaterialCode='{0}' AND Key.SupplierCode='{1}'"
                                                  , obj["MATERIAL_CODE"]
                                                  , obj["SUPPLIER_CODE"])
                        };
                        MethodReturnResult <IList <SupplierToManufacturer> > results = clients.Gets(ref cfg0);
                        if (results.Code <= 0 && results.Data.Count > 0)
                        {
                            if (results.Data[0].Key.OrderNumber == "*")
                            {
                                using (ManufacturerServiceClient clientss = new ManufacturerServiceClient())
                                {
                                    MethodReturnResult <Manufacturer> rsts = clientss.Get(results.Data[0].ManufacturerCode);
                                    if (rsts.Data != null)
                                    {
                                        mf = rsts.Data;
                                    }
                                }
                            }
                            else
                            {
                                PagingConfig cfg1 = new PagingConfig()
                                {
                                    Where = string.Format(@"Key.MaterialCode='{0}' AND Key.OrderNumber='{1}' AND Key.SupplierCode='{2}'"
                                                          , obj["MATERIAL_CODE"]
                                                          , obj["ORDER_NUMBER"]
                                                          , obj["SUPPLIER_CODE"])
                                };
                                MethodReturnResult <IList <SupplierToManufacturer> > resultss = clients.Gets(ref cfg1);
                                if (resultss.Code <= 0 && resultss.Data.Count > 0)
                                {
                                    using (ManufacturerServiceClient clientss = new ManufacturerServiceClient())
                                    {
                                        MethodReturnResult <Manufacturer> rsts = clientss.Get(resultss.Data[0].ManufacturerCode);
                                        if (rsts.Data != null)
                                        {
                                            mf = rsts.Data;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;

                    if (dc.DataType == typeof(double) || dc.DataType == typeof(float))
                    {
                        if (dc.ColumnName == "SUPPLIER_CODE")
                        {
                            cellData.SetCellValue(mf == null ? Convert.ToString(dt.Rows[j][dc]) : mf.Key);
                        }
                        else if (dc.ColumnName == "SUPPLIER_NAME")
                        {
                            cellData.SetCellValue(mf == null ? Convert.ToString(dt.Rows[j][dc]) : mf.Name);
                        }
                        else
                        {
                            cellData.SetCellValue(Convert.ToDouble(dt.Rows[j][dc]));
                        }
                    }
                    else if (dc.DataType == typeof(int))
                    {
                        if (dc.ColumnName == "SUPPLIER_CODE")
                        {
                            cellData.SetCellValue(mf == null ? Convert.ToString(dt.Rows[j][dc]) : mf.Key);
                        }
                        else if (dc.ColumnName == "SUPPLIER_NAME")
                        {
                            cellData.SetCellValue(mf == null ? Convert.ToString(dt.Rows[j][dc]) : mf.Name);
                        }
                        else
                        {
                            cellData.SetCellValue(Convert.ToInt32(dt.Rows[j][dc]));
                        }
                    }
                    else
                    {
                        if (dc.ColumnName == "SUPPLIER_CODE")
                        {
                            cellData.SetCellValue(mf == null ? Convert.ToString(dt.Rows[j][dc]) : mf.Key);
                        }
                        else if (dc.ColumnName == "SUPPLIER_NAME")
                        {
                            cellData.SetCellValue(mf == null ? Convert.ToString(dt.Rows[j][dc]) : mf.Name);
                        }
                        else
                        {
                            cellData.SetCellValue(Convert.ToString(dt.Rows[j][dc]));
                        }
                    }
                }
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "LotMaterialData.xls"));
        }