Example #1
0
        private void AutoCompleteClothes(string lotno)
        {
            Clothes clothes = GetClothes(lotno);

            if (clothes == null)
            {
                return;
            }
            gridView.SetFocusedRowCellValue(colStyleNo, clothes.StyleNo);
            gridView.SetFocusedRowCellValue(colColor, clothes.Color);
        }
Example #2
0
        private List <string[]> GetCartonData(int cartonNo)
        {
            List <string[]> list = new List <string[]>();

            string[] data    = null;
            string   artNo   = string.Empty;
            Clothes  clothes = null;

            #region 开始找第一SizeNo的行号及列号

            int nBegSizeNoCol = 3, nEndSizeNoCol = 36, nTotalCol = 37;
            int sumBefore = (cartonNo - 1) * CartonSize;
            int sumTemp = 0, nTemp = 0;
            int nRow = 0, nCol = 3, nDif = 0;

            bool bFind = false;
            //首先定位第一个元素的位置
            Object obj = null;

            if (sumBefore == 0)
            {
                goto start;
            }
            for (int i = 0; i < gridView.RowCount; i++)
            {
                //直接加 小计
                obj = gridView.GetRowCellValue(i, gridView.Columns[nTotalCol]);
                if (obj != null)
                {
                    nTemp = Convert.ToInt32(obj);
                }
                if (sumTemp + nTemp <= sumBefore)
                {
                    sumTemp += nTemp;
                    continue;
                }

                nRow = i;//开始行号

                //按列加
                for (int j = nBegSizeNoCol; j <= nEndSizeNoCol; j++)
                {
                    obj = gridView.GetRowCellValue(i, gridView.Columns[j]);
                    if (obj == null || string.IsNullOrEmpty(obj.ToString().Trim()))
                    {
                        continue;
                    }
                    nTemp = Convert.ToInt32(obj);

                    if (sumTemp + nTemp < sumBefore)
                    {
                        sumTemp += nTemp;
                        continue;
                    }

                    //正好找到了
                    if (sumTemp + nTemp == sumBefore)
                    {
                        if (j < nEndSizeNoCol)
                        {
                            nCol = j + 1;
                        }
                        else
                        {
                            nRow += 1;
                            nCol  = nBegSizeNoCol;
                        }
                    }
                    else
                    {
                        nCol = j;
                        nDif = nTemp - (sumBefore - sumTemp);
                    }

                    bFind = true;
                    break;
                }//end for j

                if (bFind == true)
                {
                    break;
                }
            }//end for i

            #endregion

            #region  nDif >= CartonSize

            if (nDif >= CartonSize)
            {
                data       = new string[37];
                data[nCol] = CartonSize.ToString();
                artNo      = gridView.GetRowCellValue(nRow, "LotNo").ToString();
                clothes    = GetClothes(artNo);
                if (clothes != null)
                {
                    data[0] = clothes.ShellNo;
                    data[1] = artNo;
                    data[2] = clothes.Color;
                }
                list.Add(data);
                return(list);
            }

            #endregion

            #region 只有一行

            start :   data = new string[37];
            artNo          = gridView.GetRowCellValue(nRow, "LotNo").ToString();
            clothes        = GetClothes(artNo);
            if (clothes != null)
            {
                data[0] = clothes.ShellNo;
                data[1] = artNo;
                data[2] = clothes.Color;

                nTemp = 0;
                if (nDif == 0)
                {
                    obj = gridView.GetRowCellValue(nRow, gridView.Columns[nCol]);
                    if (obj != null && string.IsNullOrEmpty(obj.ToString().Trim()) == false)
                    {
                        nTemp = Convert.ToInt32(obj);
                    }
                    if (nTemp <= CartonSize)
                    {
                        if (nTemp > 0)
                        {
                            data[nCol] = nTemp.ToString();
                        }
                        nDif = nTemp;
                    }
                    else
                    {
                        data[nCol] = CartonSize.ToString();
                        nDif       = nTemp - Convert.ToInt32(obj);
                        sumTemp    = CartonSize;

                        list.Add(data);
                        return(list);
                    }
                }
                else
                {
                    data[nCol] = nDif.ToString();
                }
            }

            sumTemp = nDif;
            int nEndCol = nCol;
            for (int j = nCol + 1; j <= nEndSizeNoCol; j++)
            {
                obj = gridView.GetRowCellValue(nRow, gridView.Columns[j]);
                if (obj == null || string.IsNullOrEmpty(obj.ToString().Trim()))
                {
                    continue;
                }
                nTemp = Convert.ToInt32(obj);
                if (sumTemp + nTemp < CartonSize)
                {
                    sumTemp += nTemp;
                    data[j]  = nTemp.ToString();
                    continue;
                }
                else
                {
                    data[j]  = (CartonSize - sumTemp).ToString();
                    sumTemp += nTemp;
                    break;
                }
            }

            list.Add(data);

            if (sumTemp >= CartonSize)
            {
                return(list);
            }

            #endregion

            #region 大于一行

            for (int i = nRow + 1; i < gridView.RowCount; i++)
            {
                data    = new string[37];
                artNo   = gridView.GetRowCellValue(i, "LotNo").ToString();
                clothes = GetClothes(artNo);
                if (clothes != null)
                {
                    data[0] = clothes.ShellNo;
                    data[1] = artNo;
                    data[2] = clothes.Color;
                }
                if (sumTemp < CartonSize)
                {
                    list.Add(data);
                }

                for (int j = nBegSizeNoCol; j <= nEndSizeNoCol; j++)
                {
                    obj = gridView.GetRowCellValue(i, gridView.Columns[j]);
                    if (obj == null || string.IsNullOrEmpty(obj.ToString().Trim()))
                    {
                        continue;
                    }
                    nTemp = Convert.ToInt32(obj);
                    if (sumTemp + nTemp < CartonSize)
                    {
                        sumTemp += nTemp;
                        data[j]  = nTemp.ToString();
                        continue;
                    }
                    else
                    {
                        data[j]  = (CartonSize - sumTemp).ToString();
                        sumTemp += nTemp;
                        break;
                    }
                }
            }

            #endregion

            return(list);
        }
        public static void GetData(ISheet sheet, OutBound outbound, GridView grid)
        {
            IRow  eRow  = null;
            ICell eCell = null;

            //导出日期
            eRow  = sheet.GetRow(1);
            eCell = eRow.GetCell(35);
            eCell.SetCellValue(GetEinglishDate(outbound.CreateTime));
            eCell.CellStyle.VerticalAlignment = VerticalAlignment.Center;
            eCell.CellStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.Left;

            //导出订单编号
            eRow  = sheet.GetRow(2);
            eCell = eRow.GetCell(35);
            eCell.SetCellValue(outbound.OrderNo);
            eCell.CellStyle.VerticalAlignment = VerticalAlignment.Center;
            eCell.CellStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.Left;


            //导出客户编号
            eRow  = sheet.GetRow(3);
            eCell = eRow.GetCell(35);
            eCell.SetCellValue(outbound.CustomerNo);
            eCell.CellStyle.VerticalAlignment = VerticalAlignment.Center;
            eCell.CellStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.Left;

            //导出shell To
            eRow  = sheet.GetRow(5);
            eCell = eRow.GetCell(2);
            eCell.SetCellValue(outbound.SellTo);
            eCell.CellStyle.VerticalAlignment = VerticalAlignment.Center;
            eCell.CellStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.Left;

            //地址
            eRow  = sheet.GetRow(6);
            eCell = eRow.GetCell(2);
            eCell.SetCellValue(outbound.ShipAddress);
            eCell.CellStyle.VerticalAlignment = VerticalAlignment.Top;
            eCell.CellStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.Left;
            eCell.CellStyle.WrapText          = true;

            //导出ship to
            eRow  = sheet.GetRow(5);
            eCell = eRow.GetCell(28);
            eCell.SetCellValue(outbound.ShipTo);
            eCell.CellStyle.VerticalAlignment = VerticalAlignment.Top;
            eCell.CellStyle.Alignment         = NPOI.SS.UserModel.HorizontalAlignment.Left;
            eCell.CellStyle.WrapText          = true;

            //导出 Shipway
            sheet.GetRow(9).GetCell(2).SetCellValue(outbound.Shippingway);

            //导出 Terms
            sheet.GetRow(9).GetCell(28).SetCellValue(outbound.Term);

            int begRow = 13, begCol = 0;

            int ssRow = grid.RowCount;
            int ssCol = grid.Columns.Count;

            string  artNo   = string.Empty;
            Clothes clothes = null;
            Object  obj     = null;

            for (int i = 0, j = 1; i < ssRow; i++)
            {
                artNo   = grid.GetRowCellDisplayText(i, "LotNo");
                clothes = GetClothes(artNo);
                if (clothes == null)
                {
                    continue;
                }

                j = 0;//Lot#
                sheet.GetRow(begRow + i).GetCell(begCol + j).SetCellValue(clothes.ShellNo);

                j++;//Art#
                sheet.GetRow(begRow + i).GetCell(begCol + j).SetCellValue(artNo);

                j++;//Color
                sheet.GetRow(begRow + i).GetCell(begCol + j).SetCellValue(clothes.Color);

                for (j = 3; j < ssCol - 3; j++)
                {
                    obj = grid.GetRowCellValue(i, grid.Columns[j]);

                    if (obj != null && string.IsNullOrEmpty(obj.ToString()) == false)
                    {
                        sheet.GetRow(begRow + i).GetCell(begCol + j).SetCellValue(Convert.ToInt32(obj));
                    }
                }

                obj = grid.GetRowCellValue(i, grid.Columns[j]);
                if (obj != null && string.IsNullOrEmpty(obj.ToString()) == false)
                {
                    sheet.GetRow(begRow + i).GetCell(begCol + j).SetCellValue(Convert.ToDouble(obj));
                }

                j++;
                obj = grid.GetRowCellValue(i, grid.Columns[j]);
                if (obj != null && string.IsNullOrEmpty(obj.ToString()) == false)
                {
                    sheet.GetRow(begRow + i).GetCell(begCol + j).SetCellValue(Convert.ToDouble(obj));
                }
            }

            int idxShipping = GetShippingRowNo(grid.RowCount);

            //导出 Shipping
            if (string.IsNullOrEmpty(outbound.Freight) == false)
            {
                sheet.GetRow(idxShipping).GetCell(39).SetCellValue(Convert.ToDouble(outbound.Freight));
            }
        }