예제 #1
0
        /// <summary>
        /// Удаление [Материала для продукта]
        /// </summary>
        public static bool Delete(Material material, Product editedProduct)
        {
            var mssqlServer = Properties.Settings.Default.SqlServerNu65;
            var mssqlDb     = Properties.Settings.Default.SqlDbNu65Db;

            try
            {
                using (var mssqlConnection = DbControl.GetConnection(mssqlServer, mssqlDb))
                {
                    mssqlConnection.TryConnectOpen();
                    using (var mssqlTransaction = mssqlConnection.BeginTransaction())
                    {
                        // Удаление записи о материале в MSSQL таблице
                        Nu65StorageMssql.DeleteById(material.Nu65TableId, mssqlConnection, mssqlTransaction);

                        var foxproDbPath = Properties.Settings.Default.FoxproDbFolder_Fox60_Arm_Base;


                        using (var oleDbConnection = DbControl.GetConnection(foxproDbPath))
                        {
                            oleDbConnection.TryConnectOpen();
                            Nu65StorageFoxpro.TestConnection(oleDbConnection);

                            // Удаление записи о материале в FoxPro таблице
                            Nu65StorageFoxpro.DeleteByMaterialCode(oleDbConnection, editedProduct.DisplayCodeString, material.CodeMaterial,
                                                                   material.WorkGuildId, material.ParcelId);

                            // Подтверждение транзакции MSSQL
                            mssqlTransaction.Commit();
                            return(true);
                        }
                    }
                }
            }
            catch (DbException ex) // DbException - суперкласс для SqlException и OleDbException
            {
                throw DbControl.HandleKnownDbFoxProAndMssqlServerExceptions(ex);
            }
        }