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); }
public static DataTable getRowsForSale(Guid[] IDList, Guid?customerID) { DataTable dt = getRows("inventoryitem_get", IDList, customerID); Tools.addColumn <bool>(dt, COL_SALE_SELECTED, 0); return(dt); }
public static DataTable createArrayTable() { DataTable datatable = new DataTable(); Tools.addColumn <string>(datatable, DBUtil.TYPE_ARRAY_STR, ""); Tools.addColumn <int>(datatable, DBUtil.TYPE_ARRAY_INT, 0); return(datatable); }
/*******************************************************************************************************/ #region METHODS public static DataTable getItemForReturn(string InventoryItemBarcode) { DataTable dataTable = getItem(InventoryItemBarcode, true); Tools.addColumn <int>(dataTable, COL_QTY, 1); return(dataTable); }
public static DataTable parseEnum <T>(DataTable dataTable, string targetColumnName, string enumIDColumn) { if (!dataTable.Columns.Contains(targetColumnName)) { Tools.addColumn <string>(dataTable, targetColumnName, ""); } foreach (DataRow dr in dataTable.Rows) { if (dr[enumIDColumn] != DBNull.Value) { dr[targetColumnName] = Tools.GetEnumDescription((Enum)(object)Tools.parseEnum <T>(dr[enumIDColumn])); } } return(dataTable); }
public static DataTable getItems(Guid SaleID) { DataTable dataTable = new DataTable(); using (SqlCommand cmd = new SqlCommand("saleitem_get_by_sale_id", DBConnection.ActiveSqlConnection)) using (SqlDataAdapter adapter = new SqlDataAdapter()) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@sale_id", SqlDbType.UniqueIdentifier).Value = SaleID; adapter.SelectCommand = cmd; adapter.Fill(dataTable); } Tools.addColumn <bool>(dataTable, COL_SELECTED, 0); Tools.addColumn <bool>(dataTable, COL_DB_isManualAdjustment, 0); return(dataTable); }
/*******************************************************************************************************/ #region PROTECTED METHODS protected InputPanel setupInputControl(InputPanel formControl, int inputContainerColumnIndex, string fieldTitle, string fieldDBName, int gridviewColumnWidth, bool isReadOnly, bool disableOnSearch, string format) { setupInputControl(formControl, inputContainerColumnIndex, fieldTitle, fieldDBName, disableOnSearch); Tools.addColumn <DataGridViewTextBoxCell>(gridview, fieldDBName, fieldTitle, fieldDBName, gridviewColumnWidth, isReadOnly, format); //add field to gridview return(formControl); }