Beispiel #1
0
 public static void GridWizard(QuickGrid grid,
     DataTable table,bool isMetric,IsNewAllowed isNewAllowed,
     IsReadOnly isReadOnly,
     string sortingField,GetFieldDelegate getField,
     HelperFunctions.DataGridClientInterface face,params string[] fieldsIn)
 {
     // When you get the field properties than the leading "*" is stripped
     string[] fields = (string[])fieldsIn.Clone();
     fieldsIn.CopyTo(fields,0);
     HelperFunctions.FieldProperties[] fieldProperties = HelperFunctions.GetProperties(ref fields,isMetric);
     DataTable newTable = new DataTable();
     for (int i=0;i<fields.Length;i++)
     {
         newTable.Columns.Add(fields[i],fieldProperties[i].type);
     }
     for (int i=0;i<table.Rows.Count;i++)
     {
         if (!DataInterface.IsRowAlive(table.Rows[i]))
             continue;
         DataRow targetRow = newTable.NewRow();
         foreach (string fieldName in fields)
         {
             object o = getField(table.Rows[i],isMetric,fieldName);
             targetRow[fieldName] = o;
         }
         newTable.Rows.Add(targetRow);
     }
     DataView view = new DataView(newTable,"",sortingField,
         DataViewRowState.CurrentRows);
     HelperFunctions.UpdateGrid(view,grid,face,isMetric,
         isNewAllowed,isReadOnly,fieldsIn);
 }
Beispiel #2
0
        public static void SetupContainerGrids(EMDataSet emDataSet,
            int contID,QuickGrid bundleGrid,
            QuickGrid weightGrid,
            HelperFunctions.DataGridClientInterface face,IsReadOnly isReadOnly,
            out decimal totalLbs,out decimal totalKgs,
            GetBillOfLadingNumberFunc func)
        {
            string[] bolFieldList = {"*BundleSeqNumber","*PONumber",
                "*ItemName","*SizeOfItem","MetricShipQty",
                "EnglishShipQty","Heat",
                "BayNumber","InvoiceNumber","MillInvoiceDate","BundleAlloySurcharge",
                "BundleScrapSurcharge",
                "EMInvoiceNumber",
                "PickupDate","PickupTerminal","ProofOfDelivery","*CancelDate",
                "ContainerBundleID"};
            EMDataSet.ContainerTblRow contRow = emDataSet.ContainerTbl.FindByContID(contID);
            bool showLessFields = !contRow.IsApplyClosingToEntireContainerNull() &&
                contRow.ApplyClosingToEntireContainer!=0;
            if (showLessFields)
            {
                bolFieldList = new string[]{"*BundleSeqNumber","*PONumber",
                                            "*ItemName","*SizeOfItem","MetricShipQty",
                                            "EnglishShipQty","Heat",
                                            "BayNumber","InvoiceNumber","MillInvoiceDate",
                                            "BundleAlloySurcharge","BundleScrapSurcharge","EMInvoiceNumber",
                                            "*CancelDate",
                                            "ContainerBundleID"};

            }
            BundleFieldHelper bundleFieldHelper = new BundleFieldHelper();
            bundleFieldHelper.m_getter = func;
            GridWizard(bundleGrid,emDataSet.ContBundleTbl,false,
                IsNewAllowed.No,isReadOnly,"BundleSeqNumber",
                new GetFieldDelegate(bundleFieldHelper.GetBundleField),
                face,bolFieldList);

            bundleGrid.SetCancelColumn("CancelDate");

            DataTable weightTable = new DataTable();

            weightTable.Clear();
            weightTable.Columns.Clear();
            weightTable.Columns.Add("PONumber",typeof(string));
            weightTable.Columns.Add("ItemName",typeof(string));
            weightTable.Columns.Add("ItemDesc",typeof(string));
            weightTable.Columns.Add("SizeOfItem",typeof(string));
            weightTable.Columns.Add("MetricShipQty",typeof(decimal));
            weightTable.Columns.Add("EnglishShipQty",typeof(decimal));
            weightTable.Columns.Add("POItemNumber",typeof(int));

            totalKgs = 0;
            totalLbs = 0;
            foreach (EMDataSet.ContBundleTblRow sourceRow in emDataSet.ContBundleTbl.Rows)
            {
                if (!DataInterface.IsRowAlive(sourceRow))
                    continue;
                EMDataSet.POItemTblRow itemRow = sourceRow.POItemTblRow;
                EMDataSet.POHeaderTblRow poRow = itemRow.POHeaderTblRow;
                DataRow weightRow = weightTable.NewRow();
                weightRow["PONumber"] = poRow.PONumber;
                weightRow["ItemName"] = itemRow.ItemTblRow.ItemName;
                weightRow["ItemDesc"] = itemRow["ItemDesc"];
                weightRow["EnglishShipQty"] = sourceRow["EnglishShipQty"];
                if (!sourceRow.IsNull("EnglishShipQty"))
                {
                    totalLbs += (decimal)sourceRow["EnglishShipQty"];
                }
                weightRow["MetricShipQty"] = sourceRow["MetricShipQty"];
                if (!sourceRow.IsNull("MetricShipQty"))
                {
                    totalKgs += (decimal)sourceRow["MetricShipQty"];
                }
                weightRow["SizeOfItem"] = itemRow["SizeOfItem"];
                weightRow["POItemNumber"] = itemRow.POItemNumber;
                weightTable.Rows.Add(weightRow);
            }

            // Collapse the weightTable
            for (int i=0;i<weightTable.Rows.Count;i++)
            {
                DataRow masterRow = weightTable.Rows[i];
                if (!DataInterface.IsRowAlive(masterRow))
                    continue;
                int poItemNumber = (int)masterRow["POItemNumber"];
                for (int j=i+1;j<weightTable.Rows.Count;j++)
                {
                    DataRow compareRow = weightTable.Rows[j];
                    if (!DataInterface.IsRowAlive(compareRow))
                        continue;
                    if (((int)compareRow["POItemNumber"]) == poItemNumber) // same item
                    {
                        if (masterRow.IsNull("MetricShipQty"))
                            masterRow["MetricShipQty"] = (decimal)0;
                        if (masterRow.IsNull("EnglishShipQty"))
                            masterRow["EnglishShipQty"] = (decimal)0;
                        decimal metricShipQty = (decimal)masterRow["MetricShipQty"];
                        decimal englishShipQty = (decimal)masterRow["EnglishShipQty"];
                        if (!compareRow.IsNull("MetricShipQty"))
                            metricShipQty += (decimal)compareRow["MetricShipQty"];
                        if (!compareRow.IsNull("EnglishShipQty"))
                            englishShipQty += (decimal)compareRow["EnglishShipQty"];
                        masterRow["MetricShipQty"] = metricShipQty;
                        masterRow["EnglishShipQty"] = englishShipQty;
                        compareRow.Delete();
                        j--;
                    }
                }
            }
            DataView weightView = new DataView(weightTable,"","ItemName",DataViewRowState.CurrentRows);
            HelperFunctions.UpdateGrid(weightView,weightGrid,null,false,IsNewAllowed.No,
                IsReadOnly.Yes,"PONumber","ItemName","ItemDesc","SizeOfItem",
                "MetricShipQty","EnglishShipQty");
        }