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

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

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@RegisterNoSaleRegisterDrawerId", SqlDbType.Int, registerDrawerId);
                BuildSqlParameter(sqlCmd, "@RegisterNoSaleEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@RegisterNoSaleTime", SqlDbType.DateTime, noSaleTime);
                BuildSqlParameter(sqlCmd, "@RegisterNoSaleId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new RegisterNoSale(Convert.ToInt32(sqlCmd.Parameters["@RegisterNoSaleId"].Value),
                                                registerDrawerId, employeeId, noSaleTime);
                }
            }
            FinishedWithConnection(cn);

            return(result);
        }
示例#2
0
        /// <summary>
        /// Update an entry in the RegisterNoSale table
        /// </summary>
        public static bool Update(RegisterNoSale registerNoSale)
        {
            bool result = false;

            SqlConnection cn = GetConnection();

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

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

            SqlConnection cn = GetConnection();

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

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

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM RegisterNoSale WHERE RegisterNoSaleId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildRegisterNoSale(rdr);
                    }
                }
            }
            return(result);
        }
示例#5
0
        private static bool Update(SqlConnection cn, RegisterNoSale registerNoSale)
        {
            Int32 rowsAffected = 0;

            using (SqlCommand sqlCmd = cn.CreateCommand())
            {
                sqlCmd.CommandText = "UPDATE RegisterNoSale SET RegisterNoSaleRegisterDrawerId=@RegisterNoSaleRegisterDrawerId,RegisterNoSaleEmployeeId=@RegisterNoSaleEmployeeId,RegisterNoSaleTime=@RegisterNoSaleTime WHERE RegisterNoSaleId=@RegisterNoSaleId";

                BuildSqlParameter(sqlCmd, "@RegisterNoSaleId", SqlDbType.Int, registerNoSale.Id);
                BuildSqlParameter(sqlCmd, "@RegisterNoSaleRegisterDrawerId", SqlDbType.Int, registerNoSale.RegisterDrawerId);
                BuildSqlParameter(sqlCmd, "@RegisterNoSaleEmployeeId", SqlDbType.Int, registerNoSale.EmployeeId);
                BuildSqlParameter(sqlCmd, "@RegisterNoSaleTime", SqlDbType.DateTime, registerNoSale.When);

                rowsAffected = sqlCmd.ExecuteNonQuery();
            }
            return(rowsAffected != 0);
        }
示例#6
0
        /// <summary>
        /// Delete an entry from the RegisterNoSale table
        /// </summary>
        public static bool Delete(int id)
        {
            Int32          rowsAffected   = 0;
            SqlConnection  cn             = GetConnection();
            RegisterNoSale registerNoSale = Get(cn, id);

            if (registerNoSale != null)
            {
                using (SqlCommand sqlCmd = cn.CreateCommand())
                {
                    sqlCmd.CommandText = "DELETE FROM RegisterNoSale WHERE RegisterNoSaleId=" + id;
                    rowsAffected       = sqlCmd.ExecuteNonQuery();
                }
            }
            FinishedWithConnection(cn);
            return(rowsAffected != 0);
        }