/// <summary> /// Creates a new instance of the Sac_MoneyInventory class and populates it with data from the specified SqlDataReader. /// </summary> protected virtual Sac_MoneyInventory MakeSac_MoneyInventory(SqlDataReader dataReader) { Sac_MoneyInventory sac_MoneyInventory = new Sac_MoneyInventory(); sac_MoneyInventory.ClientID = SqlClientUtility.GetString(dataReader, "ClientID", String.Empty); sac_MoneyInventory.MoneyID = SqlClientUtility.GetInt32(dataReader, "MoneyID", 0); sac_MoneyInventory.BillDispenserID = SqlClientUtility.GetInt32(dataReader, "BillDispenserID", 0); sac_MoneyInventory.Address = SqlClientUtility.GetString(dataReader, "Address", String.Empty); sac_MoneyInventory.Inventory = SqlClientUtility.GetInt32(dataReader, "Inventory", 0); sac_MoneyInventory.MaxNumBills = SqlClientUtility.GetInt32(dataReader, "MaxNumBills", 0); sac_MoneyInventory.FullQuantity = SqlClientUtility.GetInt32(dataReader, "FullQuantity", 0); return(sac_MoneyInventory); }
/// <summary> /// Selects all records from the Sac_MoneyInventory table. /// </summary> public virtual List <Sac_MoneyInventory> SelectAll() { using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Sac_MoneyInventory_SelectAll")) { List <Sac_MoneyInventory> sac_MoneyInventoryList = new List <Sac_MoneyInventory>(); while (dataReader.Read()) { Sac_MoneyInventory sac_MoneyInventory = MakeSac_MoneyInventory(dataReader); sac_MoneyInventoryList.Add(sac_MoneyInventory); } return(sac_MoneyInventoryList); } }
/// <summary> /// Updates a record in the Sac_MoneyInventory table. /// </summary> public virtual void Update(Sac_MoneyInventory sac_MoneyInventory) { ValidationUtility.ValidateArgument("sac_MoneyInventory", sac_MoneyInventory); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ClientID", sac_MoneyInventory.ClientID), new SqlParameter("@MoneyID", sac_MoneyInventory.MoneyID), new SqlParameter("@BillDispenserID", sac_MoneyInventory.BillDispenserID), new SqlParameter("@Address", sac_MoneyInventory.Address), new SqlParameter("@Inventory", sac_MoneyInventory.Inventory), new SqlParameter("@MaxNumBills", sac_MoneyInventory.MaxNumBills), new SqlParameter("@FullQuantity", sac_MoneyInventory.FullQuantity) }; SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "Sac_MoneyInventory_Update", parameters); }
/// <summary> /// Selects all records from the Sac_MoneyInventory table by a foreign key. /// </summary> public virtual List <Sac_MoneyInventory> _SelectAllByClientID(string clientID) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ClientID", clientID) }; using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Sac_MoneyInventory_SelectAllByClientID", parameters)) { List <Sac_MoneyInventory> sac_MoneyInventoryList = new List <Sac_MoneyInventory>(); while (dataReader.Read()) { Sac_MoneyInventory sac_MoneyInventory = MakeSac_MoneyInventory(dataReader); sac_MoneyInventoryList.Add(sac_MoneyInventory); } return(sac_MoneyInventoryList); } }
private void buttonUseCalculatedInventory_Click(object sender, EventArgs e) { //sac_MoneyInventory; sac_MoneyInventory_Sp = new Sac_MoneyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString); string c; int j = dataGridViewFloat.Rows.Count; if (j < 1) { return; } Sac_ClientName sac_ClientName = new Sac_ClientName(); if (Main.Sol_ControlInfo.SacCashTrayID >= 0) { Sac_ClientName_Sp sac_ClientName_Sp = new Sac_ClientName_Sp(Properties.Settings.Default.WsirDbConnectionString); //get sac's clientID sac_ClientName = sac_ClientName_Sp.SelectByCashTrayID(Main.Sol_ControlInfo.SacCashTrayID); } int moneyID = 0; decimal cashValue = 0; for (int i = 0; i < j; i++) { if (dataGridViewFloat[1, i].Value.ToString() == "Rolls") { continue; } //MoneyID try { c = dataGridViewFloat[8, i].Value.ToString(); Int32.TryParse(c, out moneyID); } catch { continue; } if (String.IsNullOrEmpty(sac_ClientName.ClientID)) { continue; } sac_MoneyInventory = sac_MoneyInventory_Sp.Select(sac_ClientName.ClientID, moneyID, billDispenserId); if (sac_MoneyInventory == null) { continue; } //CashValue try { c = dataGridViewFloat[5, i].Value.ToString(); decimal.TryParse(c, out cashValue); } catch { cashValue = 0; } //Save Count try { dataGridViewFloat[2, i].Value = (int)sac_MoneyInventory.Inventory; // count; } catch { continue; } dataGridViewFloat[3, i].Value = String.Format("{0:$##,##0.00}", sac_MoneyInventory.Inventory * cashValue); } CalculateTotals(); buttonUseCalculatedInventory.Visible = false; }
private void buttonSave_Click(object sender, EventArgs e) { //total amount string c = labelTotalAmount2.Text; c = c.Replace("$", ""); c = c.Replace(",", ""); decimal totalAmount = 0; Decimal.TryParse(c, out totalAmount); if (totalAmount <= 0) { MessageBox.Show("Nothing to save!"); return; } //save entry sol_Entrie = new Sol_Entrie(); sol_Entrie.EntryType = entryType; MembershipUser membershipUser = membershipUser = Membership.GetUser(Properties.Settings.Default.UsuarioNombre); if (membershipUser == null) { MessageBox.Show("User does not exist, cannot save this entry"); return; } sol_Entrie.UserID = (Guid)membershipUser.ProviderUserKey; sol_Entrie.UserName = Properties.Settings.Default.UsuarioNombre; sol_Entrie.Date = Main.rc.FechaActual; // Properties.Settings.Default.FechaActual; sol_Entrie.CashTrayID = Convert.ToInt32(comboBoxCashTray.SelectedValue); //Properties.Settings.Default.SettingsCurrentCashTray; sol_Entrie.ExpenseTypeID = 0; //<none> sol_Entrie.Amount = totalAmount; Sac_MoneyInventory sac_MoneyInventory; Sac_MoneyInventory_Sp sac_MoneyInventory_Sp = new Sac_MoneyInventory_Sp(Properties.Settings.Default.WsirDbConnectionString); Sac_ClientName sac_ClientName = new Sac_ClientName(); Sac_ClientName_Sp sac_ClientName_Sp = new Sac_ClientName_Sp(Properties.Settings.Default.WsirDbConnectionString); //get sac clientID if we are using sac cashtray string bdd = Properties.Settings.Default.SQLBaseDeDatos; if (Properties.Settings.Default.SQLBaseDeDatos == Properties.Settings.Default.BaseDeDatosPrincipal && Main.Sol_ControlInfo.SacCashTrayID >= 0) { //Sac_ClientName sac_ClientName = new Sac_ClientName(); //Sac_ClientName_Sp sac_ClientName_Sp = new Sac_ClientName_Sp(Properties.Settings.Default.WsirDbConnectionString); //get sac's clientID sac_ClientName = sac_ClientName_Sp.SelectByCashTrayID(Main.Sol_ControlInfo.SacCashTrayID); if (sac_ClientName == null) { MessageBox.Show("SAC's Client Not Found!\r\n" + "Goto SAC -> Settings -> FrontScreen and select a Cash Tray." ); return; } //update coin amount inventory if we are using sac cashtray if (sol_Entrie.CashTrayID == Main.Sol_ControlInfo.SacCashTrayID) { // search for active clientID using the CashTrayID in Sac_ClienNames //sac_ClientName = sac_ClientName_Sp.SelectByCashTrayID(Main.Sol_ControlInfo.SacCashTrayID); if (!String.IsNullOrEmpty(sac_ClientName.ClientID)) { //clientID = sac_ClientName.ClientID; if (entryName == "Open") { sac_ClientName.CoinAmountInventory = totalCoinAmountInventory; } else if (entryName == "Float") { sac_ClientName.CoinAmountInventory += totalCoinAmountInventory; } else if (entryName == "Close") { sac_ClientName.CoinAmountInventory = 0; } sac_ClientName_Sp.Update(sac_ClientName); } } } decimal decimalAmount = 0; if (entryName == "Close") { c = labelTotalAmount3.Text; c = c.Replace("$", ""); c = c.Replace(",", ""); Decimal.TryParse(c, out decimalAmount); sol_Entrie.DiscrepancyAmount = decimalAmount; // Decimal.Parse(c); } else { sol_Entrie.DiscrepancyAmount = 0.0m; } sol_Entrie_Sp.Insert(sol_Entrie); //clear form //decimal totalAmount2 = 0; //labelTotalAmount2.Text = String.Format("{0:$##,##0.00}", totalAmount2); int j = dataGridViewFloat.Rows.Count; if (j < 1) { return; } sol_EntriesDetail = new Sol_EntriesDetail(); int intValue = 0; int count = 0; decimal cashValue = 0; decimal cashItemValue = 0; int quantity = 0; int moneyID = -1; for (int i = 0; i < j; i++) { sol_EntriesDetail.EntryID = sol_Entrie.EntryID; sol_EntriesDetail.EntryType = sol_Entrie.EntryType; //CashID (Sol_CashDenomination) try { c = dataGridViewFloat[4, i].Value.ToString(); Int32.TryParse(c, out intValue); } catch { intValue = 0; } sol_EntriesDetail.CashID = intValue; // Convert.ToInt32(dataGridViewFloat[4, i].Value); //Count try { c = dataGridViewFloat[2, i].Value.ToString(); Int32.TryParse(c, out count); } catch { count = 0; } sol_EntriesDetail.Count = count; // Convert.ToInt32(dataGridViewFloat[2, i].Value); //CashValue try { c = dataGridViewFloat[5, i].Value.ToString(); decimal.TryParse(c, out cashValue); } catch { cashValue = 0; } //CashItemValue try { c = dataGridViewFloat[6, i].Value.ToString(); decimal.TryParse(c, out cashItemValue); } catch { cashItemValue = 1; } //Quantity try { c = dataGridViewFloat[7, i].Value.ToString(); int.TryParse(c, out quantity); } catch { quantity = 1; } //MoneyID try { c = dataGridViewFloat[8, i].Value.ToString(); int.TryParse(c, out moneyID); } catch { moneyID = 1; } if (dataGridViewFloat[1, i].Value.ToString() == "Rolls") { count *= quantity; } //sol_EntriesDetail.Count = count; // Convert.ToInt32(dataGridViewFloat[2, i].Value); sol_EntriesDetail_Sp.Insert(sol_EntriesDetail); //if (entryName == "Close") // continue; //if we are using sac cashtray update money inventory if (Main.Sol_ControlInfo.SacCashTrayID >= 0) { if (Main.Sol_ControlInfo.SacCashTrayID == (int)comboBoxCashTray.SelectedIndex) { //sac_MoneyInventory. if (String.IsNullOrEmpty(sac_ClientName.ClientID)) { continue; } sac_MoneyInventory = sac_MoneyInventory_Sp.Select(sac_ClientName.ClientID, moneyID, billDispenserId); if (sac_MoneyInventory == null) { continue; } if (entryName == "Open") { sac_MoneyInventory.Inventory += count; } else if (entryName == "Float") { sac_MoneyInventory.Inventory += count; } else //if (entryName == "Float") { sac_MoneyInventory.Inventory = 0; } sac_MoneyInventory_Sp.Update(sac_MoneyInventory); } } } //MessageBox.Show("Entry Saved!"); buttonSave.Enabled = false; buttonSave.Text = "Saved"; dataGridViewFloat.Columns["Count"].ReadOnly = !buttonSave.Enabled; comboBoxCashTray.Enabled = false; buttonUseLastClose.Enabled = false; //readCashDenominations(); //ClearForm(); if (Properties.Settings.Default.SettingsCurrentCashTray != (int)comboBoxCashTray.SelectedIndex) { DialogResult result = MessageBox.Show("Do you want to make this cash tray the current cash tray?", "", MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { Properties.Settings.Default.SettingsCurrentCashTray = Convert.ToInt32(comboBoxCashTray.SelectedValue); //comboBoxCashTray.SelectedIndex; Properties.Settings.Default.Save(); } } }