public bool CloseInstallation(int InstallationNo, int MachineStatusFlag, string MachineTransitSiteCode)
        {
            bool result = true;

            using (SqlConnection conn = new SqlConnection(CommonDataAccess.ExchangeConnectionString))
            {
                try
                {
                    conn.Open();
                    if (System.Transactions.Transaction.Current != null)
                    {
                        conn.EnlistTransaction(System.Transactions.Transaction.Current);
                    }

                    CloseInstallationArg argument = new CloseInstallationArg()
                    {
                        InstallationNo         = InstallationNo,
                        MachineStatusFlag      = MachineStatusFlag,
                        MachineTransitSiteCode = MachineTransitSiteCode
                    };
                    CloseInstallationHandler[] handlers = new CloseInstallationHandler[]
                    {
                        CloseInstallation_Machine, CloseInstallation_Read, CloseInstallation_VTP,
                        CloseInstallation_MeterHistory, CloseInstallation_MGMD,
                        CloseInstallation_FloorFinancials, CloseInstallation_BAD_IGI
                    };

                    foreach (CloseInstallationHandler handler in handlers)
                    {
                        try
                        {
                            result &= handler(conn, argument);
                        }
                        catch (Exception ex2)
                        {
                            ExceptionManager.Publish(ex2);
                            result &= false;
                        }
                        if (!result)
                        {
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.Publish(ex);
                    result = false;
                }
            }
            return(result);
        }
        private bool CloseInstallation_FloorFinancials(SqlConnection conn, CloseInstallationArg argument)
        {
            SqlParameter[] objSQlParams = new SqlParameter[1];

            SqlParameter objSQL1 = new SqlParameter();

            objSQL1.ParameterName = "InstallationNo";
            objSQL1.Direction     = ParameterDirection.Input;
            objSQL1.Value         = argument.InstallationNo;
            objSQlParams[0]       = objSQL1;

            return(this.ExecuteQueryWithCommandTimeout(conn, "dbo.usp_CloseInstallation_FloorFinancials", objSQlParams));
        }
        //Call the installation and machine
        private bool CloseInstallation_Machine(SqlConnection conn, CloseInstallationArg argument)
        {
            SqlParameter[] objSQlParams = new SqlParameter[5];

            SqlParameter objSQL1 = new SqlParameter();

            objSQL1.ParameterName = "InstallationNo";
            objSQL1.Direction     = ParameterDirection.Input;
            objSQL1.Value         = argument.InstallationNo;
            objSQlParams[0]       = objSQL1;

            SqlParameter objSQL2 = new SqlParameter();

            objSQL2.ParameterName = "UserID";
            objSQL2.Direction     = ParameterDirection.Input;
            objSQL2.Value         = Security.SecurityHelper.CurrentUser.SecurityUserID;
            objSQlParams[1]       = objSQL2;

            SqlParameter objSQL3 = new SqlParameter();

            objSQL3.ParameterName = "MachineStatusFlag";
            objSQL3.Direction     = ParameterDirection.Input;
            objSQL3.Value         = argument.MachineStatusFlag;
            objSQlParams[2]       = objSQL3;

            SqlParameter objSQL4 = new SqlParameter();

            objSQL4.ParameterName = "MachineTransitSiteCode";
            objSQL4.Direction     = ParameterDirection.Input;
            objSQL4.Value         = argument.MachineTransitSiteCode;
            objSQlParams[3]       = objSQL4;

            SqlParameter objSQL5 = new SqlParameter();

            objSQL5.ParameterName = "SerialNo";
            objSQL5.Direction     = ParameterDirection.Output;
            objSQL5.Size          = 50;
            objSQlParams[4]       = objSQL5;

            return(this.ExecuteQueryWithCommandTimeout(conn, "dbo.usp_CloseInstallation_Machine", objSQlParams,
                                                       () =>
            {
                if (objSQL5.Value != DBNull.Value)
                {
                    argument.SerialNo = objSQL5.Value.ToString();
                }
            }));
        }
        private bool CloseInstallation_BAD_IGI(SqlConnection conn, CloseInstallationArg argument)
        {
            SqlParameter[] objSQlParams = new SqlParameter[2];

            SqlParameter objSQL1 = new SqlParameter();

            objSQL1.ParameterName = "InstallationNo";
            objSQL1.Direction     = ParameterDirection.Input;
            objSQL1.Value         = argument.InstallationNo;
            objSQlParams[0]       = objSQL1;

            SqlParameter objSQL2 = new SqlParameter();

            objSQL2.ParameterName = "SerialNo";
            objSQL2.Direction     = ParameterDirection.Input;
            objSQL2.Value         = argument.SerialNo;
            objSQlParams[1]       = objSQL2;

            return(this.ExecuteQueryWithCommandTimeout(conn, "dbo.usp_CloseInstallation_BAD_IGI", objSQlParams));
        }