⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscordset.cs

📁 酒店管理软件,c#版本可以选择不同的模式
💻 CS
📖 第 1 页 / 共 2 页
字号:

                //if (CordDm != CordDm_Fornt || CordMemo != CordMemo_Fornt || Check1 != Check1_Fornt || Check2 != Check2_Fornt)
                //{
                
                    DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
                    db.AddInParameter(dbCommand, "CordDm", DbType.String, CordDm);
                    db.AddInParameter(dbCommand, "CordMemo", DbType.String, CordMemo);
                    db.AddInParameter(dbCommand, "Check1", DbType.Boolean, Check1);
                    db.AddInParameter(dbCommand, "Check2", DbType.Boolean, Check2);
                    db.AddInParameter(dbCommand, "@FlowId", DbType.Int32, FlowId_Fornt);

                    // DataSet that will hold the returned results		
                     results += db.ExecuteNonQuery(dbCommand);
                 //}
            }
 


            return results;

        }

        public int UpdateSysCordSet(DataGridView dataGridView1, DataGridView DataGridViewFornt)
       {
            Int32 results = 0;

            string CordId = "";
            Int32 FlowId = 0;

            //string CordId_Fornt = "";
            //Int32 FlowId_Fornt = 0;

            Database db = DatabaseFactory.CreateDatabase();
            string sqlCommand = "UpdateSysCordSet";


            for (int i = 0; i < dataGridView1.RowCount-1; i++)
            {

                CordId = dataGridView1.Rows[i].Cells[0].Value.ToString();
                FlowId = System.Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
                //CordId_Fornt = DataGridViewFornt.Rows[i].Cells[0].Value.ToString();


               // if (CordId_Fornt != CordId)
               // {
                    DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
                    db.AddInParameter(dbCommand, "@CordId", DbType.String, CordId);
                    db.AddInParameter(dbCommand, "@FlowId", DbType.Int32, FlowId);

                    // DataSet that will hold the returned results		
                    results += db.ExecuteNonQuery(dbCommand);
               // }
 
            }

            return results;

        }

        /// <summary>
        /// Retrieves details about the specified product.
        /// </summary>
        /// <param name="productID">The ID of the product used to retrieve details.</param>
        /// <returns>The product details as a string.</returns>
        /// <remarks>Demonstrates retrieving a single row of data using output parameters.</remarks>
        public string GetProductDetails(int productID)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase();

            string sqlCommand = "GetProductDetails";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);

            // Add paramters
            // Input parameters can specify the input value
            db.AddInParameter(dbCommand, "ProductID", DbType.Int32, productID);
            // Output parameters specify the size of the return data
            db.AddOutParameter(dbCommand, "ProductName", DbType.String, 50);
            db.AddOutParameter(dbCommand, "UnitPrice", DbType.Currency, 8);

            db.ExecuteNonQuery(dbCommand);

            // Row of data is captured via output parameters
            string results = string.Format(CultureInfo.CurrentCulture, "{0}, {1}, {2:C} ",
                                           db.GetParameterValue(dbCommand, "ProductID"),
                                           db.GetParameterValue(dbCommand, "ProductName"),
                                           db.GetParameterValue(dbCommand, "UnitPrice"));

            return results;
        }

        /// <summary>
        /// Retrieves the specified product's name.
        /// </summary>
        /// <param name="productID">The ID of the product.</param>
        /// <returns>The name of the product.</returns>
        /// <remarks>Demonstrates retrieving a single item. Parameter discovery
        /// is used for determining the properties of the productID parameter.</remarks>
        public string GetProductName(int productID)
        {
            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase();

            // Passing the productID value to the GetStoredProcCommand
            // results in parameter discovery being used to correctly establish the parameter
            // information for the productID. Subsequent calls to this method will
            // cause the block to retrieve the parameter information from the 
            // cache, and not require rediscovery.
            string sqlCommand = "GetProductName";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand, productID);

            // Retrieve ProdcutName. ExecuteScalar returns an object, so
            // we cast to the correct type (string).
            string productName = (string)db.ExecuteScalar(dbCommand);

            return productName;
        }

        /// <summary>
        /// Retrieves a list of products.
        /// </summary>
        /// <returns>A list of products as an XML string.</returns>
        /// <remarks>Demonstrates retrieving multiple rows of data as XML. This
        /// method is not portable across database providers, but is 
        /// specific to the SqlDatabase.</remarks>
        public string GetProductList()
        {
            // Use a named database instance that refers to a SQL Server database.
            SqlDatabase dbSQL = DatabaseFactory.CreateDatabase() as SqlDatabase;

            // Use "FOR XML AUTO" to have SQL return XML data
            string sqlCommand = "Select ProductID, ProductName, CategoryID, UnitPrice, LastUpdate " +
                "From Products FOR XML AUTO";
            DbCommand dbCommand = dbSQL.GetSqlStringCommand(sqlCommand);

            XmlReader productsReader = null;
            StringBuilder productList = new StringBuilder();

            try
            {
                productsReader = dbSQL.ExecuteXmlReader(dbCommand);

                // Iterate through the XmlReader and put the data into our results.
                while (!productsReader.EOF)
                {
                    if (productsReader.IsStartElement())
                    {
                        productList.Append(productsReader.ReadOuterXml());
                        productList.Append(Environment.NewLine);
                    }
                }
            }
            finally
            {
                // Close the Reader.
                if (productsReader != null)
                {
                    productsReader.Close();
                }

                // Explicitly close the connection. The connection is not closed
                // when the XmlReader is closed.
                if (dbCommand.Connection != null)
                {
                    dbCommand.Connection.Close();
                }
            }

            return productList.ToString();
        }

        /// <summary>
        /// Transfers an amount between two accounts.
        /// </summary>
        /// <param name="transactionAmount">Amount to transfer.</param>
        /// <param name="sourceAccount">Account to be credited.</param>
        /// <param name="destinationAccount">Account to be debited.</param>
        /// <returns>true if sucessful; otherwise false.</returns>
        /// <remarks>Demonstrates executing multiple updates within the 
        /// context of a transaction.</remarks>
        public bool Transfer(int transactionAmount, int sourceAccount, int destinationAccount)
        {
            bool result = false;

            // Create the Database object, using the default database service. The
            // default database service is determined through configuration.
            Database db = DatabaseFactory.CreateDatabase();

            // Two operations, one to credit an account, and one to debit another
            // account.
            string sqlCommand = "CreditAccount";
            DbCommand creditCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(creditCommand, "AccountID", DbType.Int32, sourceAccount);
            db.AddInParameter(creditCommand, "Amount", DbType.Int32, transactionAmount);

            sqlCommand = "DebitAccount";
            DbCommand debitCommand = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(debitCommand, "AccountID", DbType.Int32, destinationAccount);
            db.AddInParameter(debitCommand, "Amount", DbType.Int32, transactionAmount);

            using (DbConnection connection = db.CreateConnection())
            {
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    // Credit the first account
                    db.ExecuteNonQuery(creditCommand, transaction);
                    // Debit the second account
                    db.ExecuteNonQuery(debitCommand, transaction);

                    // Commit the transaction
                    transaction.Commit();

                    result = true;
                }
                catch
                {
                    // Rollback transaction 
                    transaction.Rollback();
                }
                connection.Close();

                return result;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -