示例#1
0
        /// <summary>
        /// Add a new entry to the RegisterDrop table
        /// </summary>
        public static RegisterDrop Add(int registerDrawerId, int employeeId, double amount, DateTime dropTime)
        {
            RegisterDrop result       = null;
            DateTime     purchaseTime = DateTime.Now;

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

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@RegisterDropRegisterDrawerId", SqlDbType.Int, registerDrawerId);
                BuildSqlParameter(sqlCmd, "@RegisterDropEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@RegisterDropAmount", SqlDbType.Float, amount);
                BuildSqlParameter(sqlCmd, "@RegisterDropTime", SqlDbType.DateTime, dropTime);
                BuildSqlParameter(sqlCmd, "@RegisterDropId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new RegisterDrop(Convert.ToInt32(sqlCmd.Parameters["@RegisterDropId"].Value),
                                              registerDrawerId, employeeId, amount, dropTime);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
示例#2
0
        /// <summary>
        /// Update an entry in the RegisterDrop table
        /// </summary>
        public static bool Update(RegisterDrop registerDrop)
        {
            bool result = false;

            SqlConnection cn = GetConnection();

            result = Update(cn, registerDrop);
            FinishedWithConnection(cn);

            return(result);
        }
示例#3
0
        /// <summary>
        /// Get an entry from the RegisterDrop table
        /// </summary>
        public static RegisterDrop Get(int id)
        {
            RegisterDrop result = null;

            SqlConnection cn = GetConnection();

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

            return(result);
        }
示例#4
0
        private static RegisterDrop Get(SqlConnection cn, int id)
        {
            RegisterDrop result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM RegisterDrop WHERE RegisterDropId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildRegisterDrop(rdr);
                    }
                }
            }
            return(result);
        }
示例#5
0
        /// <summary>
        /// Delete an entry from the RegisterDrop table
        /// </summary>
        public static bool Delete(int id)
        {
            Int32         rowsAffected = 0;
            SqlConnection cn           = GetConnection();
            RegisterDrop  registerDrop = Get(cn, id);

            if (registerDrop != null)
            {
                using (SqlCommand sqlCmd = cn.CreateCommand())
                {
                    sqlCmd.CommandText = "DELETE FROM RegisterDrop WHERE RegisterDropId=" + id;
                    rowsAffected       = sqlCmd.ExecuteNonQuery();
                }
            }
            FinishedWithConnection(cn);
            return(rowsAffected != 0);
        }
示例#6
0
        private static bool Update(SqlConnection cn, RegisterDrop registerDrop)
        {
            Int32 rowsAffected = 0;

            using (SqlCommand sqlCmd = cn.CreateCommand())
            {
                sqlCmd.CommandText = "UPDATE RegisterDrop SET RegisterDropRegisterDrawerId=@RegisterDropRegisterDrawerId,RegisterDropEmployeeId=@RegisterDropEmployeeId,RegisterDropAmount=@RegisterDropAmount,RegisterDropTime=@RegisterDropTime WHERE RegisterDropId=@RegisterDropId";

                BuildSqlParameter(sqlCmd, "@RegisterDropId", SqlDbType.Int, registerDrop.Id);
                BuildSqlParameter(sqlCmd, "@RegisterDropRegisterDrawerId", SqlDbType.Int, registerDrop.RegisterDrawerId);
                BuildSqlParameter(sqlCmd, "@RegisterDropEmployeeId", SqlDbType.Int, registerDrop.EmployeeId);
                BuildSqlParameter(sqlCmd, "@RegisterDropAmount", SqlDbType.Float, registerDrop.Amount);
                BuildSqlParameter(sqlCmd, "@RegisterDropTime", SqlDbType.DateTime, registerDrop.When);

                rowsAffected = sqlCmd.ExecuteNonQuery();
            }
            return(rowsAffected != 0);
        }