/*******************************************************************************************************/ #region CLASS METHODS public static DataTable compileSummaryData(DataTable dt) { DataTable dtSummary = dt.Clone(); Tools.setDataTablePrimaryKey(dtSummary, SaleItem.COL_INVENTORY_ID); DataRow tempRow; foreach (DataRow dr in dt.Rows) { if (dtSummary.Rows.Contains(dr[SaleItem.COL_INVENTORY_ID])) { tempRow = dtSummary.Rows.Find(dr[SaleItem.COL_INVENTORY_ID]); tempRow[SaleItem.COL_QTY] = Tools.zeroNonNumericString(tempRow[SaleItem.COL_QTY]) + Tools.zeroNonNumericString(dr[SaleItem.COL_QTY]); tempRow[SaleItem.COL_LENGTH] = Tools.zeroNonNumericString(tempRow[SaleItem.COL_LENGTH]) + Tools.zeroNonNumericString(dr[SaleItem.COL_LENGTH]); tempRow[SaleItem.COL_SUBTOTAL] = Tools.zeroNonNumericString(tempRow[SaleItem.COL_SUBTOTAL]) + Tools.zeroNonNumericString(dr[SaleItem.COL_SUBTOTAL]); dtSummary.AcceptChanges(); } else { dtSummary.Rows.Add(dr.ItemArray); } } return(dtSummary); }
/*******************************************************************************************************/ #region CLASS METHODS public static DataTable compileSummaryData(DataTable dt) { DataTable dtSummary = dt.Clone(); Tools.setDataTablePrimaryKey(dtSummary, InventoryItem.COL_DB_INVENTORY_ID); DataRow tempRow; int i = 0; foreach (DataRow dr in dt.Rows) { if (dtSummary.Rows.Contains(dr[InventoryItem.COL_DB_INVENTORY_ID])) { tempRow = dtSummary.Rows.Find(dr[InventoryItem.COL_DB_INVENTORY_ID]); tempRow[InventoryItem.COL_SALE_QTY] = Tools.zeroNonNumericString(tempRow[InventoryItem.COL_SALE_QTY]) + Tools.zeroNonNumericString(dr[InventoryItem.COL_SALE_QTY]); tempRow[InventoryItem.COL_DB_LENGTH] = Tools.zeroNonNumericString(tempRow[InventoryItem.COL_DB_LENGTH]) + Tools.zeroNonNumericString(dr[InventoryItem.COL_DB_LENGTH]); tempRow[InventoryItem.COL_SALE_SUBTOTAL] = Tools.zeroNonNumericString(tempRow[InventoryItem.COL_SALE_SUBTOTAL]) + Tools.zeroNonNumericString(dr[InventoryItem.COL_SALE_SUBTOTAL]); tempRow[InventoryItem.COL_SALE_ADJUSTEDPRICE] = Tools.zeroNonNumericString(tempRow[InventoryItem.COL_SALE_SUBTOTAL]) / Tools.zeroNonNumericString(tempRow[InventoryItem.COL_DB_LENGTH]); dtSummary.AcceptChanges(); } else { if (!string.IsNullOrEmpty(dr[InventoryItem.COL_DB_INVENTORY_ID].ToString())) { dtSummary.Rows.Add(dr.ItemArray); } } i++; } return(dtSummary); }
public static DataTable compileCompleteData(DataTable dtDetail) { string col_sold = "sold"; Tools.addColumn <bool>(dtDetail, col_sold, 0); Tools.setDataTablePrimaryKey(dtDetail, InventoryItemCheck.COL_DB_INVENTORYITEMID); DataTable dtCompilation = Inventory.getAll(false); Tools.addColumn <int>(dtCompilation, COL_COUNT_DIFF_QTY, 0); Tools.addColumn <decimal>(dtCompilation, COL_COUNT_DIFF_LENGTH, 0); foreach (DataRow dr in dtCompilation.Rows) { dr[Inventory.COL_QTY] = dtDetail.Compute(string.Format("COUNT({0})", COL_COUNT_ITEMLENGTH), string.Format("inventory_id = '{0}' AND {1} = false", dr[Inventory.COL_DB_ID], col_sold)); dr[Inventory.COL_ITEMLENGTH] = dtDetail.Compute(string.Format("SUM({0})", COL_COUNT_ITEMLENGTH), string.Format("inventory_id = '{0}' AND {1} = false", dr[Inventory.COL_DB_ID], col_sold)); //DataRow drSold = dtSoldItems.Rows.Find(dr[Inventory.COL_DB_ID]); //if (drSold != null) //{ // dr[Inventory.COL_QTY] = Convert.ToInt32(dr[Inventory.COL_QTY]) - Convert.ToInt32(drSold[Inventory.COL_QTY]); // dr[Inventory.COL_ITEMLENGTH] = Convert.ToInt32(Tools.zeroNonNumericString(dr[Inventory.COL_ITEMLENGTH])) - Convert.ToInt32(drSold[Inventory.COL_ITEMLENGTH]); //} dr[COL_COUNT_DIFF_QTY] = Convert.ToInt16(dr[Inventory.COL_QTY]) - Convert.ToInt16(dr[COL_COUNT_AVAILABLE_QTY]); dr[COL_COUNT_DIFF_LENGTH] = Convert.ToDecimal(Tools.zeroNonNumericString(dr[Inventory.COL_ITEMLENGTH])) - Convert.ToDecimal(Tools.zeroNonNumericString(dr[COL_COUNT_AVAILABLE_ITEM_LENGTH])); } return(dtCompilation); }
private static List <SaleItem> getListOfSaleItemsForUpdate(Guid SaleID, DataTable dt) { return(dt.AsEnumerable() .Select(row => new SaleItem { id = row.Field <Guid>(SaleItem.COL_ID), sale_id = SaleID, inventory_item_id = row.Field <Guid>(InventoryItem.COL_DB_ID), sell_price = Tools.zeroNonNumericString(row.Field <decimal?>(InventoryItem.COL_SALE_SELLPRICE)), adjustment = Tools.zeroNonNumericString(row.Field <decimal?>(InventoryItem.COL_SALE_ADJUSTMENT)), isManualAdjustment = row.Field <bool>(InventoryItem.COL_SALE_isManualAdjustment) }).ToList()); }
public static DataTable compileSummaryData(DataTable dt, bool showColor) { DataTable dtSummary = dt.Clone(); //copy table structure without rows of data Tools.setDataTablePrimaryKey(dtSummary, Inventory.COL_DB_ID); DataRow tempRow; decimal totalLength = 0; foreach (DataRow dr in dt.Rows) { tempRow = findCombination(dtSummary, dr, showColor); if (tempRow != null) { totalLength = Tools.zeroNonNumericString(tempRow[Inventory.COL_AVAILABLEITEMLENGTH]) + Tools.zeroNonNumericString(dr[Inventory.COL_AVAILABLEITEMLENGTH]); if (totalLength > 0) { tempRow[Inventory.COL_DB_BUYPRICE] = ((Tools.zeroNonNumericString(tempRow[Inventory.COL_DB_BUYPRICE]) * Tools.zeroNonNumericString(tempRow[Inventory.COL_AVAILABLEITEMLENGTH])) + (Tools.zeroNonNumericString(dr[Inventory.COL_DB_BUYPRICE]) * Tools.zeroNonNumericString(dr[Inventory.COL_AVAILABLEITEMLENGTH]))) / totalLength; //calculate average buy price tempRow[Inventory.COL_BUYVALUE] = Tools.zeroNonNumericString(tempRow[Inventory.COL_DB_BUYPRICE]) * totalLength; //calculate buy value tempRow[Inventory.COL_SELLVALUE] = Tools.zeroNonNumericString(tempRow[Inventory.COL_SELLVALUE]) + (Tools.zeroNonNumericString(dr[Inventory.COL_SELLPRICE]) * Tools.zeroNonNumericString(dr[Inventory.COL_AVAILABLEITEMLENGTH])); //calculate buy value tempRow[Inventory.COL_AVAILABLEITEMLENGTH] = totalLength; tempRow[Inventory.COL_AVAILABLEQTY] = Tools.zeroNonNumericString(tempRow[Inventory.COL_AVAILABLEQTY]) + Tools.zeroNonNumericString(dr[Inventory.COL_AVAILABLEQTY]); } dtSummary.AcceptChanges(); } else { tempRow = dtSummary.Rows.Add(dr.ItemArray); tempRow[Inventory.COL_BUYVALUE] = Tools.zeroNonNumericString(tempRow[Inventory.COL_DB_BUYPRICE]) * Tools.zeroNonNumericString(tempRow[Inventory.COL_AVAILABLEITEMLENGTH]); //calculate buy value tempRow[Inventory.COL_SELLVALUE] = Tools.zeroNonNumericString(tempRow[Inventory.COL_SELLPRICE]) * Tools.zeroNonNumericString(tempRow[Inventory.COL_AVAILABLEITEMLENGTH]); //calculate sell value dtSummary.AcceptChanges(); } } return(dtSummary); }
public static void setCountAndAmount(Label lbl, string qty, string length, string total) { lbl.Text = String.Format("{0} pcs / {1:N2} ({2:N2})", qty, Tools.zeroNonNumericString(length), Tools.zeroNonNumericString(total)); }
public static void setCount(Label lbl, string qty, string length) { lbl.Text = String.Format("{0:N0} pcs / {1:N2}", qty, Tools.zeroNonNumericString(length)); }
public static void setAmount(Label lbl, string total) { lbl.Text = String.Format("Rp. {0:N2}", Tools.zeroNonNumericString(total)); }