public void createReport(Object theReportSettings)
        {
            MWDataManager.clsDataAccess _sect = new MWDataManager.clsDataAccess();
            _sect.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _sect.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _sect.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _sect.ResultsTableName   = "sect";
            _sect.SqlStatement       = "select top 1 name from section where sectionid='" + reportSettings.sectionid + "'";
            _sect.ExecuteInstruction();

            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
            _dbMan.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _dbMan.SqlStatement       = "sp_StatusDetails";
            _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _dbMan.ExecuteInstruction();

            MWDataManager.clsDataAccess _RevisedStatus = new MWDataManager.clsDataAccess();
            _RevisedStatus.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _RevisedStatus.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _RevisedStatus.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _RevisedStatus.ResultsTableName   = "RevisedStatus";
            _RevisedStatus.SqlStatement       = "sp_RevisedPlanningAudit";

            try
            {
                SqlParameter[] _paramCollection2 =
                {
                    _RevisedStatus.CreateParameter("@Prodmonth",   SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsInt(reportSettings.FromProdmonth)),
                    _RevisedStatus.CreateParameter("@ToProdmonth", SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsInt(reportSettings.ToProdmonth)),
                    _RevisedStatus.CreateParameter("@Section",     SqlDbType.VarChar, 30, reportSettings.sectionid),
                    _RevisedStatus.CreateParameter("@RevisedType", SqlDbType.VarChar, 50, reportSettings.RevisedPlanningType),
                };

                _RevisedStatus.ParamCollection = _paramCollection2;
                _RevisedStatus.ExecuteInstruction();
            }
            catch (Exception _exception)
            {
                throw new ApplicationException(_exception.Message, _exception);
            }

            DataTable changetype = new DataTable();

            changetype           = _RevisedStatus.ResultsDataTable.DefaultView.ToTable(true, "ChangeType");
            changetype.TableName = "ChangeType";

            MWDataManager.clsDataAccess _RevisedStatusDetails = new MWDataManager.clsDataAccess();
            _RevisedStatusDetails.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _RevisedStatusDetails.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _RevisedStatusDetails.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _RevisedStatusDetails.ResultsTableName   = "RevisedStatusDetails";
            _RevisedStatusDetails.SqlStatement       = "sp_RevisedPlanningAudit_StatusDetail";

            try
            {
                SqlParameter[] _paramCollection8 =
                {
                    _RevisedStatus.CreateParameter("@Prodmonth",   SqlDbType.Int, 0, TProductionGlobal.ProdMonthAsInt(reportSettings.FromProdmonth)),
                    _RevisedStatus.CreateParameter("@ToProdmonth", SqlDbType.Int, 0, TProductionGlobal.ProdMonthAsInt(reportSettings.ToProdmonth)),
                };

                _RevisedStatusDetails.ParamCollection = _paramCollection8;
                _RevisedStatusDetails.ExecuteInstruction();
            }
            catch (Exception _exception)
            {
                throw new ApplicationException(_exception.Message, _exception);
            }

            MWDataManager.clsDataAccess _RevisedSummarybet = new MWDataManager.clsDataAccess();
            _RevisedSummarybet.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _RevisedSummarybet.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _RevisedSummarybet.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _RevisedSummarybet.ResultsTableName   = "RevisedSummarybet";
            _RevisedSummarybet.SqlStatement       = "sp_Revised_Audit_Summary";

            try
            {
                SqlParameter[] _paramCollection4 =
                {
                    _RevisedStatus.CreateParameter("@Prodmonth",   SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsInt(reportSettings.FromProdmonth)),
                    _RevisedStatus.CreateParameter("@ToProdmonth", SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsInt(reportSettings.ToProdmonth)),
                    _RevisedSummarybet.CreateParameter("@Section", SqlDbType.VarChar, 30, reportSettings.sectionid),
                    _RevisedSummarybet.CreateParameter("@between", SqlDbType.VarChar, 50, "0"),
                };

                _RevisedSummarybet.ParamCollection = _paramCollection4;
                _RevisedSummarybet.ExecuteInstruction();
            }
            catch (Exception _exception)
            {
                throw new ApplicationException(_exception.Message, _exception);
            }

            MWDataManager.clsDataAccess _RevisedSummarynotbet = new MWDataManager.clsDataAccess();
            _RevisedSummarynotbet.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _RevisedSummarynotbet.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _RevisedSummarynotbet.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _RevisedSummarynotbet.ResultsTableName   = "RevisedSummarynotbet";
            _RevisedSummarynotbet.SqlStatement       = "sp_Revised_Audit_Summary";

            try
            {
                SqlParameter[] _paramCollection3 =
                {
                    _RevisedStatus.CreateParameter("@Prodmonth",      SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsInt(reportSettings.FromProdmonth)),
                    _RevisedStatus.CreateParameter("@ToProdmonth",    SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsInt(reportSettings.ToProdmonth)),
                    _RevisedSummarynotbet.CreateParameter("@Section", SqlDbType.VarChar, 30, reportSettings.sectionid),
                    _RevisedSummarynotbet.CreateParameter("@between", SqlDbType.VarChar, 50, "1"),
                };

                _RevisedSummarynotbet.ParamCollection = _paramCollection3;
                _RevisedSummarynotbet.ExecuteInstruction();
            }
            catch (Exception _exception)
            {
                throw new ApplicationException(_exception.Message, _exception);
            }

            DataSet RevisedAudit = new DataSet();

            RevisedAudit.Tables.Add(_sect.ResultsDataTable);
            RevisedAudit.Tables.Add(_RevisedStatus.ResultsDataTable);
            RevisedAudit.Tables.Add(_RevisedStatusDetails.ResultsDataTable);
            RevisedAudit.Tables.Add(_RevisedSummarybet.ResultsDataTable);
            RevisedAudit.Tables.Add(_RevisedSummarynotbet.ResultsDataTable);
            RevisedAudit.Tables.Add(changetype);
            theReport.RegisterData(RevisedAudit);
            theReport.Load(TGlobalItems.ReportsFolder + "\\Revised_Audit_Report.frx");

            theReport.SetParameterValue("logo", TGlobalItems.ClientLogo);
            theReport.SetParameterValue("logoMineware", TGlobalItems.CompanyLogo);
            theReport.SetParameterValue("type", reportSettings.RevisedPlanningType);

            //theReport.Design();


            if (TParameters.DesignReport)
            {
                theReport.Design();
            }
            theReport.Prepare();

            ActiveReport.SetReport = theReport;
            ActiveReport.isDone    = true;
        }
        public bool loadPrePlanning(DateTime Prodmonth, string SectionID_2, int Activity)
        {
            MWDataManager.clsDataAccess _ApprovedInfo = new MWDataManager.clsDataAccess();
            _ApprovedInfo.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _ApprovedInfo.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _ApprovedInfo.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _ApprovedInfo.SqlStatement       = "sp_PrePlanning_GetApprovedInfo";

            _Prodmonth   = Prodmonth;
            _SectionID_2 = SectionID_2;
            _Activity    = Activity;

            SqlParameter[] _paramCollection =
            {
                _ApprovedInfo.CreateParameter("@Prodmonth",   SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsInt(Prodmonth)),
                _ApprovedInfo.CreateParameter("@SectionID_2", SqlDbType.VarChar, 20, SectionID_2),
                _ApprovedInfo.CreateParameter("@Activity",    SqlDbType.Int,      0, Activity),
                _ApprovedInfo.CreateParameter("@CurrentUser", SqlDbType.VarChar, 20, TUserInfo.UserID),
            };

            _ApprovedInfo.ParamCollection = _paramCollection;
            _ApprovedInfo.ExecuteInstruction();

            if (_ApprovedInfo.ResultsDataTable.Rows.Count > 0)
            {
                theApproveData = _ApprovedInfo.ResultsDataTable.Clone();
                DataRow[] theApprovedWP = _ApprovedInfo.ResultsDataTable.Select("CanApprove = 2");
                foreach (DataRow row in theApprovedWP)
                {
                    theApproveData.ImportRow(row);
                }
                gcApprovePrePlanning.DataSource = theApproveData;


                this.fieldDepartmentApproved.KPIGraphic = PivotKPIGraphic.Shapes;
                this.pgWorkplaceList.Fields.AddRange(new PivotGridField[] { this.fieldWorkplaceDesc });
                this.pgWorkplaceList.Fields.AddRange(new PivotGridField[] { this.fieldTheGroup });
                this.pgWorkplaceList.Fields.AddRange(new PivotGridField[] { this.fieldTemplateName });
                this.pgWorkplaceList.Fields.AddRange(new PivotGridField[] { fieldDepartmentApproved });
                this.pgWorkplaceList.Groups.Add(fieldTheGroup, fieldTemplateName);

                MWDataManager.clsDataAccess _TemplateList = new MWDataManager.clsDataAccess();
                _TemplateList.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _TemplateList.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _TemplateList.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _TemplateList.SqlStatement       = "SELECT TemplateName,TemplateID,USR1.USERID USER1,USR2.USERID USER2 FROM dbo.PlanProt_Template PPT " +
                                                   "LEFT JOIN Users USR1 ON " +
                                                   "PPT.User1 = USR1.USERID " +
                                                   "LEFT JOIN (SELECT * FROM dbo.USERS) USR2 ON " +
                                                   "PPt.User2 = USR2.USERID " +
                                                   "WHERE Activity = " + Activity.ToString();

                _TemplateList.ExecuteInstruction();

                //foreach (DataRow row in _TemplateList.ResultsDataTable.Rows)
                //{
                //    cbcTemplateList.Items.Add(row["TemplateName"]);
                //}
                cbcTemplateList.DisplayMember = "TemplateName";
                cbcTemplateList.ValueMember   = "TemplateID";

                cbcTemplateList.DataSource = _TemplateList.ResultsDataTable;

                pgWorkplaceList.DataSource = _ApprovedInfo.ResultsDataTable;

                pgWorkplaceList.Fields[1].Appearance.Header.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
                pgWorkplaceList.Fields[1].BestFit();

                fieldTemplateName.ColumnValueLineCount = 10;
                fieldWorkplaceDesc.Caption             = "Workplace";
                fieldWorkplaceDesc.Width              = 120;
                fieldTheGroup.Options.AllowExpand     = DevExpress.Utils.DefaultBoolean.False;
                fieldTemplateName.Options.AllowExpand = DevExpress.Utils.DefaultBoolean.False;

                this.fieldTemplateName.Width = 30;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void btnSendMessage_Click(object sender, EventArgs e)
        {
            foreach (var item in cbcTemplateList.CheckedItems)
            {
                int items = Convert.ToInt32((item as DataRowView)["TemplateID"].ToString());
                MWDataManager.clsDataAccess _GetData = new MWDataManager.clsDataAccess();
                _GetData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _GetData.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _GetData.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _GetData.SqlStatement       = "SELECT d1.TemplateID,d1.User1,d1.TemplateName from( " +
                                              "SELECT PPT.TemplateID,PPT.TemplateName,PPAU.User1,PPAU.User2 FROM dbo.PlanProt_Template PPT " +
                                              "INNER JOIN dbo.PlanProt_ApproveUsers PPAU ON " +
                                              "PPT.TemplateID = PPAU.TemplateID " +
                                              "INNER JOIN vw_Section_from_MO SC  ON " +
                                              "(SC.Name_3 = PPAU.Shaft OR " +
                                              "SC.Name_4 = PPAU.Shaft) AND " +
                                              "SC.SECTIONID_2 = '" + _SectionID_2 + "' " +
                                              "WHERE PPT.TemplateID = '" + Convert.ToString(items) + "' AND " +
                                              "      PPT.Activity = " + Convert.ToString(_Activity) + "  AND " +
                                              "      SC.PRODMONTH = " + Convert.ToString(TProductionGlobal.ProdMonthAsInt(_Prodmonth)) + " ) d1 " +
                                              " where d1.User1<>'' GROUP BY TemplateID,User1,TemplateName";
                _GetData.ExecuteInstruction();

                foreach (DataRow r in _GetData.ResultsDataTable.Rows)
                {
                    MWDataManager.clsDataAccess _SendMail = new MWDataManager.clsDataAccess();
                    _SendMail.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _SendMail.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _SendMail.queryReturnType    = MWDataManager.ReturnType.longNumber;
                    _SendMail.SqlStatement       = "sp_MailRequestDataApprovalNew";

                    SqlParameter[] _paramCollection =
                    {
                        _SendMail.CreateParameter("@Prodmonth",   SqlDbType.Int,       0, TProductionGlobal.ProdMonthAsInt(_Prodmonth)),
                        _SendMail.CreateParameter("@SectionID_2", SqlDbType.VarChar,  20, _SectionID_2),
                        _SendMail.CreateParameter("@TemplateID",  SqlDbType.Int,       0, Convert.ToInt32(r["TemplateID"].ToString())),
                        _SendMail.CreateParameter("@toUserName",  SqlDbType.VarChar,  20, r["User1"].ToString()),
                        _SendMail.CreateParameter("@theMessage",  SqlDbType.NVarChar,  0, memoMessage.Text),
                    };

                    _SendMail.ParamCollection = _paramCollection;

                    _SendMail.ExecuteInstruction();
                }
            }
            MessageBox.Show("Message(s) was successfully sent.");
            //_SendMail.ExecuteInstruction();
        }
        private void btnShow_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (TProductionGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).EnableUranium == true)
            {
                gridBand2.Visible  = true;
                gridBand10.Visible = true;
                gridBand11.Visible = true;
            }
            else
            {
                gridBand2.Visible  = false;
                gridBand10.Visible = false;
                gridBand11.Visible = false;
            }
            editProdmonth.Text = TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue).ToString();

            try
            {
                if (activity.EditValue.ToString() == "0")
                {
                    editAct.Text = "Stoping";
                }
                if (activity.EditValue.ToString() == "1")
                {
                    editAct.Text = "Development";
                }
                if (activity.EditValue.ToString() == "2")
                {
                    editAct.Text = "Sundry";
                }
                if (activity.EditValue.ToString() == "8")
                {
                    editAct.Text = "Sweeps & Vamps";
                }
                panelControl1.Visible = true;

                editMoSectionID.Text = mineoverseer1.EditValue.ToString();

                gcLockPlan.Visible    = true;
                rpReplanning.Visible  = true;
                rpPreplanning.Visible = false;
                gcLockPlan.DataSource = "";
                dt.Clear();

                if (activity.EditValue.ToString() == "0")
                {
                    gcLockPlan.MainView = Stopping;


                    MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbMan.SqlStatement       = "[sp_AuthLockPlan]";
                    int    prodmonth = TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue);
                    string desc      = mineoverseer1.EditValue.ToString();
                    int    activ     = Convert.ToInt32(activity.EditValue);

                    SqlParameter[] _paramCollection =
                    {
                        _dbMan.CreateParameter("@prodmonth",   SqlDbType.Int,       0, TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue)),
                        _dbMan.CreateParameter("@description", SqlDbType.VarChar, 100, mineoverseer1.EditValue.ToString()),
                        _dbMan.CreateParameter("@activity",    SqlDbType.Int,       0, Convert.ToInt32(activity.EditValue)),
                    };

                    _dbMan.ParamCollection = _paramCollection;
                    _dbMan.ExecuteInstruction();

                    dt = _dbMan.ResultsDataTable;

                    gcLockPlan.DataSource = dt;
                }
                else if (activity.EditValue.ToString() == "1")
                {
                    gcLockPlan.MainView = Development;

                    MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;

                    _dbMan.SqlStatement    = "sp_AuthLockPlan";
                    _dbMan.queryReturnType = MWDataManager.ReturnType.DataTable;
                    int    prodmonth = TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue);
                    string desc      = mineoverseer1.EditValue.ToString();
                    int    activ     = Convert.ToInt32(activity.EditValue);

                    SqlParameter[] _paramCollection =
                    {
                        _dbMan.CreateParameter("@prodmonth",   SqlDbType.Int,       0, TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue)),
                        _dbMan.CreateParameter("@description", SqlDbType.VarChar, 100, mineoverseer1.EditValue.ToString()),
                        _dbMan.CreateParameter("@activity",    SqlDbType.Int,       0, Convert.ToInt32(activity.EditValue)),
                    };

                    _dbMan.ParamCollection = _paramCollection;
                    _dbMan.ExecuteInstruction();
                    dt = _dbMan.ResultsDataTable;
                    gcLockPlan.DataSource = dt;
                }
                else if (activity.EditValue.ToString() == "2")
                {
                    gcLockPlan.MainView = Sundry;

                    MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbMan.SqlStatement       = "[sp_AuthLockPlan]";
                    int    prodmonth = TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue);
                    string desc      = mineoverseer1.EditValue.ToString();
                    int    activ     = Convert.ToInt32(activity.EditValue);

                    SqlParameter[] _paramCollection =
                    {
                        _dbMan.CreateParameter("@prodmonth",   SqlDbType.Int,       0, TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue)),
                        _dbMan.CreateParameter("@description", SqlDbType.VarChar, 100, mineoverseer1.EditValue.ToString()),
                        _dbMan.CreateParameter("@activity",    SqlDbType.Int,       0, Convert.ToInt32(activity.EditValue)),
                    };

                    _dbMan.ParamCollection = _paramCollection;
                    _dbMan.ExecuteInstruction();
                    dt = _dbMan.ResultsDataTable;
                    gcLockPlan.DataSource = dt;
                }
                else if (activity.EditValue.ToString() == "8")
                {
                    gcLockPlan.MainView = SweepsVamps;

                    MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbMan.SqlStatement       = "[sp_AuthLockPlan]";
                    int    prodmonth = TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue);
                    string desc      = mineoverseer1.EditValue.ToString();
                    int    activ     = Convert.ToInt32(activity.EditValue);

                    SqlParameter[] _paramCollection =
                    {
                        _dbMan.CreateParameter("@prodmonth",   SqlDbType.Int,       0, TProductionGlobal.ProdMonthAsInt((DateTime)productionmonth1.EditValue)),
                        _dbMan.CreateParameter("@description", SqlDbType.VarChar, 100, mineoverseer1.EditValue.ToString()),
                        _dbMan.CreateParameter("@activity",    SqlDbType.Int,       0, Convert.ToInt32(activity.EditValue)),
                    };

                    _dbMan.ParamCollection = _paramCollection;
                    _dbMan.ExecuteInstruction();
                    dt = _dbMan.ResultsDataTable;
                    gcLockPlan.DataSource = dt;
                }
            }
            catch (Exception)
            {
                Mineware.Systems.Global.sysNotification.TsysNotification.showNotification("Error", "Invalid Selection", Color.Red);
            }
        }