public CurrencyFiller(EMDataSet emDataSet) { m_emDataSet = emDataSet; InitializeComponent(); // find all the currencies in the dataset and then // add each of them to the dataview ArrayList listOfCurrencies = new ArrayList(); foreach (EMDataSet.POHeaderTblRow row in emDataSet.POHeaderTbl.Rows) { if (row.IsCurrencyIDNull()) continue; if (row.CurrencyID == 0) // U.S. continue; listOfCurrencies.Add(row.CurrencyID); } AdapterHelper.Unique(ref listOfCurrencies); foreach (int currencyId in listOfCurrencies) { EMDataSet.CurrencyTblRow currencyRow = emDataSet.CurrencyTbl.FindByCurrencyID(currencyId); string currencyName = currencyRow.CurrencyName; string[] values = new string[] { currencyName, ""}; currencyGrid.Rows.Add(values); this.currencyGrid.Rows[currencyGrid.Rows.Count - 1].Tag = currencyId ; } }
public ShowCompletedPODlg(EMDataSet poDataSet,string friendlyConstraintsText) { m_emDataSet = poDataSet; m_emDataSet.AcceptChanges(); InitializeComponent(); percentEdt.Text = "80"; this.constraintsEdt.Text = friendlyConstraintsText; MyRefresh(); }
public static object DefaultGetBillOfLadingNumber(EMDataSet.ContBundleTblRow sourceRow) { EMDataSet.BOLItemTblRow[] bolItems = new EMDataSet.BOLItemTblRow[1]; if (bolItems.Length > 1) throw new Exception("BUG, too many bill of ladings for a bundle"); if (bolItems.Length == 0) return DBNull.Value;; EMDataSet.BOLItemTblRow bolItem = bolItems[0]; EMDataSet.BOLTblRow bolRow = bolItem.BOLTblRow; return bolRow["BOLNumber"]; }
public BatchAddInvoice(EMDataSet emDataSet,List<EMDataSet.POHeaderTblRow> notYetInvoicedRows) { m_emDataSet = emDataSet; InitializeComponent(); foreach (EMDataSet.POHeaderTblRow row in notYetInvoicedRows) { TaggedItem tagged = new TaggedItem(row.POID,row.PONumber); poList.Items.Add(tagged); } System.DateTime dateTime = System.DateTime.Today; invoiceDateEdt.Text = HelperFunctions.ToDateText(dateTime); }
public static void Update() { EMDataSet emDataSet = new EMDataSet(); using (new OpenConnection(EM.IsWrite.Yes,AdapterHelper.Connection)) using (new TurnOffConstraints(emDataSet)) { AdapterHelper.FillAllPOHeaders(emDataSet); foreach( EMDataSet.POHeaderTblRow row in emDataSet.POHeaderTbl) { row.InvoiceNumber = ""; } AdapterHelper.CommitAllPOHeaders(emDataSet); } }
public static void FillContainerFromDatabase(EMDataSet emDataSet,int contID) { using (new OpenConnection(IsWrite.No,AdapterHelper.Connection)) using (new TurnOffConstraints(emDataSet)) { AdapterHelper.FillContainerHeader(emDataSet,contID); AdapterHelper.FillContBundle(emDataSet,contID); foreach (EMDataSet.BOLItemTblRow bolItemRow in emDataSet.BOLItemTbl.Rows) { int bolID = bolItemRow.BOLID; AdapterHelper.FillBillOfLading(emDataSet,bolID); } AdapterHelper.FillOutConstraints(emDataSet); } }
public override void CommitTablesToDataSource() { using (new OpenConnection(EM.IsWrite.Yes, AdapterHelper.Connection)) { if (DataInterface.IsRowAlive(GetHeaderRow()) && GetHeaderRow().RowState != DataRowState.Added) { if (GetHeaderRow().ItemName != (string) GetHeaderRow()["ItemName", DataRowVersion.Original]) { EMDataSet tempDataSet = new EMDataSet(); using (new TurnOffConstraints(tempDataSet)) { OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.SelectCommand = new OleDbCommand(); adapter.SelectCommand.CommandText = "SELECT ItemID,ItemName,CompID FROM " + "tblItem where ItemName = '" + GetHeaderRow().ItemName + "' AND CompID = " + GetHeaderRow().CompID.ToString(); adapter.SelectCommand.Connection = AdapterHelper.Connection; adapter.Fill(tempDataSet.ItemTbl); if (tempDataSet.ItemTbl.Rows.Count > 1) throw new Exception("BUG: There are too many rows with that item name"); if (tempDataSet.ItemTbl.Rows.Count == 1) { int newItemID = (int)tempDataSet.ItemTbl.Rows[0]["ItemID"]; tempDataSet.Clear(); DialogResult res = MessageBox.Show("There is already an item with this name. Would you like " + "to merge the item with this one? This will update all purchase orders that " + "have this item.", "Merge Item?", MessageBoxButtons.YesNo); if (res == DialogResult.No) return; // We will update all the POs to the other item. Then delete the current item. UpdatePOItems(GetHeaderRow().ItemID, newItemID); GetHeaderRow().Delete(); } tempDataSet.Clear(); } } } AdapterHelper.UpdateItemsFromCompID(m_emDataSet); } }
public NewExcelHelper(EMDataSet.ContainerTblRow headerRow) { Type tApp = Type.GetTypeFromProgID("Excel.Application"); object application = Activator.CreateInstance(tApp); tApp.InvokeMember("Visible", BindingFlags.SetProperty, null, application, new object[] { true }); object workbooks = tApp.InvokeMember("Workbooks", BindingFlags.GetProperty, null, application, new object[] { }); Marshal.ReleaseComObject(application); Type tWorkbooks = workbooks.GetType(); string tempDirectory = Path.GetTempPath(); string tempXLS = tempDirectory + "\\tmpitl.xls"; File.Copy("m:\\shipping_notices\\itl.xls", tempXLS, true); object workbook = tWorkbooks.InvokeMember("Open", BindingFlags.InvokeMethod, null, workbooks, new object[] { tempXLS }); Marshal.ReleaseComObject(workbooks); Type tWorkbook = workbook.GetType(); sheet = tWorkbook.InvokeMember("ActiveSheet", BindingFlags.GetProperty, null, workbook, new object[] { }); Marshal.ReleaseComObject(workbook); tSheet = sheet.GetType(); JoinContainerDatabase(headerRow); }
public CrystalViewer(EMDataSet dataSet,bool isPO) { // // Required for Windows Form Designer support // InitializeComponent(); ParameterFields fields= new ParameterFields(); ParameterField field = new ParameterField(); field.ParameterFieldName = "isPO"; ParameterDiscreteValue discrete = new ParameterDiscreteValue(); discrete.Value = isPO; field.CurrentValues.Add(discrete); fields.Add(field); CrystalReport1 c = new CrystalReport1(); crystalReportViewer1.ParameterFieldInfo = fields; EMDataSet copy = (EMDataSet)dataSet.Copy(); c.SetDataSource(copy); crystalReportViewer1.ReportSource = c; // // TODO: Add any constructor code after InitializeComponent call // }
public static void ShowReport(EMDataSet emDataSet,int contid,string reportDescription) { GenericCrystalViewer view = new GenericCrystalViewer(); view.Text = "Balance Report"; BalanceReport report = new BalanceReport(); report.SetDataSource(emDataSet); view.viewer.ReportSource = report; ParameterFields fields = new ParameterFields(); ParameterField field = new ParameterField(); field.ParameterFieldName = "contNumber"; ParameterDiscreteValue discrete = new ParameterDiscreteValue(); discrete.Value = emDataSet.ContainerTbl.FindByContID(contid).ContNumber; field.CurrentValues.Add(discrete); fields.Add(field); ParameterField field2 = new ParameterField(); field2.ParameterFieldName = "ReportDescription"; ParameterDiscreteValue discrete2 = new ParameterDiscreteValue(); discrete2.Value = reportDescription; field2.CurrentValues.Add(discrete2); fields.Add(field2); view.viewer.ParameterFieldInfo = fields; view.Show(); }
private void Swap(EMDataSet.POItemTblRow row1,EMDataSet.POItemTblRow row2) { if (row1 == null) return; if (row2 == null) return; int tempSeq = row1.SeqNumber; row1.SeqNumber = row2.SeqNumber; row2.SeqNumber = tempSeq; }
public override void CommitTablesToDatabase() { using (DataInterface.CreateLockFile("po.lock")) using (new OpenConnection(IsWrite.Yes,AdapterHelper.Connection)) { EMDataSet tempDataSet = new EMDataSet(); using (new TurnOffConstraints(tempDataSet)) { AdapterHelper.FillCurrency(tempDataSet); AdapterHelper.FillPOHeader(tempDataSet,base.CurrentKey); AdapterHelper.FillPOItem(tempDataSet,base.CurrentKey); AdapterHelper.FillOutConstraints(tempDataSet); } if (!IsEmptyTable()) { EMDataSet.POHeaderTblRow row = GetHeaderRow(); if (DataInterface.IsRowAlive(row)) CompareForValidaty(m_emDataSet,tempDataSet); } AdapterHelper.CommitPOChanges(m_emDataSet); } }
private void OnLocationChanged(EMDataSet dataSet,AutoCompleteComboBox box, AutoCompleteTextBox addressEdt,AutoCompleteTextBox countryEdt, AutoCompleteComboBox companyCombo) { int locationID = ((TaggedItem)box.SelectedItem).key; EMDataSet.LocationTblRow row = dataSet.LocationTbl.FindByLocID(locationID); int countryID = row.CountryID; EMDataSet.CountryTblRow countryRow = dataSet.CountryTbl.FindByCountryID(countryID); addressEdt.Text = row.Address; countryEdt.Text = countryRow.CountryName; box.Text = row.LocName; }
private void OnContactChanged(EMDataSet dataSet,AutoCompleteComboBox box,AutoCompleteTextBox contactEdt, AutoCompleteTextBox phoneEdt,AutoCompleteTextBox faxEdt,AutoCompleteTextBox emailEdt) { TaggedItem item = (TaggedItem)box.SelectedItem; int contactsID = item.key; EMDataSet.ContactsTblRow row = dataSet.ContactsTbl.FindByContactID(contactsID); contactEdt.Text = row.FirstName + " " + row.LastName; phoneEdt.Text = row.Phone; faxEdt.Text = row.Fax; emailEdt.Text = row.EMail; }
public static void CompareForValidaty(EMDataSet unsavedDataSet,EMDataSet currentDataSet) { DataInterface.CheckForChanges("POItemNumber","Sequence Number","SeqNumber", "SeqNumber",currentDataSet.POItemTbl, unsavedDataSet.POItemTbl); }
public static DataView GetViewFrom(EMDataSet.POItemTblDataTable table) { DataView view = new DataView(table,"","SeqNumber",DataViewRowState.CurrentRows); return view; }
public override bool IsDeleteAllowed() { using (new OpenConnection(EM.IsWrite.Yes,AdapterHelper.Connection)) { EMDataSet tempDataSet = new EMDataSet(); using (new TurnOffConstraints(tempDataSet)) { OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.SelectCommand = new OleDbCommand(); adapter.SelectCommand.CommandText = "SELECT POITEMNumber, ItemID FROM "+ "tblPOItem2 where ItemID = " + GetHeaderRow().ItemID; adapter.SelectCommand.Connection = AdapterHelper.Connection; adapter.Fill(tempDataSet.POItemTbl); if (tempDataSet.POItemTbl.Rows.Count != 0) { tempDataSet.Clear(); MessageBox.Show("Delete of item is not allowed. Item is still used by " + "Purchase Orders in the database."); return false; } tempDataSet.Clear(); } } return true; }
public static int GetPO(OleDbConnection connection, int compID,int locationID) { string[] mycolumnHeadings = {"PO","Date","Status","Mill","Customer","Customer Location"}; string[] myfieldNames = {"PONumber","PODate","Status","MillName","CustomerName","CustomerLocation"}; FieldType[] myfieldTypes = {FieldType.String,FieldType.Date,FieldType.String, FieldType.String,FieldType.String,FieldType.String}; int[] mycolumnWidths = {150,150,60,150,150,200}; string filterName = "Status"; string[] filterValues = new string[]{"All","Open","Closed","Cancelled"}; int initialFilterValue = 1; if (compID != -1 && locationID != -1) { using (new OpenConnection(IsWrite.No,AdapterHelper.Connection)) { EMDataSet tmpSet = new EMDataSet(); tmpSet.EnforceConstraints = false; AdapterHelper.FillCompanyFromCompID(tmpSet,compID); AdapterHelper.FillLocationFromLocationID(tmpSet,locationID); } } Chooser dlg = new Chooser(connection,"POID",mycolumnHeadings,mycolumnWidths, myfieldNames,myfieldTypes,filterName,filterValues,initialFilterValue, new POFindButtonClick(compID,locationID)); DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK) return dlg.KeyValue; else return 0; }
public DataTable OnFindButtonClick(OleDbConnection connection,string constraint) { using (new OpenConnection(IsWrite.No,connection)) { EMDataSet dataSet = new EMDataSet(); dataSet.EnforceConstraints = false; OleDbDataAdapter contAdapter= new OleDbDataAdapter(); contAdapter.SelectCommand= new OleDbCommand(); string query = "SELECT ContID, ContNumber, ShipDate, ETA,"+ "ApplyClosingToEntireContainer,ContainerPickupDate,"+ "ContainerPickupTerminal,ContainerProofOfDelivery,Status,CustomerID"+ " FROM tblContainer"; string statusConstraint = constraint; if (statusConstraint != "All") { statusConstraint = "'" + statusConstraint + "'"; query += " WHERE STATUS =" + statusConstraint; } query += " ORDER BY ContNumber"; contAdapter.SelectCommand.CommandText = query; contAdapter.SelectCommand.Connection = connection; contAdapter.Fill(dataSet.ContainerTbl); ArrayList customerIDs = new ArrayList(); foreach (EMDataSet.ContainerTblRow contRow in dataSet.ContainerTbl) { AdapterHelper.FillContBundle(dataSet,contRow.ContID); if (!contRow.IsCustomerIDNull()) customerIDs.Add(contRow.CustomerID); } AdapterHelper.Unique(ref customerIDs); foreach (int id in customerIDs) { AdapterHelper.FillCompanyFromCompID(dataSet, id); } dataSet.ContainerTbl.Columns.Add("Customer",typeof(string)); dataSet.ContainerTbl.Columns.Add("Completed", typeof(string)); dataSet.ContainerTbl.Columns.Add("PONumbers", typeof(string)); if (m_showPOs) { AdapterHelper.FillOutConstraints(dataSet); foreach (EMDataSet.ContainerTblRow contRow in dataSet.ContainerTbl) { if (Completed(contRow)) { contRow["Completed"] = "Completed"; } else { contRow["Completed"] = "Incomplete"; } ArrayList listOfPONumbers = new ArrayList(); foreach (EMDataSet.ContBundleTblRow bundleRow in contRow.GetContBundleTblRows()) { listOfPONumbers.Add(bundleRow.POItemTblRow.POHeaderTblRow.PONumber); } listOfPONumbers.Sort(); AdapterHelper.UniqueStr(ref listOfPONumbers); foreach (string ponum in listOfPONumbers) { contRow["PONumbers"] += ponum + " "; } } } foreach (EMDataSet.ContainerTblRow contRow in dataSet.ContainerTbl) { if (!contRow.IsCustomerIDNull()) { contRow["Customer"] = dataSet.CompanyTbl.FindByCompID(contRow.CustomerID).CompName; } } return dataSet.ContainerTbl; } }
void FillFromItemRow(EMDataSet.BOLItemTblRow row) { AdapterHelper.FillContBundleFromContBundleID(emDataSet,row.ContainerBundleID); int contID = row.ContBundleTblRow.ContID; AdapterHelper.FillContainerHeader(emDataSet,contID); AdapterHelper.FillPOItemFromPOItemNumber(emDataSet,row.ContBundleTblRow.POItemNumber); foreach (EMDataSet.POItemTblRow poItemRow in emDataSet.POItemTbl.Rows) { int poid = poItemRow.POID; AdapterHelper.FillPOHeader(emDataSet,poid); if (!poItemRow.IsItemIDNull()) AdapterHelper.FillItem(emDataSet,poItemRow.ItemID); } }
public override bool IsDeleteAllowed() { int compid = GetHeaderRow().CompID; EMDataSet tempSet = new EMDataSet(); tempSet.EnforceConstraints = false; using (new OpenConnection(EM.IsWrite.No,AdapterHelper.Connection)) { AdapterHelper.FillLocations(tempSet,compid); AdapterHelper.FillContacts(tempSet,compid); AdapterHelper.FillItemsFromCompID(tempSet,compid); if (!IsTableEmpty(tempSet.LocationTbl) || !IsTableEmpty(tempSet.ItemTbl) || !IsTableEmpty(tempSet.ContactsTbl)) { MessageBox.Show("Delete of the company is not allowed " + "until all locations, contacts, and items of the company have been removed", "Can't delete"); return false; } } return true; }
private object GetBillOfLadingNumber(EMDataSet.ContBundleTblRow row) { int contBundleID = row.ContainerBundleID; // Does this item exist in our view, either deleted or not EMDataSet.BOLItemTblRow bolItemRow = FindBOLByContBundleID(contBundleID); if (bolItemRow != null) { if (bolItemRow.RowState == DataRowState.Deleted) return DBNull.Value; else { return bolItemRow.BOLTblRow.BOLNumber; } } return FormSupport.DefaultGetBillOfLadingNumber(row); }
void JoinContainerDatabase(EMDataSet.ContainerTblRow headerRow) { DataTable table = new DataTable(); EMDataSet.ContBundleTblRow[] bundleRows = headerRow.GetContBundleTblRows(); System.Array.Sort(bundleRows,new SortByBundleNum()); string[] fieldsAndPaths= { "BUNDLE_NUMBER","BundleSeqNumber", "COMPANY_NAME","ContID>ContainerTbl.CustomerID>CompanyTbl.CompName",// + //"ContID>ContainerTbl.CustomerID>CompanyTbl.CompName", "CONTNUMBER","ContID>ContainerTbl.ContNumber", "PO_NUMBER","POItemNumber>POItemTbl.POID>POHeaderTbl.PONumber", "SIZE","POItemNumber>POItemTbl.SizeOfItem", "ITEM_NAME","POItemNumber>POItemTbl.FinishID>FinishTbl.FinishType+" + "POItemNumber>POItemTbl.ItemID>ItemTbl.ItemName+"+ "POItemNumber>POItemTbl.TreatmentID>TreatmentTbl.TreatmentType", "CODE","POItemNumber>POItemTbl.ItemAccessCode", "WEIGHT_KGS","MetricShipQty", "WEIGHT_LBS","EnglishShipQty", "HEAT","Heat", "INVOICE","InvoiceNumber", "BAY","BayNumber", "ETA","ContID>ContainerTbl.ETA", "RATE","POItemNumber>POItemTbl.CustRate", "BRANCH","POItemNumber>POItemTbl.POID>POHeaderTbl.CustomerLocationID>LocationTbl.LocName" }; string[] fields = new string[fieldsAndPaths.Length/2]; string[] paths = new string[fieldsAndPaths.Length/2]; for(int i =0;i<fields.Length;i++) { fields[i] = fieldsAndPaths[i*2]; paths[i] = fieldsAndPaths[i*2+1]; } string firstRowName = "BUNDLE_NUMBER"; int contID = headerRow.ContID; EMDataSet.ContBundleTblRow[] rows = (EMDataSet.ContBundleTblRow[]) headerRow.Table.DataSet.Tables["ContBundleTbl"]. Select("ContID = " + contID.ToString()); // Sort rows based on bundle number Array.Sort(rows, new SortBasedOnBundle()); ArrayList listOfLists = Join(rows, paths); ArrayList[] listOfLists2 = (ArrayList[]) listOfLists.ToArray(typeof(ArrayList)); WriteExcelFile(fields, paths, firstRowName, listOfLists2); }
public static void DoIt(QuickGrid grid,int poid,bool isMetric,EMDataSet emDataSet) { int[] finishKeys = HelperFunctions.GetFinishKeys("Finish"); decimal[] totalWeight = new decimal[finishKeys.Length+1];// Last one has no key decimal[] totalAmount = new decimal[finishKeys.Length+1]; foreach (EMDataSet.POItemTblRow itemRow in emDataSet.POItemTbl) { if (!DataInterface.IsRowAlive(itemRow)) continue; decimal currentWeight; if (itemRow.IsQtyNull()) currentWeight = 0; else currentWeight = itemRow.Qty; decimal currentAmount; if (itemRow.IsCustAmountNull()) currentAmount = 0; else currentAmount = itemRow.CustAmount; if (itemRow.IsFinishIDNull()) { totalWeight[totalWeight.Length-1] += currentWeight; totalAmount[totalAmount.Length-1] += currentAmount; } else { int index = Array.IndexOf(finishKeys,itemRow.FinishID); totalWeight[index] += currentWeight; totalAmount[index] += currentAmount; } } DataTable dataTable = new DataTable(); dataTable.Columns.Add("Heading",typeof(string)); dataTable.Columns.Add("FinishWeight",typeof(decimal)); dataTable.Columns.Add("FinishAmount",typeof(decimal)); for (int i=0;i<totalWeight.Length;i++) { DataRow weightRow = dataTable.NewRow(); weightRow["FinishWeight"] = totalWeight[i]; weightRow["FinishAmount"] = totalAmount[i]; if (i == finishKeys.Length) // should just happen here { weightRow["Heading"] = "Unknown"; } else weightRow["Heading"] = HelperFunctions.GetFinishType("Finish",finishKeys[i]); dataTable.Rows.Add(weightRow); } DataRow totalRow = dataTable.NewRow(); totalRow["Heading"] = "Total"; decimal totalTotal = 0; foreach (decimal current in totalWeight) { totalTotal += current; } decimal totalAmountTotal =0; foreach (decimal current in totalAmount) { totalAmountTotal += current; } totalRow["FinishAmount"] = totalAmountTotal; totalRow["FinishWeight"] = totalTotal; dataTable.Rows.Add(totalRow); HelperFunctions.UpdateGrid(dataTable.DefaultView,grid,null, isMetric,IsNewAllowed.No,IsReadOnly.Yes, "Heading","FinishWeight","FinishAmount"); }
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"); }
private void RefreshContainerGrids() { EMDataSet containerDataSet = new EMDataSet(); FormSupport.FillContainerFromDatabase(containerDataSet,m_containerGridID); decimal totalLbs; decimal totalKgs; FormSupport.SetupContainerGrids(containerDataSet, m_containerGridID, containerBundleGrid, containerWeightGrid,null,IsReadOnly.Yes, out totalLbs,out totalKgs, new FormSupport.GetBillOfLadingNumberFunc( GetBillOfLadingNumber)); }
public static bool Completed(EMDataSet.ContainerTblRow row) { return DataInterface.IsCompleted(row); }
public static void SetupContainerItemSummaryGrid(EMDataSet emDataSet, QuickGrid grid, int poItemNumber) { SetupContainerItemSummaryGrid(emDataSet, grid, poItemNumber, 0); }
public DataTable OnFindButtonClick(OleDbConnection connection,string constraint) { using (new OpenConnection(IsWrite.No,connection)) { DataTable table = new DataTable(); table.Columns.Add("POID",typeof(int)); table.Columns.Add("PONumber",typeof(string)); table.Columns.Add("PODate",typeof(DateTime)); table.Columns.Add("Status",typeof(string)); table.Columns.Add("MillID",typeof(int)); table.Columns.Add("CustomerID",typeof(int)); table.Columns.Add("CustomerLocationID",typeof(int)); table.Columns.Add("MillName",typeof(string)); table.Columns.Add("CustomerName",typeof(string)); table.Columns.Add("CustomerLocation",typeof(string)); OleDbDataAdapter poHeaderAdapter = new OleDbDataAdapter(); poHeaderAdapter.SelectCommand= new OleDbCommand(); string query = "SELECT POID, PONumber, PODate, Status,MillID,CustomerID,CustomerLocationID"+ " FROM tblPOHeader2"; string statusConstraint = constraint; ArrayList constraints = new ArrayList(); if (statusConstraint != "All") { statusConstraint = "'" + statusConstraint + "'"; constraints.Add("STATUS =" + statusConstraint); } if (compID != -1 && locID != -1) { string locConstraint = "CustomerLocationID = " + locID.ToString(); constraints.Add(locConstraint); } query += DataInterface.TranslateToConstraint(constraints); query += " ORDER BY PONumber"; poHeaderAdapter.SelectCommand.CommandText = query; poHeaderAdapter.SelectCommand.Connection = connection; poHeaderAdapter.Fill(table); ArrayList compIDs = new ArrayList(); EMDataSet tempDataSet = new EMDataSet(); tempDataSet.EnforceConstraints = false; ArrayList locIDs = new ArrayList(); foreach (DataRow row in table.Rows) { if (!row.IsNull("MillID")) { compIDs.Add(row["MillID"]); } if (!row.IsNull("CustomerID")) { compIDs.Add(row["CustomerID"]); } if (!row.IsNull("CustomerLocationID")) { locIDs.Add(row["CustomerLocationID"]); } } compIDs.Sort(); locIDs.Sort(); int oldID = -1; foreach (int id in compIDs) { if (id != oldID) { AdapterHelper.FillCompanyFromCompID(tempDataSet,id); } oldID = id; } oldID = -1; foreach (int id in locIDs) { if (id != oldID) { AdapterHelper.FillLocationFromLocationID(tempDataSet,id); } oldID = id; } foreach (DataRow row in table.Rows) { if (!row.IsNull("MillID")) { EMDataSet.CompanyTblRow compRow = tempDataSet.CompanyTbl.FindByCompID((int)row["MillID"]); row["MillName"] = compRow.CompName; } if (!row.IsNull("CustomerID")) { EMDataSet.CompanyTblRow compRow = tempDataSet.CompanyTbl.FindByCompID((int)row["CustomerID"]); row["CustomerName"] = compRow.CompName; } if (!row.IsNull("CustomerLocationID")) { EMDataSet.LocationTblRow locRow = tempDataSet.LocationTbl.FindByLocID((int)row["CustomerLocationID"]); row["CustomerLocation"] = locRow.LocName; } } return table; } }
public static void SetupContainerItemSummaryGrid(EMDataSet emDataSet,QuickGrid grid,int poItemNumber,int bundleIDNumber) { EMDataSet.ContBundleTblRow[] rows = (EMDataSet.ContBundleTblRow[]) emDataSet.ContBundleTbl.Select("POItemNumber = " + poItemNumber.ToString()); DataTable newTable = new DataTable(); string[] fields = new string[]{"ContNumber","BundleSeqNumber","EnglishShipQty","MetricShipQty","ContID","ContainerBundleID"}; HelperFunctions.FieldProperties[] fieldProperties = HelperFunctions.GetProperties(ref fields,false); for (int i =0;i<fields.Length;i++) { newTable.Columns.Add(fields[i],fieldProperties[i].type); } int selectedIndex = -1; for (int i = 0; i < rows.Length; i++) { EMDataSet.ContBundleTblRow row = rows[i]; if (!DataInterface.IsRowAlive(row)) continue; if (row.ContainerBundleID == bundleIDNumber) selectedIndex = i; DataRow targetRow = newTable.NewRow(); targetRow["ContNumber"] = row.ContainerTblRow.ContNumber; targetRow["BundleSeqNumber"] = row.BundleSeqNumber; targetRow["EnglishShipQty"] = row["EnglishShipQty"]; targetRow["MetricShipQty"] = row["MetricShipQty"]; targetRow["ContID"] = row.ContID; targetRow["ContainerBundleID"] = row.ContainerBundleID; newTable.Rows.Add(targetRow); } DataView view = new DataView(newTable,"","ContNumber",DataViewRowState.CurrentRows); HelperFunctions.UpdateGrid(view,grid,null,false,IsNewAllowed.No,IsReadOnly.Yes,fields); if (selectedIndex != -1) grid.SetNewFocus(selectedIndex, 0); }