Ejemplo n.º 1
0
        public static ItemAdjustment Add(int employeeId, ItemAdjustmentType type,
                                         int itemId, int?itemOptionSetId = null)
        {
            ItemAdjustment result = null;
            SqlConnection  cn     = GetConnection();
            DateTime       when   = DateTime.Now;

            string cmd = "AddItemAdjustment";

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@ItemAdjustmentItemId", SqlDbType.Int, itemId);
                BuildSqlParameter(sqlCmd, "@ItemAdjustmentEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@ItemAdjustmentItemOptionSetId", SqlDbType.Int, itemOptionSetId);
                BuildSqlParameter(sqlCmd, "@ItemAdjustmentType", SqlDbType.TinyInt, type);
                BuildSqlParameter(sqlCmd, "@ItemAdjustmentWhen", SqlDbType.DateTime, when);
                BuildSqlParameter(sqlCmd, "@ItemAdjustmentId", SqlDbType.Int, ParameterDirection.ReturnValue);

                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new ItemAdjustment(Convert.ToInt32(sqlCmd.Parameters["@ItemAdjustmentId"].Value),
                                                employeeId, type, itemId, itemOptionSetId, when);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
Ejemplo n.º 2
0
        public static ItemAdjustment Get(int id)
        {
            ItemAdjustment result = null;
            SqlConnection  cn     = GetConnection();

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

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