示例#1
0
        /// <summary>
        /// Creates a new instance of the Sac_ClientNames class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual Sac_ClientName MakeSac_ClientName(SqlDataReader dataReader)
        {
            Sac_ClientName sac_ClientName = new Sac_ClientName();

            sac_ClientName.ClientID            = SqlClientUtility.GetString(dataReader, "ClientID", String.Empty);
            sac_ClientName.CashTrayID          = SqlClientUtility.GetInt32(dataReader, "CashTrayID", 0);
            sac_ClientName.CoinAmountInventory = SqlClientUtility.GetDecimal(dataReader, "CoinAmountInventory", Decimal.Zero);

            return(sac_ClientName);
        }
示例#2
0
        /// <summary>
        /// Updates a record in the Sac_ClientNames table.
        /// </summary>
        public virtual void Update(Sac_ClientName sac_ClientName)
        {
            ValidationUtility.ValidateArgument("sac_ClientName", sac_ClientName);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ClientID", sac_ClientName.ClientID),
                new SqlParameter("@CashTrayID", sac_ClientName.CashTrayID),
                new SqlParameter("@CoinAmountInventory", sac_ClientName.CoinAmountInventory)
            };

            SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "Sac_ClientNames_Update", parameters);
        }
示例#3
0
        /// <summary>
        /// Selects all records from the Sac_ClientNames table.
        /// </summary>
        public virtual List <Sac_ClientName> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Sac_ClientNames_SelectAll"))
            {
                List <Sac_ClientName> sac_ClientNameList = new List <Sac_ClientName>();
                while (dataReader.Read())
                {
                    Sac_ClientName sac_ClientName = MakeSac_ClientName(dataReader);
                    sac_ClientNameList.Add(sac_ClientName);
                }

                return(sac_ClientNameList);
            }
        }
示例#4
0
文件: Float.cs 项目: ideaztech/ideaz
        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;
        }
示例#5
0
文件: Float.cs 项目: ideaztech/ideaz
        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();
                }
            }
        }