Ejemplo n.º 1
0
        /// <summary>
        /// Add a new entry to the RegisterDeposit table
        /// </summary>
        public static RegisterDeposit Add(int registerDrawerId, int employeeId, double amount)
        {
            RegisterDeposit result = null;
            DateTime        when   = DateTime.Now;

            SqlConnection cn  = GetConnection();
            string        cmd = "AddRegisterDeposit";

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@RegisterDepositRegisterDrawerId", SqlDbType.Int, registerDrawerId);
                BuildSqlParameter(sqlCmd, "@RegisterDepositEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@RegisterDepositAmount", SqlDbType.Float, amount);
                BuildSqlParameter(sqlCmd, "@RegisterDepositWhen", SqlDbType.DateTime, when);
                BuildSqlParameter(sqlCmd, "@RegisterDepositId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new RegisterDeposit(Convert.ToInt32(sqlCmd.Parameters["@RegisterDepositId"].Value),
                                                 registerDrawerId, employeeId, amount, when);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get an entry from the RegisterDeposit table
        /// </summary>
        public static RegisterDeposit Get(int id)
        {
            RegisterDeposit result = null;

            SqlConnection cn = GetConnection();

            result = Get(cn, id);
            FinishedWithConnection(cn);

            return(result);
        }
Ejemplo n.º 3
0
        private static RegisterDeposit Get(SqlConnection cn, int id)
        {
            RegisterDeposit result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM RegisterDeposit WHERE RegisterDepositId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildRegisterDeposit(rdr);
                    }
                }
            }
            return(result);
        }