Esempio n. 1
0
        public static ItemOptionAdjustment Get(int id)
        {
            ItemOptionAdjustment result = null;
            SqlConnection        cn     = GetConnection();

            result = Get(cn, id);
            FinishedWithConnection(cn);
            return(result);
        }
Esempio n. 2
0
        private static ItemOptionAdjustment Get(SqlConnection cn, int id)
        {
            ItemOptionAdjustment result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM ItemAdjustment WHERE ItemAdjustmentId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildItemOptionAdjustment(rdr);
                    }
                }
            }
            return(result);
        }
Esempio n. 3
0
        public static ItemOptionAdjustment Add(int employeeId, ItemOptionAdjustmentType type,
                                               int?itemOptionSetId, int?itemOptionId, int?oldProductId, int?newProductId,
                                               byte?oldTinyIntValue, byte?newTinyIntValue, double?oldFloatValue,
                                               double?newFloatValue)
        {
            ItemOptionAdjustment result = null;
            SqlConnection        cn     = GetConnection();
            DateTime             when   = DateTime.Now;

            string cmd = "AddItemOptionAdjustment";

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentItemOptionSetId", SqlDbType.Int, itemOptionSetId);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentItemOptionId", SqlDbType.Int, itemOptionId);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentType", SqlDbType.TinyInt, type);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentOldProductId", SqlDbType.Int, oldProductId);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentNewProductId", SqlDbType.Int, newProductId);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentOldTinyIntValue", SqlDbType.TinyInt, oldTinyIntValue);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentNewTinyIntValue", SqlDbType.TinyInt, newTinyIntValue);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentOldFloatValue", SqlDbType.Float, oldFloatValue);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentNewFloatValue", SqlDbType.Float, newFloatValue);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentWhen", SqlDbType.DateTime, when);
                BuildSqlParameter(sqlCmd, "@ItemOptionAdjustmentId", SqlDbType.Int, ParameterDirection.ReturnValue);

                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new ItemOptionAdjustment(Convert.ToInt32(sqlCmd.Parameters["@ItemAdjustmentId"].Value),
                                                      employeeId, type, itemOptionSetId, itemOptionId, oldProductId, newProductId, oldTinyIntValue,
                                                      newTinyIntValue, oldFloatValue, newFloatValue, when);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }