Ejemplo n.º 1
0
        private void EnterCashButton_Click(object sender, EventArgs e)
        {
            CashBox cashBox = new CashBox(currentEmployee.Id);
            bool    checker = cashBox.getMoney(tarjDeb_textBox.Text, tarjCre_textBox.Text,
                                               tarjCh_textBox.Text, m2000_textBox.Text, m1000_textBox.Text, m500_textBox.Text,
                                               m200_textBox.Text, m100_textBox.Text, m50_textBox.Text, m25_textBox.Text,
                                               m20_textBox.Text, m10_textBox.Text, m5_textBox.Text, m1_textBox.Text);

            if (checker)
            {
                MessageBox.Show(cashBox.Money.ToString());
                cleanData();
                if (isInsertion)
                {
                    cashBox = database.insertCashBox(cashBox);
                    if (cashBox != null)
                    {
                        if (cashBox.IsBoxClose)
                        {
                            MessageBox.Show("La Caja ha sido cerrada, el desbalance en la misma es de " + cashBox.LeftOver.ToString());
                        }
                        else
                        {
                            MessageBox.Show("La Caja ha sido abierta");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Los numeros introducidos son incorrectos.\n Favor Revisar");
            }
        }
Ejemplo n.º 2
0
        public CashBox insertCashBox(CashBox cashBox)
        {
            SqlParameter output1 = new SqlParameter("@result", SqlDbType.Money);
            SqlParameter output2 = new SqlParameter("@state", SqlDbType.Bit);

            output1.Direction = ParameterDirection.Output;
            output2.Direction = ParameterDirection.Output;
            try
            {
                SqlCommand cmd = (SqlCommand)RunStoredProc("insertCashBox", false,
                                                           new SqlParameter("@id", cashBox.EmployeeId),
                                                           new SqlParameter("@cashInDebitCard", cashBox.CashInDebitCard),
                                                           new SqlParameter("@cashInCreditCard", cashBox.CashInCreditCard),
                                                           new SqlParameter("@cashInCheck", cashBox.CashInCheck),
                                                           new SqlParameter("@m2000", cashBox.Money[10]),
                                                           new SqlParameter("@m1000", cashBox.Money[9]),
                                                           new SqlParameter("@m500", cashBox.Money[8]),
                                                           new SqlParameter("@m200", cashBox.Money[7]),
                                                           new SqlParameter("@m100", cashBox.Money[6]),
                                                           new SqlParameter("@m50", cashBox.Money[5]),
                                                           new SqlParameter("@m25", cashBox.Money[4]),
                                                           new SqlParameter("@m20", cashBox.Money[3]),
                                                           new SqlParameter("@m10", cashBox.Money[2]),
                                                           new SqlParameter("@m5", cashBox.Money[1]),
                                                           new SqlParameter("@m1", cashBox.Money[0]),
                                                           new SqlParameter("@moneyInBox", cashBox.MoneyInBox),
                                                           output1, output2
                                                           );
                cashBox.IsBoxClose = (bool)cmd.Parameters["@state"].Value;
                cashBox.LeftOver   = Double.Parse(cmd.Parameters["@result"].Value.ToString());

                return(cashBox);
            }
            catch (SqlException esql)
            {
                MessageBox.Show(esql.ToString());
                return(null);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return(null);
            }
        }
Ejemplo n.º 3
0
        public CashBox modifyCashBox(CashBox cashBox)
        {
            CashBox ans = null;

            try
            {
                SqlDataReader rdr = (SqlDataReader)RunStoredProc("modifyCashBox", true,
                                                                 new SqlParameter("@idEmployee", cashBox.EmployeeId),
                                                                 new SqlParameter("@idCashBox", cashBox.Id),
                                                                 new SqlParameter("@cashInDebitCard", cashBox.CashInDebitCard),
                                                                 new SqlParameter("@cashInCreditCard", cashBox.CashInCreditCard),
                                                                 new SqlParameter("@cashInCheck", cashBox.CashInCheck),
                                                                 new SqlParameter("@m2000", cashBox.Money[10]),
                                                                 new SqlParameter("@m1000", cashBox.Money[9]),
                                                                 new SqlParameter("@m500", cashBox.Money[8]),
                                                                 new SqlParameter("@m200", cashBox.Money[7]),
                                                                 new SqlParameter("@m100", cashBox.Money[6]),
                                                                 new SqlParameter("@m50", cashBox.Money[5]),
                                                                 new SqlParameter("@m25", cashBox.Money[4]),
                                                                 new SqlParameter("@m20", cashBox.Money[3]),
                                                                 new SqlParameter("@m10", cashBox.Money[2]),
                                                                 new SqlParameter("@m5", cashBox.Money[1]),
                                                                 new SqlParameter("@m1", cashBox.Money[0]),
                                                                 new SqlParameter("@moneyInBox", cashBox.MoneyInBox),
                                                                 new SqlParameter("@wasCreated", cashBox.WasCreated)
                                                                 );
                if (rdr.Read())
                {
                    ans = new CashBox(
                        Int32.Parse(rdr.GetInt32(rdr.GetOrdinal("cashboxID")).ToString()),
                        cashBox.Id,
                        Double.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("cashInDebitCard")).ToString()),
                        Double.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("cashInCreditCard")).ToString()),
                        Double.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("cashInCheck")).ToString()),

                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m2000")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m1000")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m500")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m200")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m100")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m50")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m25")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m20")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m10")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m5")).ToString()),
                        Int32.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("m1")).ToString()),

                        Double.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("unbalance")).ToString()),
                        Double.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("grossMoney")).ToString()),
                        Double.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("discountMoney")).ToString()),
                        Double.Parse(rdr.GetSqlMoney(rdr.GetOrdinal("moneyInBox")).ToString()),
                        Boolean.Parse(rdr.GetInt32(rdr.GetOrdinal("isBoxClose")).ToString()),
                        DateTime.Parse(rdr.GetSqlDateTime(rdr.GetOrdinal("wasCreated")).ToString())
                        );
                }
                if (rdr != null)
                {
                    rdr.Close();
                }
                return(null);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return(ans);
            }
        }