Esempio n. 1
0
        /// <summary>
        /// Update an entry in the Printer table
        /// </summary>
        public static bool Update(PrintOption printOption)
        {
            bool result = false;

            SqlConnection cn = GetConnection();

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

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Get an entry from the Printer table
        /// </summary>
        public static PrintOption Get(int id)
        {
            PrintOption result = null;

            SqlConnection cn = GetConnection();

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

            return(result);
        }
Esempio n. 3
0
        private static bool Update(SqlConnection cn, PrintOption printOption)
        {
            Int32 rowsAffected = 0;

            using (SqlCommand sqlCmd = cn.CreateCommand())
            {
                sqlCmd.CommandText = "UPDATE PrintOption SET PrintOptionPrintOptionSetId=@PrintOptionPrintOptionSetId,PrintOptionPrinterId=@PrintOptionPrinterId WHERE PrintOptionId=@PrintOptionId";

                BuildSqlParameter(sqlCmd, "@PrintOptionId", SqlDbType.Int, printOption.Id);
                BuildSqlParameter(sqlCmd, "@PrintOptionPrintOptionSetId", SqlDbType.Int, printOption.PrintOptionSetId);
                BuildSqlParameter(sqlCmd, "@PrintOptionPrinterId", SqlDbType.Int, printOption.PrinterId);

                rowsAffected = sqlCmd.ExecuteNonQuery();
            }
            return(rowsAffected != 0);
        }
Esempio n. 4
0
        private static PrintOption Get(SqlConnection cn, int id)
        {
            PrintOption result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM PrintOption WHERE PrintOptionId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildPrintOption(rdr);
                    }
                }
            }
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Delete an entry from the Printer table
        /// </summary>
        public static bool Delete(int id)
        {
            Int32         rowsAffected = 0;
            SqlConnection cn           = GetConnection();
            PrintOption   printOption  = Get(cn, id);

            if (printOption != null)
            {
                using (SqlCommand sqlCmd = cn.CreateCommand())
                {
                    sqlCmd.CommandText = "DELETE FROM PrintOption WHERE PrintOptionId=" + id;
                    rowsAffected       = sqlCmd.ExecuteNonQuery();
                }
            }
            FinishedWithConnection(cn);
            return(rowsAffected != 0);
        }
Esempio n. 6
0
        /// <summary>
        /// Add a new entry to the Printer table
        /// </summary>
        public static PrintOption Add(int printerOptionSetId, int printerId)
        {
            PrintOption result       = null;
            DateTime    purchaseTime = DateTime.Now;

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

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@PrintOptionPrintOptionSetId", SqlDbType.Int, printerOptionSetId);
                BuildSqlParameter(sqlCmd, "@PrintOptionPrinterId", SqlDbType.Int, purchaseTime);
                BuildSqlParameter(sqlCmd, "@PrintOptionId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new PrintOption(Convert.ToInt32(sqlCmd.Parameters["@PrintOptionId"].Value),
                                             printerOptionSetId, printerId);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }
Esempio n. 7
0
 public bool Update()
 {
     return(PrintOption.Update(this));
 }