private void Expenses_Load(object sender, EventArgs e) { if (Properties.Settings.Default.TouchOriented) { toolStripButtonVirtualKb.Visible = true; } // TODO: This line of code loads data into the 'dataSetExpenseTypes.sol_ExpenseTypes_SelectAll' table. You can move, or remove it, as needed. this.sol_ExpenseTypes_SelectAllTableAdapter.Fill(this.dataSetExpenseTypes.sol_ExpenseTypes_SelectAll); // TODO: This line of code loads data into the 'dataSetCashTrays.sol_CashTrays_SelectAll' table. You can move, or remove it, as needed. this.sol_CashTrays_SelectAllTableAdapter.Fill(this.dataSetCashTrays.sol_CashTrays_SelectAll); sol_Entrie = new Sol_Entrie(); sol_Entrie_Sp = new Sol_Entrie_Sp(Properties.Settings.Default.WsirDbConnectionString); //disable form resizing this.FormBorderStyle = FormBorderStyle.FixedSingle; //current cashtray flagInicio = true; comboBoxCashTray.SelectedValue = Properties.Settings.Default.SettingsCurrentCashTray; flagInicio = false; if (SolFunctions.IsCashierClosed(ref sol_Entrie, sol_Entrie_Sp, Properties.Settings.Default.SettingsCurrentCashTray)) { DialogResult result = MessageBox.Show("The default cash tray is not open. You cannot add an expense!. Are you sure you want to continue?", "", MessageBoxButtons.YesNo); if (result != System.Windows.Forms.DialogResult.Yes) { Close(); return; } buttonSave.Enabled = false; } }
public static bool IsCashierClosed(ref Sol_Entrie sol_Entrie, Sol_Entrie_Sp sol_Entrie_Sp, int cashTrayID) { //open cashier sol_Entrie = sol_Entrie_Sp.SelectLastType("O", cashTrayID); DateTime OpenLatestDate; if (sol_Entrie == null) { OpenLatestDate = DateTime.MinValue; } else { OpenLatestDate = sol_Entrie.Date; } //close cashier sol_Entrie = sol_Entrie_Sp.SelectLastType("C", cashTrayID); DateTime CloseLatestDate; if (sol_Entrie == null) { CloseLatestDate = DateTime.MinValue; } else { CloseLatestDate = sol_Entrie.Date; } return(CloseLatestDate >= OpenLatestDate); }
private void buttonSave_Click(object sender, EventArgs e) { int j = dataGridViewExpenses.Rows.Count; if (j < 1) { MessageBox.Show("Nothing to save!"); return; } sol_Entrie = new Sol_Entrie(); for (int i = 0; i < j; i++) { //save entry sol_Entrie.EntryType = "E"; //Expenses MembershipUser membershipUser = membershipUser = Membership.GetUser(Properties.Settings.Default.UsuarioNombre); if (membershipUser == null) { MessageBox.Show("User does not exits, 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 = Properties.Settings.Default.SettingsCurrentCashTray; sol_Entrie.ExpenseTypeID = Convert.ToInt32(dataGridViewExpenses[0, i].Value); sol_Entrie.Amount = Convert.ToDecimal(dataGridViewExpenses[1, i].Value) * -1; //ignore zero amount if (sol_Entrie.Amount == 0) { continue; } //discrepancy sol_Entrie.DiscrepancyAmount = 0.0m; sol_Entrie_Sp.Insert(sol_Entrie); entrySaved = true; } if (entrySaved) { buttonSave.Enabled = false; dataGridViewExpenses.ReadOnly = !buttonSave.Enabled; MessageBox.Show("Entry(ies) Saved!"); } entrySaved = false; //if (Properties.Settings.Default.SettingsCurrentCashTray != (int)comboBoxCashTray.SelectedIndex) //{ // DialogResult result = MessageBox.Show("Dou you want to make this cash tray the current cash tray?", "", MessageBoxButtons.YesNo); // if (result == System.Windows.Forms.DialogResult.Yes) // { // Properties.Settings.Default.SettingsCurrentCashTray = comboBoxCashTray.SelectedIndex; // Properties.Settings.Default.Save(); // } //} }
/// <summary> /// Selects all records from the sol_Entries table. /// </summary> public virtual List <Sol_Entrie> SelectAll() { using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_Entries_SelectAll")) { List <Sol_Entrie> sol_EntrieList = new List <Sol_Entrie>(); while (dataReader.Read()) { Sol_Entrie sol_Entrie = MakeSol_Entrie(dataReader); sol_EntrieList.Add(sol_Entrie); } return(sol_EntrieList); } }
public static bool CheckCashier() { Sol_Entrie sol_Entrie = new Sol_Entrie(); Sol_Entrie_Sp sol_Entrie_Sp = new Sol_Entrie_Sp(Properties.Settings.Default.WsirDbConnectionString); if (SolFunctions.IsCashierClosed(ref sol_Entrie, sol_Entrie_Sp, Properties.Settings.Default.SettingsCurrentCashTray)) { //************************************************* //check if the Main.rc is enabled (RelojCalendario) //************************************************* //MessageBox.Show("You need to Open a new Cashier before using this option!"); //can pay a Return!"); //Close(); return(false); } return(true); }
/// <summary> /// Creates a new instance of the sol_Entries class and populates it with data from the specified SqlDataReader. /// </summary> protected virtual Sol_Entrie MakeSol_Entrie(SqlDataReader dataReader) { Sol_Entrie sol_Entrie = new Sol_Entrie(); sol_Entrie.EntryID = SqlClientUtility.GetInt32(dataReader, "EntryID", 0); sol_Entrie.EntryType = SqlClientUtility.GetString(dataReader, "EntryType", String.Empty); sol_Entrie.UserID = SqlClientUtility.GetGuid(dataReader, "UserID", Guid.Empty); sol_Entrie.UserName = SqlClientUtility.GetString(dataReader, "UserName", String.Empty); sol_Entrie.Date = SqlClientUtility.GetDateTime(dataReader, "Date", new DateTime(0)); sol_Entrie.CashTrayID = SqlClientUtility.GetInt32(dataReader, "CashTrayID", 0); sol_Entrie.ExpenseTypeID = SqlClientUtility.GetInt32(dataReader, "ExpenseTypeID", 0); sol_Entrie.Amount = SqlClientUtility.GetDecimal(dataReader, "Amount", Decimal.Zero); sol_Entrie.DiscrepancyAmount = SqlClientUtility.GetDecimal(dataReader, "DiscrepancyAmount", Decimal.Zero); return(sol_Entrie); }
/// <summary> /// Saves a record to the sol_Entries table. /// </summary> public virtual void Insert(Sol_Entrie sol_Entrie) { ValidationUtility.ValidateArgument("sol_Entrie", sol_Entrie); SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@EntryType", sol_Entrie.EntryType), new SqlParameter("@UserID", sol_Entrie.UserID), new SqlParameter("@UserName", sol_Entrie.UserName), new SqlParameter("@Date", sol_Entrie.Date), new SqlParameter("@CashTrayID", sol_Entrie.CashTrayID), new SqlParameter("@ExpenseTypeID", sol_Entrie.ExpenseTypeID), new SqlParameter("@Amount", sol_Entrie.Amount), new SqlParameter("@DiscrepancyAmount", sol_Entrie.DiscrepancyAmount) }; sol_Entrie.EntryID = (int)SqlClientUtility.ExecuteScalar(connectionStringName, CommandType.StoredProcedure, "sol_Entries_Insert", parameters); }
/// <summary> /// Selects all records from the sol_Entries table by a foreign key. /// </summary> public virtual List <Sol_Entrie> _SelectAllByExpenseTypeID(int expenseTypeID) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ExpenseTypeID", expenseTypeID) }; using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_Entries_SelectAllByExpenseTypeID", parameters)) { List <Sol_Entrie> sol_EntrieList = new List <Sol_Entrie>(); while (dataReader.Read()) { Sol_Entrie sol_Entrie = MakeSol_Entrie(dataReader); sol_EntrieList.Add(sol_Entrie); } return(sol_EntrieList); } }
/// <summary> /// Selects all records from the sol_Entries table by a foreign key. /// </summary> public virtual List <Sol_Entrie> SelectAllByTypeDateTray(string entryType, DateTime date, int cashTrayID) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@EntryType", entryType), new SqlParameter("@Date", date), new SqlParameter("@CashTrayID", cashTrayID) }; using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "sol_Entries_SelectAllByTypeDateTray", parameters)) { List <Sol_Entrie> sol_EntrieList = new List <Sol_Entrie>(); while (dataReader.Read()) { Sol_Entrie sol_Entrie = MakeSol_Entrie(dataReader); sol_EntrieList.Add(sol_Entrie); } return(sol_EntrieList); } }
private void Float_Load(object sender, EventArgs e) { if (Properties.Settings.Default.TouchOriented) { toolStripButtonVirtualKb.Visible = true; } // TODO: This line of code loads data into the 'dataSetCashTraysLookup.sol_CashTrays' table. You can move, or remove it, as needed. this.sol_CashTraysTableAdapter.Fill(this.dataSetCashTraysLookup.sol_CashTrays); sol_Entrie = new Sol_Entrie(); sol_Entrie_Sp = new Sol_Entrie_Sp(Properties.Settings.Default.WsirDbConnectionString); sol_EntriesDetail = new Sol_EntriesDetail(); sol_EntriesDetail_Sp = new Sol_EntriesDetail_Sp(Properties.Settings.Default.WsirDbConnectionString); //disable form resizing this.FormBorderStyle = FormBorderStyle.FixedSingle; flagInicio = true; //current cashtray //int currentTray = Properties.Settings.Default.SettingsCurrentCashTray; comboBoxCashTray.SelectedValue = Properties.Settings.Default.SettingsCurrentCashTray; flagInicio = false; dataGridViewFloat.ColumnCount = 9; dataGridViewFloat.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy; dataGridViewFloat.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; //dataGridViewFloat.ColumnHeadersDefaultCellStyle.Font = // new Font(dataGridViewFloat.Font, FontStyle.Bold); //dataGridViewFloat.Name = "dataGridViewFloat"; //dataGridViewFloat.Location = new Point(8, 8); //dataGridViewFloat.Size = new Size(500, 250); dataGridViewFloat.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders; dataGridViewFloat.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dataGridViewFloat.CellBorderStyle = DataGridViewCellBorderStyle.Single; dataGridViewFloat.GridColor = Color.Black; dataGridViewFloat.RowHeadersVisible = false; dataGridViewFloat.AllowUserToAddRows = false; int index = 0; //0 dataGridViewFloat.Columns[index].Name = "Denomination"; dataGridViewFloat.Columns[index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridViewFloat.Columns[index].Width = 160; dataGridViewFloat.Columns[index++].ReadOnly = true; //1 dataGridViewFloat.Columns[index].Name = "Type"; dataGridViewFloat.Columns[index].Width = 90; dataGridViewFloat.Columns[index++].ReadOnly = true; //2 dataGridViewFloat.Columns[index].Name = "Count"; dataGridViewFloat.Columns[index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridViewFloat.Columns[index++].Width = 80; //3 dataGridViewFloat.Columns[index].Name = "Total"; dataGridViewFloat.Columns[index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridViewFloat.Columns[index].Width = 120; dataGridViewFloat.Columns[index++].ReadOnly = true; //4 dataGridViewFloat.Columns[index].Name = "CashID"; dataGridViewFloat.Columns[index].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dataGridViewFloat.Columns[index].Width = 120; dataGridViewFloat.Columns[index].ReadOnly = true; //dataGridViewFloat.Columns[index++].Visible = false; //5 //CashValue dataGridViewFloat.Columns[index].Name = "CashValue"; dataGridViewFloat.Columns[index].Width = 150; //dataGridViewFloat.Columns[index++].Visible = false; //6 //Cash Item value dataGridViewFloat.Columns[index].Name = "CashItemValue"; dataGridViewFloat.Columns[index].Width = 150; //dataGridViewFloat.Columns[index++].Visible = false; //7 //Quantity dataGridViewFloat.Columns[index].Name = "Quantity"; dataGridViewFloat.Columns[index].Width = 150; //dataGridViewFloat.Columns[index++].Visible = false; //8 //MoneyID dataGridViewFloat.Columns[index].Name = "MoneyID"; dataGridViewFloat.Columns[index].Width = 150; //dataGridViewFloat.Columns[index++].Visible = false; closingDate = Main.rc.FechaActual; readCashDenominations(); if (entryName == "Open") { this.Text = "Open Cashier"; entryType = "O"; labelTotal1.Text = "Last Closing Value:"; labelTotal2.Text = "Opening Value:"; labelTotal3.Text = "";//New Value of Float:"; labelTotalAmount3.Text = ""; if (!SolFunctions.IsCashierClosed(ref sol_Entrie, sol_Entrie_Sp, Properties.Settings.Default.SettingsCurrentCashTray)) { DialogResult result = MessageBox.Show("The current cash tray is already open. You cannot open it until it is closed. Are you sure you want to continue?", "", MessageBoxButtons.YesNo); if (result != System.Windows.Forms.DialogResult.Yes) { Close(); return; } buttonSave.Enabled = false; //buttonUseLastClose.Enabled = false; } else { buttonUseLastClose.Enabled = true; } } else if (entryName == "Float") { this.Text = "Add Float"; entryType = "F"; labelTotal1.Text = "Current Value of Float:"; labelTotal2.Text = "Amount to add:"; labelTotal3.Text = "New Value of Float:"; //comboBoxCashTray.Enabled = false; if (SolFunctions.IsCashierClosed(ref sol_Entrie, sol_Entrie_Sp, Properties.Settings.Default.SettingsCurrentCashTray)) { buttonSave.Enabled = false; MessageBox.Show("You need to Open a new Cashier before you can add a Float!"); //Close(); //return; } } else if (entryName == "Close") { this.Text = "Close Cashier"; entryType = "C"; labelTotal1.Text = "Calculated Float:"; labelTotal2.Text = "Closing Amount Entered:"; labelTotal3.Text = "Discrepancy:"; if (Main.Sol_ControlInfo.SacCashTrayID >= 0) { if (Main.Sol_ControlInfo.SacCashTrayID == (int)comboBoxCashTray.SelectedIndex) { buttonUseCalculatedInventory.Visible = true; } } //buttonOpenDrawer.Visible = false; //comboBoxCashTray.Enabled = false; if (SolFunctions.IsCashierClosed(ref sol_Entrie, sol_Entrie_Sp, Properties.Settings.Default.SettingsCurrentCashTray)) { DialogResult result = MessageBox.Show("The current cash tray is already closed. You cannot close it until it is opened. Are you sure you want to continue?", "", MessageBoxButtons.YesNo); if (result != System.Windows.Forms.DialogResult.Yes) { Close(); return; } buttonSave.Enabled = false; } } //SAC //leer opciones //if (sac_Setting_Sp == null) // sac_Setting_Sp = new Sac_Setting_Sp(Properties.Settings.Default.WsirDbConnectionString); //sac_Setting = sac_Setting_Sp.Select("BillDispenserId"); //if(sac_Setting != null) // int.TryParse(sac_Setting.SetValue.ToString(), out billDispenserId); billDispenserId = 0; }
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(); } } }