private void mwProdmonthEdit1_EditValueChanged(object sender, EventArgs e)
 {
     if (editActivity.EditValue != null)
     {
         updateSections(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(mwProdmonthEdit1.EditValue)), editActivity.EditValue.ToString());
     }
 }
示例#2
0
        void LoadPlanningLockData()
        {
            DataTable dtPlanningLockData = _clsLockMonthData.GetPlanningLockData(
                TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(luePlanningProdMonth.EditValue.ToString())));

            gcPlanningLock.DataSource = dtPlanningLockData;
        }
        void LoadPlanningScreenData()
        {
            rpgSelection.Enabled = true;
            rpgShow.Enabled      = true;
            rpgSave.Enabled      = false;

            _clsTrammingPlanningData.theData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            DataTable dtProdMonth = _clsTrammingPlanningData.GetProdMonth();

            foreach (DataRow r in dtProdMonth.Rows)
            {
                prodMonth = r["Prodmonth"].ToString();
                luePlanningProdMonth.EditValue = TProductionGlobal.ProdMonthAsDate(prodMonth.ToString());;
            }

            DataTable dtSections = _clsTrammingPlanningData.GetSections(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(luePlanningProdMonth.EditValue.ToString())));

            rPlanningSections.DataSource    = dtSections;
            rPlanningSections.ValueMember   = "SectionID";
            rPlanningSections.DisplayMember = "Name";

            gvTrammingPlanning.PostEditor();

            LookUpColumnInfoCollection collXC = LookupXC.Columns;

            collXC.Add(new LookUpColumnInfo("XC", 0));

            LookUpColumnInfoCollection coll = LookupBoxHole.Columns;

            coll.Add(new LookUpColumnInfo("BH", 0));
        }
示例#4
0
        void LoadScreenData()
        {
            gcStoping.Visible     = false;
            gcDevelopment.Visible = false;
            rpgSelection.Enabled  = true;
            rpgShow.Enabled       = true;
            rpgSave.Enabled       = false;

            _clsBonusCaptureData.theData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            DataTable dtProdMonth = _clsBonusCaptureData.GetProdMonth();

            foreach (DataRow r in dtProdMonth.Rows)
            {
                ProdMonth = r["MillMonth"].ToString();
                lueProdMonth.EditValue = TProductionGlobal.ProdMonthAsDate(ProdMonth.ToString());;
            }

            DataTable dtActivity = _clsBonusCaptureData.GetActivity();

            rActivity.DataSource    = dtActivity;
            rActivity.ValueMember   = "Activity";
            rActivity.DisplayMember = "Description";

            DataTable dtSections = _clsBonusCaptureData.GetSections(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueProdMonth.EditValue.ToString())));

            rSection.DataSource    = dtSections;
            rSection.ValueMember   = "SectionID";
            rSection.DisplayMember = "Name";
        }
        private void LoadSections()
        {
            DataTable          _SectionResult = new DataTable();
            GetSectionsAndName theData        = new GetSectionsAndName {
                theSystemDBTag = this.theSystemDBTag, UserCurrentInfo = this.UserCurrentInfo
            };

            List <string> sections = TProductionGlobal.getUserInfo(UserCurrentInfo.Connection).PlanBookSections;

            foreach (string item in sections)
            {
                MWDataManager.clsDataAccess temp = theData.theSectionsAndName(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(barProdMonth.EditValue.ToString())), item, TProductionGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).MOHierarchicalID);
                temp.ExecuteInstruction();
                if (temp.ResultsDataTable.Rows.Count != 0)
                {
                    if (_SectionResult.Columns.Count == 0)
                    {
                        _SectionResult = temp.ResultsDataTable.Clone();
                    }
                    _SectionResult.Merge(temp.ResultsDataTable);
                }
            }

            editListSections.DataSource    = _SectionResult;
            editListSections.ValueMember   = "SectionID";
            editListSections.DisplayMember = "Name";
        }
        private void ParamLbl_TextChanged(object sender, EventArgs e)
        {
            if (ParamLbl.Text == ParamLbl1.Text)
            {
                //MessageBox.Show("Please enter the Problem Id", "Insufficient information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                ParamLbl1.Text = ParamLbl.Text;

                if (ParamLbl.Text != "")
                {
                    measure.MLPMLbl.Text  = TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth);
                    measure.MLACTLbl.Text = ParamLbl.Text.Substring(0, 1);
                    measure.MLWPLbl.Text  = procs.ExtractAfterColon(ParamLbl.Text + "                                  ".Substring(2, 30)).Trim();
                    measure.MLSecLbl.Text = procs.ExtractBeforeColon(ParamLbl.Text).Trim();
                    measure.MLSecLbl.Text = measure.MLSecLbl.Text + "                  ";
                    measure.MLSecLbl.Text = measure.MLSecLbl.Text.Substring(1, 10);
                    measure.MLSecLbl.Text = measure.MLSecLbl.Text.Trim();
                    measure.Connection    = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    measure.ShowDialog();

                    //MsgFrm.Text = "Record Inserted";
                    //Procedures.MsgText = "Problem Group Added";
                    //MsgFrm.Show();

                    //   showBtn_Click(null, null);
                }
            }
        }
        private DataTable loadIndicatestatus()
        {
            MWDataManager.clsDataAccess _DataStatus = new MWDataManager.clsDataAccess();
            _DataStatus.ConnectionString = TConnections.GetConnectionString(systemDBTag, UserCurrentInfo.Connection);
            _DataStatus.SqlStatement     = "SELECT 'L' theStatus, COUNT(Plancode) TheCount FROM PLANMONTH a inner join Section_complete b on \n" +
                                           "a.prodmonth = b.Prodmonth and \n" +
                                           "a.Sectionid = b.SectionID \n" +
                                           "WHERE SectionID_2 = '" + SECTIONID_2 + "' and \n" +
                                           "a.Prodmonth = " + TProductionGlobal.ProdMonthAsString(Prodmonth) + "  and \n" +
                                           "Activity = " + Code + " and \n" +
                                           "Plancode = 'MP' AND LOCKED=1\n" +
                                           "UNION \n" +
                                           "SELECT 'D' theStatus,COUNT(Plancode) TheCount FROM PLANMONTH a inner join Section_complete b on \n" +
                                           "a.prodmonth = b.Prodmonth and \n" +
                                           "a.Sectionid = b.SectionID\n" +
                                           "WHERE SectionID_2 = '" + SECTIONID_2 + "' and \n" +
                                           "a.Prodmonth = " + TProductionGlobal.ProdMonthAsString(Prodmonth) + " and \n" +
                                           "Activity = " + Code + " and \n" +
                                           "Plancode='MP' AND LOCKED=0";
            _DataStatus.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _DataStatus.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _DataStatus.ExecuteInstruction();

            return(_DataStatus.ResultsDataTable);
        }
        private void frmResavePlanningProtocol_Load(object sender, EventArgs e)
        {
            //string ThePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
            //string path = string.Format(@"{0}\{1}_{2}.txt", ThePath, r["Prodmonth"], r["WorkPlaceID"]);

            //MessageBox.Show(ThePath);

            mwProdmonthEdit1.EditValue = TProductionGlobal.ProdMonthAsDate(TProductionGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).CurrentProductionMonth.ToString());

            CPMBusinessLayer.clsBusinessLayer BMEBL = new CPMBusinessLayer.clsBusinessLayer();
            BMEBL._queryReturnType = CPMBusinessLayer.ReturnType.DataTable;

            BMEBL.SetsystemDBTag     = this.theSystemDBTag;
            BMEBL.SetUserCurrentInfo = this.UserCurrentInfo;
            if (BMEBL.get_Activity() == true)
            {
                //  this.tscbShaft.Items.Add("MINE");
                editActivity.Properties.DataSource    = BMEBL.ResultsDataTable;
                editActivity.Properties.DisplayMember = "Desc";
                editActivity.Properties.ValueMember   = "Code";
                editActivity.ItemIndex = 0;
            }

            updateSections(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(mwProdmonthEdit1.EditValue)), editActivity.EditValue.ToString());
            DataStructure();
        }
示例#9
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _clsMillingBookingData.SavePlannedData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueMillMonth.EditValue.ToString())),
                                                   lueMill.EditValue.ToString(),
                                                   Convert.ToInt32(txtTonsTreated.EditValue),
                                                   Convert.ToInt32(txtTonsToPlant.EditValue));

            LoadMillingData();
        }
示例#10
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _clsHoistingBookingData.SaveData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueMillMonth.EditValue.ToString())),
                                             lueShaft.EditValue.ToString(),
                                             Convert.ToInt32(txtPlanHoistTons.EditValue),
                                             Convert.ToDecimal(txtPlanBeltGrade.EditValue),
                                             Convert.ToInt32(txtPlanGold.EditValue));

            LoadHoistingData();
        }
        void LoadTopPanels()
        {
            gcTopPanels.Visible = true;

            _clsTopPanelsData.theData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            DataTable dtTopPanels = _clsTopPanelsData.GetTopPanelsData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueProdMonth.EditValue.ToString())),
                                                                       lueSectionID.EditValue.ToString());

            gcTopPanels.DataSource = dtTopPanels;
        }
        private void btnBookingSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            _clsTrammingBookingData.SaveTrammingBooking(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueBookingProdMonth.EditValue.ToString())), cbBookingSections.EditValue.ToString(), Convert.ToDateTime(dteDate.EditValue.ToString()), dtTrammingBookingData);

            dtTrammingBookingData = _clsTrammingBookingData.GetTrammingBookingData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueBookingProdMonth.EditValue.ToString())), cbBookingSections.EditValue.ToString(), Convert.ToDateTime(dteDate.EditValue.ToString()));
            gcBookings.DataSource = dtTrammingBookingData;

            rpgSelection.Enabled = false;
            rpgShow.Enabled      = false;
            rpgSave.Enabled      = true;
        }
        private void ucRevisedPlanningAuditReport_Load(object sender, EventArgs e)
        {
            CPMBusinessLayer.clsBusinessLayer BMEBL = new CPMBusinessLayer.clsBusinessLayer();
            BMEBL._queryReturnType       = CPMBusinessLayer.ReturnType.DataTable;
            BMEBL.SetsystemDBTag         = this.theSystemDBTag;
            BMEBL.SetUserCurrentInfo     = this.UserCurrentInfo;
            reportSettings.FromProdmonth = TProductionGlobal.ProdMonthAsDate(TProductionGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).CurrentProductionMonth.ToString());
            reportSettings.ToProdmonth   = TProductionGlobal.ProdMonthAsDate(TProductionGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).CurrentProductionMonth.ToString());

            DataTable section = new DataTable();

            if (BMEBL.GetPlanSectionsAndNameADO(TProductionGlobal.ProdMonthAsString(reportSettings.FromProdmonth)) == true)
            {
                section = BMEBL.ResultsDataTable;
                rpSection.DataSource    = BMEBL.ResultsDataTable;
                rpSection.DisplayMember = "NAME";
                rpSection.ValueMember   = "sectionid";
            }
            reportSettings.sectionid           = section.Rows[0]["sectionid"].ToString();
            reportSettings.RevisedPlanningType = "All";

            MWDataManager.clsDataAccess _RevisedOptions = new MWDataManager.clsDataAccess();

            _RevisedOptions.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _RevisedOptions.SqlStatement     = "SELECT 0 Code, 'All' [RevisedPlanningType] " +
                                               "UNION " +
                                               "SELECT 1 Code, 'Stop Workplace' [RevisedPlanningType] " +
                                               "union " +
                                               "select 2 Code, 'New Workplace' [RevisedPlanningType] " +
                                               "union " +
                                               "select 3 Code, 'Crew Miner Changes' [RevisedPlanningType] " +
                                               "union " +
                                               "select 4 Code, 'Call Changes' [RevisedPlanningType] " +
                                               "union " +
                                               "select 5 Code, 'Move Planning' [RevisedPlanningType] " +
                                               "union " +
                                               "select 6 Code, 'Start Workplace' [RevisedPlanningType] " +
                                               "union " +
                                               "select 7 Code, 'Mining Method Change' [RevisedPlanningType] " +
                                               "union " +
                                               "select 8 Code, 'Drill Rig Change' [RevisedPlanningType] " +
                                               "union " +
                                               "select 9 Code, 'Delete Planning' [RevisedPlanningType] ";

            _RevisedOptions.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;

            _RevisedOptions.queryReturnType = MWDataManager.ReturnType.DataTable;
            _RevisedOptions.ExecuteInstruction();
            rpRevisedPlanningType.DataSource      = _RevisedOptions.ResultsDataTable;
            rpRevisedPlanningType.DisplayMember   = "RevisedPlanningType";
            rpRevisedPlanningType.ValueMember     = "RevisedPlanningType";
            pgRevisedPlanningAudit.SelectedObject = reportSettings;
        }
        private void gvTopPanels_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            var workplaceID = gvTopPanels.GetRowCellValue(gvTopPanels.FocusedRowHandle, gvTopPanels.Columns["WPID"]).ToString();

            var activity = gvTopPanels.GetRowCellValue(gvTopPanels.FocusedRowHandle, gvTopPanels.Columns["Activity"]).ToString();

            var selected = gvTopPanels.GetRowCellValue(gvTopPanels.FocusedRowHandle, gvTopPanels.Columns["Selected"]).ToString();

            _clsTopPanelsData.SaveData(Convert.ToBoolean(selected),
                                       TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueProdMonth.EditValue.ToString())),
                                       lueSectionID.EditValue.ToString(), workplaceID.ToString(), activity.ToString());

            LoadTopPanels();
        }
示例#15
0
        private void gvMillingBooking_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            var calendarDate = gvMillingBooking.GetRowCellValue(gvMillingBooking.FocusedRowHandle, gvMillingBooking.Columns["CalendarDate"]).ToString();

            var treated = gvMillingBooking.GetRowCellValue(gvMillingBooking.FocusedRowHandle, gvMillingBooking.Columns["Treated"]).ToString();

            var toPlant = gvMillingBooking.GetRowCellValue(gvMillingBooking.FocusedRowHandle, gvMillingBooking.Columns["ToPlant"]).ToString();

            _clsMillingBookingData.SaveActualData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueMillMonth.EditValue.ToString())),
                                                  lueMill.EditValue.ToString(), Convert.ToDateTime(calendarDate),
                                                  Convert.ToDecimal(treated),
                                                  Convert.ToDecimal(toPlant));

            LoadMillingData();
        }
示例#16
0
        void LoadStopingData()
        {
            gcStoping.Visible     = true;
            gcDevelopment.Visible = false;
            rpgSelection.Enabled  = false;
            rpgShow.Enabled       = false;
            rpgSave.Enabled       = true;

            try
            {
                dtStopingData        = _clsBonusCaptureData.GetStopingData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueProdMonth.EditValue.ToString())), cmbActivity.EditValue.ToString(), cmbSection.EditValue.ToString());
                gcStoping.DataSource = dtStopingData;
            }
            catch (Exception _exception)
            {
                Mineware.Systems.Global.sysNotification.TsysNotification.showNotification("Error", _exception.Message, Color.Red);;
            }
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            Thread theReportThread;

            //Thread.CurrentThread.SetApartmentState(ApartmentState.STA);
            theReportThread = new Thread(new ParameterizedThreadStart(resavePP));
            theReportThread.SetApartmentState(ApartmentState.STA);
            theProgressData.Rows.Add(lcSections.SelectedValue.ToString(), TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(mwProdmonthEdit1.EditValue)), editActivity.EditValue.ToString(), 0);
            DataTable theData = _WorkplaceList.ResultsDataTable.Clone();

            for (int i = 0; i <= _WorkplaceList.ResultsDataTable.Rows.Count - 1; ++i)
            {
                theData.ImportRow(_WorkplaceList.ResultsDataTable.Rows[i]);
            }
            theData.TableName = Convert.ToString(theProgressData.Rows.Count - 1);

            theReportThread.Start(theData);
        }
示例#18
0
        private void gvHoistingBooking_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            var calendarDate = gvHoistingBooking.GetRowCellValue(gvHoistingBooking.FocusedRowHandle, gvHoistingBooking.Columns["CalendarDate"]).ToString();

            var reefTons = gvHoistingBooking.GetRowCellValue(gvHoistingBooking.FocusedRowHandle, gvHoistingBooking.Columns["ReefTons"]).ToString();

            var wasteTons = gvHoistingBooking.GetRowCellValue(gvHoistingBooking.FocusedRowHandle, gvHoistingBooking.Columns["WasteTons"]).ToString();

            var beltGrade = gvHoistingBooking.GetRowCellValue(gvHoistingBooking.FocusedRowHandle, gvHoistingBooking.Columns["BeltGrade"]).ToString();

            _clsHoistingBookingData.SaveActualData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueMillMonth.EditValue.ToString())),
                                                   lueShaft.EditValue.ToString(), Convert.ToDateTime(calendarDate),
                                                   Convert.ToInt32(reefTons),
                                                   Convert.ToDecimal(wasteTons),
                                                   Convert.ToDecimal(beltGrade));

            LoadHoistingData();
        }
示例#19
0
        void LoadMillingData()
        {
            gcMillingBooking.Visible = true;
            rpgSelection.Enabled     = false;
            rpgInputs.Enabled        = true;
            rpgShow.Enabled          = false;
            rpgSave.Enabled          = true;

            try
            {
                DataTable dtPlanMillingData = _clsMillingBookingData.GetMillingPlanningData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueMillMonth.EditValue.ToString())), lueMill.EditValue.ToString());

                if (dtPlanMillingData.Rows.Count == 0)
                {
                    txtTonsTreated.EditValue = "0";
                    txtTonsToPlant.EditValue = "0";
                }

                else if (dtPlanMillingData.Rows.Count != 0)
                {
                    _tonsTreated = Convert.ToInt32(dtPlanMillingData.Rows[0]["TonsTreated"]);
                    _tonsToPlant = Convert.ToInt32(dtPlanMillingData.Rows[0]["TonsToPlant"]);

                    txtTonsTreated.EditValue = _tonsTreated.ToString();
                    txtTonsToPlant.EditValue = _tonsToPlant.ToString();
                }

                _clsMillingBookingData.theData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                dtMillingCapture = _clsMillingBookingData.GetMillingData(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueMillMonth.EditValue.ToString())), lueMill.EditValue.ToString());

                if (dtMillingCapture.Rows.Count != 0)
                {
                    gcMillingBooking.DataSource = dtMillingCapture;
                }
                else
                {
                    Mineware.Systems.Global.sysNotification.TsysNotification.showNotification("Error", "Cannot Load Grid", Color.Red);
                }
            }
            catch (Exception _exception)
            {
                Mineware.Systems.Global.sysNotification.TsysNotification.showNotification("Error", _exception.Message, Color.Red);;
            }
        }
示例#20
0
        public void LoadSections()
        {
            CPMBusinessLayer.clsBusinessLayer BMEBL = new CPMBusinessLayer.clsBusinessLayer();
            BMEBL._queryReturnType = CPMBusinessLayer.ReturnType.DataTable;

            BMEBL.SetsystemDBTag     = this.theSystemDBTag;
            BMEBL.SetUserCurrentInfo = this.UserCurrentInfo;

            DataTable dtSectionData = new DataTable();

            if (BMEBL.GetPlanSectionsAndNameADO(TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth)) == true)
            {
                dtSectionData           = BMEBL.ResultsDataTable;
                riSection.DataSource    = BMEBL.ResultsDataTable;
                riSection.DisplayMember = "NAME";
                riSection.ValueMember   = "sectionid";
            }
            reportSettings.NAME = dtSectionData.Rows[0]["sectionid"].ToString();
        }
        private void btnLockData_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ucPlanProtDataView.saveData();
            ucUnapproveWPList = new ucUnapproveWorkplaceList {
                theSystemDBTag = this.theSystemDBTag, UserCurrentInfo = this.UserCurrentInfo
            };
            ucUnapproveWPList.loadTemplateData(Convert.ToInt32(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(barProdMonth.EditValue.ToString()))),
                                               barSetion.EditValue.ToString(),
                                               Convert.ToInt32(barTemplate.EditValue.ToString()),

                                               Convert.ToInt32(barActitivity.EditValue.ToString())
                                               );
            if (ucUnapproveWPList.abc.Rows.Count == 0)
            {
                ucPlanProtDataView.DoApproveData("APPROVE");
            }
            else
            {
            }
        }
示例#22
0
        private void btnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (cmbActivity.EditValue.ToString() == "0")
            {
                _clsBonusCaptureData.SaveStopingData(dtStopingData,
                                                     TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueProdMonth.EditValue.ToString())),
                                                     cmbActivity.EditValue.ToString(),
                                                     cmbSection.EditValue.ToString());
                LoadStopingData();
            }

            else if (cmbActivity.EditValue.ToString() == "1")
            {
                _clsBonusCaptureData.SaveDevelopmentData(dtDevelopmentData,
                                                         TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueProdMonth.EditValue.ToString())),
                                                         cmbActivity.EditValue.ToString(),
                                                         cmbSection.EditValue.ToString());
                LoadDevelopmentData();
            }
        }
        public void LoadSections()
        {
            procs.systemDBTag = theSystemDBTag;
            procs.connection  = UserCurrentInfo.Connection;

            if (clsUserInfo.Hier == 1)
            {
                dtSections = procs.GetSections(TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth), "4", "");
            }
            else
            {
                string Sec = clsUserInfo.UserBookSection + "              ".Substring(0, 3).Trim();

                dtSections = procs.GetSections(TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth), "4", Sec.ToString());
            }
            if (dtSections.Rows.Count != 0)
            {
                riSection.DataSource    = dtSections;
                riSection.DisplayMember = "Name";
                riSection.ValueMember   = "SectionID";
            }
        }
        private void LoadSections()
        {
            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
            //_dbMan.ConnectionString = ConfigurationManager.AppSettings["SQLConnectionStr"];
            _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _dbMan.SqlStatement     = " Select SectionID+':'+Name SectionID " +
                                      "from Section s where s.Prodmonth =  '" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "' ";

            _dbMan.SqlStatement += " and Hierarchicalid  = 4 ";
            _dbMan.SqlStatement += " order by SectionID   ";

            _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbMan.ExecuteInstruction();

            dtSections              = _dbMan.ResultsDataTable;
            riSection.DataSource    = dtSections;
            riSection.DisplayMember = "SectionID";
            riSection.ValueMember   = "SectionID";



            MWDataManager.clsDataAccess _dbManCrew = new MWDataManager.clsDataAccess();
            //_dbMan.ConnectionString = ConfigurationManager.AppSettings["SQLConnectionStr"];
            _dbManCrew.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _dbManCrew.SqlStatement     = " Select Distinct(OrgUnitDay) Crew From PLanmonth where prodmonth = '" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "' " +
                                          "  ";


            _dbManCrew.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbManCrew.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbManCrew.ExecuteInstruction();

            dtCrew = _dbManCrew.ResultsDataTable;
            riCrewLookUpEdit.DataSource    = dtCrew;
            riCrewLookUpEdit.DisplayMember = "Crew";
            riCrewLookUpEdit.ValueMember   = "Crew";
        }
        void LoadScreenData()
        {
            gcTopPanels.Visible  = false;
            rpgSelection.Enabled = true;
            rpgShow.Enabled      = true;
            rpgSave.Enabled      = false;

            _clsTopPanelsData.theData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            DataTable dtProdMonth = _clsTopPanelsData.GetProdMonth();

            foreach (DataRow r in dtProdMonth.Rows)
            {
                ProdMonth = r["Prodmonth"].ToString();
                lueProdMonth.EditValue = TProductionGlobal.ProdMonthAsDate(ProdMonth.ToString());
            }

            DataTable dtSection = _clsTopPanelsData.GetSection(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueProdMonth.EditValue.ToString())));

            rpSectionID.DataSource    = dtSection;
            rpSectionID.ValueMember   = "SectionID";
            rpSectionID.DisplayMember = "Name";
        }
        void LoadBookingScreenData()
        {
            rpgSelection.Enabled = true;
            rpgShow.Enabled      = true;
            rpgSave.Enabled      = false;
            gcBookings.Visible   = false;

            _clsTrammingBookingData.theData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            DataTable dtProdMonth = _clsTrammingBookingData.GetProdMonth();

            foreach (DataRow r in dtProdMonth.Rows)
            {
                prodMonth = r["Prodmonth"].ToString();
                lueBookingProdMonth.EditValue = TProductionGlobal.ProdMonthAsDate(prodMonth.ToString());;
            }

            DataTable dtSections = _clsTrammingBookingData.GetSections(TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(lueBookingProdMonth.EditValue.ToString())));

            rpBookingSections.DataSource    = dtSections;
            rpBookingSections.ValueMember   = "SectionID";
            rpBookingSections.DisplayMember = "Name";
        }
        private void LoadSections()
        {
            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
            //_dbMan.ConnectionString = ConfigurationManager.AppSettings["SQLConnectionStr"];
            _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _dbMan.SqlStatement     = " Select SectionID, SectionID  +' : ' + Name Name " +
                                      "from Section s where s.Prodmonth = '" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "'";

            _dbMan.SqlStatement += " and Hierarchicalid  = 4 ";
            _dbMan.SqlStatement += " order by SectionID asc  ";

            _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbMan.ExecuteInstruction();
            dtSections                = _dbMan.ResultsDataTable;
            rpSectionID.DataSource    = dtSections;
            rpSectionID.DisplayMember = "Name";
            rpSectionID.ValueMember   = "SectionID";



            // this.gbSectionID.Text = "Section ID";
        }
        private void lcSections_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                _WorkplaceList.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _WorkplaceList.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _WorkplaceList.queryReturnType    = MWDataManager.ReturnType.DataTable;

                StringBuilder sb = new StringBuilder();

                sb.AppendLine("Update AT set[FileName] = Cast(pp.ProdMonth As VarChar(7)) + '_' + Cast(pp.Workplaceid As VarChar(7)) + '.fpx' ");
                sb.AppendLine(" ");
                sb.AppendLine("FROM PLANMONTH PP ");
                sb.AppendLine("LEFT JOIN PLANPROT_APPROVEDTEMPLATE AT ON ");
                sb.AppendLine("PP.Prodmonth = AT.Prodmonth and ");
                sb.AppendLine("PP.[Workplaceid] = AT.[Workplaceid] and ");
                sb.AppendLine("PP.[Activity] = AT.[Activity] ");
                sb.AppendLine("WHERE PP.Prodmonth = " + TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(mwProdmonthEdit1.EditValue)) + " and ");
                sb.AppendLine("	  Locked = 1 and");
                sb.AppendLine("	  pp.PlanCode = 'MP' and [FileName] is null");

                _WorkplaceList.SqlStatement = sb.ToString();
                _WorkplaceList.ExecuteInstruction();

                sb.Clear();
                sb.AppendLine("Insert Into PLANPROT_APPROVEDTEMPLATE ");
                sb.AppendLine("Select pp.Prodmonth, pp.WorkplaceID, pp.Sectionid_2, pp.Activity,  [FileName] = Cast(pp.ProdMonth As VarChar(7)) + '_' + Cast(pp.Workplaceid As VarChar(7)) + '.fpx', GetDate()");
                sb.AppendLine("FROM PLANMONTH PP ");
                sb.AppendLine("LEFT JOIN PLANPROT_APPROVEDTEMPLATE AT ON ");
                sb.AppendLine("PP.Prodmonth = AT.Prodmonth and ");
                sb.AppendLine("PP.[Workplaceid] = AT.[Workplaceid] and ");
                sb.AppendLine("PP.[Activity] = AT.[Activity] ");
                sb.AppendLine("WHERE PP.Prodmonth = " + TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(mwProdmonthEdit1.EditValue)) + " and ");
                sb.AppendLine("	  Locked = 1 and");
                sb.AppendLine("	  pp.PlanCode = 'MP' and [FileName] is null");

                _WorkplaceList.SqlStatement = sb.ToString();
                _WorkplaceList.ExecuteInstruction();

                //sb.Clear();
                //sb.AppendLine("update a set Locked = 1 ");
                //sb.AppendLine("from");
                //sb.AppendLine("planmonth a inner");
                //sb.AppendLine("join");
                //sb.AppendLine("(select Prodmonth,");
                //sb.AppendLine("SectionID,");
                //sb.AppendLine("WorkplaceID,");
                //sb.AppendLine("Activity,");
                //sb.AppendLine("PlanCode,");
                //sb.AppendLine("Count(Prodmonth) Shifts");
                //sb.AppendLine(" from planning");
                //sb.AppendLine(" group by Prodmonth,");
                //sb.AppendLine("SectionID,");
                //sb.AppendLine("WorkplaceID,");
                //sb.AppendLine("Activity,");
                //sb.AppendLine("PlanCode) b on");
                //sb.AppendLine("a.Prodmonth = b.Prodmonth and");
                //sb.AppendLine("a.SectionID = b.SectionID and");
                //sb.AppendLine("a.WorkplaceID = b.WorkplaceID and");
                //sb.AppendLine("a.Activity = b.Activity and");
                //sb.AppendLine("a.PlanCode = b.PlanCode");
                //sb.AppendLine("where a.Prodmonth = " + TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(mwProdmonthEdit1.EditValue)) + " and");
                //sb.AppendLine("a.Plancode = 'MP'");
                //sb.AppendLine("and b.Shifts >= 20");
                //sb.AppendLine("and a.Locked = 0");

                //_WorkplaceList.SqlStatement = sb.ToString();
                //_WorkplaceList.ExecuteInstruction();

                sb.Clear();

                sb.AppendLine("SELECT * FROM");
                sb.AppendLine("( SELECT PP.Prodmonth,  PP.[Workplaceid],  PP.[Activity], [FileName],dbo.fn_FileExists('" + TProductionGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).PlanProtSaveDir + "\\' + [FileName]) FileExsits ");
                sb.AppendLine("FROM PLANMONTH  PP   ");
                sb.AppendLine("LEFT JOIN PLANPROT_APPROVEDTEMPLATE AT ON   ");
                sb.AppendLine("PP.Prodmonth = AT.Prodmonth and   ");
                sb.AppendLine("PP.[Workplaceid] = AT.[Workplaceid] and   ");
                sb.AppendLine("PP.[Activity] = AT.[Activity]   ");
                sb.AppendLine("WHERE PP.Prodmonth = " + TProductionGlobal.ProdMonthAsString(Convert.ToDateTime(mwProdmonthEdit1.EditValue)) + " and ");
                sb.AppendLine("      PP.sectionID_2 = '" + lcSections.SelectedValue + "' and  ");
                sb.AppendLine("	  PP.[Activity] = " + editActivity.EditValue.ToString() + " and Locked = 1 and");
                sb.AppendLine("	  pp.PlanCode = 'MP' ) data   ");
                sb.AppendLine("WHERE FileExsits = 0 ");
                _WorkplaceList.SqlStatement = sb.ToString();
                _WorkplaceList.ExecuteInstruction();

                gridControl1.DataSource = _WorkplaceList.ResultsDataTable;
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.Message);
            }
        }
        private void createReport(Object theReportSettings)
        {
            string section = "";

            section = procs.ExtractBeforeColon(reportSettings.SectionID);
            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
            if (reportSettings.Prodmonth.ToString() != "")
            {
                //if (lkpActivity.EditValue.ToString() == "0")
                //{
                if (reportSettings.Activity == "Stoping")
                {
                    string act = "0";
                    //gcStoping.Visible = true;
                    //gcDevelopment.Visible = false;
                    // MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _dbMan.SqlStatement     =
                        " select ''status,divisioncode ExeName, 'xxx' Costareaid, W.Workplaceid, w.Description, s.Prodmonth,cs.StopeTypeDesc Type, 'KR' Type2, " +
                        " s.LedgeSqm Lsqm, s.StopeSqm SSQM, s.LedgeSqmOSF LOSF, s.StopeSqmOSF SOSF, s.LedgeSqmOS LOS, s.StopeSqmOS SOS, s.FLTotal Facelength, " +
                        " s.LedgeFL LFL, s.StopeFL FFL, s.FLOSTotal OSFL, s.CleanSqm SQMClean, s.CleanDist DistFromFace, s.CW ChnWidth, s.FW FWWidth, s.HW HWWidth, " +
                        " s.SWSQM StpWidth, s.CrewMorning, s.CrewAfternoon, s.CrewEvening, " +
                        " CleaningCrew,TrammingCrew,HlgeMaintainanceCrew,RiggerCrew,RseCleaningCrew, " +
                        " 'Miner' Hierarchicalname, sc.name, " +
                        //" M2NOTTOBEPAIDFORMINER,MINSPRETARGETSW2,MidmonthIndicator,DISTFROMFACEMIDMONTH,SweepingPenalty,SF1SF2 "+
                        " case when M2NOTTOBEPAIDFORMINER is null then 0 else M2NOTTOBEPAIDFORMINER end M2NOTTOBEPAIDFORMINER, " +
                        "  case when MINSPRETARGETSW2 is null then 0 else MINSPRETARGETSW2 end MINSPRETARGETSW2, " +
                        " case when MidmonthIndicator is null then 0 else  MidmonthIndicator end MidmonthIndicator, " +
                        " case when DISTFROMFACEMIDMONTH is null then 0 else DISTFROMFACEMIDMONTH end DISTFROMFACEMIDMONTH, " +
                        " case when SweepingPenalty is null then 0 else SweepingPenalty end SweepingPenalty, SF1SF2 " +
                        " from survey s inner join workplace w on w.WorkplaceID  = s.workplaceid inner join Code_StopeTypes cs on cs.StopeTypeID = s.SType " +
                        // " inner join SectionComplete sc on s.prodmonth = sc.prodmonth and s.sectionid = sc.sectionid where s.activity = '" + lkpActivity.EditValue.ToString() + "' and s.Prodmonth ='" + ProdMonthTxt.Value.ToString() + "'  and sc.MOID='" + procs.ExtractBeforeColon(SectionsCombo.Text) + "' ";
                        " inner join Section_Complete sc on s.prodmonth = sc.prodmonth and s.sectionid = sc.sectionid where s.activity = '" + act + "' and s.Prodmonth ='" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "'  and sc.Sectionid_2='" + section + "' ";
                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbMan.ResultsTableName   = "BonusStoping";
                    _dbMan.ExecuteInstruction();
                    if (_dbMan.ResultsDataTable.Rows.Count == 0)
                    {
                        //gcStoping.Visible = false;
                        //gcDevelopment.Visible = false;
                        MessageBox.Show("There is no data to display.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        theReport.Prepare();
                        theReport.Refresh();
                        ActiveReport.SetReport = theReport;
                        ActiveReport.isDone    = true;
                        return;
                    }
                    else
                    {
                        //gcStoping.DataSource = _dbMan.ResultsDataTable;
                    }
                }
                else
                {
                    //gcStoping.Visible = false;
                    //gcDevelopment.Visible = true;
                    //MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();

                    _dbMan.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    string act = "1";
                    _dbMan.SqlStatement =
                        " select ''status,divisioncode ExeName, 'xxx' Costareaid,s.Prodmonth, W.Workplaceid, w.Description, s.TotalMetres Adv_Total, s.MeasWidth, s.MeasHeight," +
                        "   s.CubicsMetres [Extra Units], 'Miner' Hierarchicalname, sc.Name, s.CrewMorning,s.CrewAfternoon,s.CrewEvening, e.Description Description2, s.cw ," +
                        " case when MetersNotToBePaid is NULL then 0 else MetersNotToBePaid end MetersNotToBePaid,CleaningCrew,TrammingCrew,HlgeMaintainanceCrew,RiggerCrew,RseCleaningCrew " +
                        "   from survey s inner join workplace w on w.WorkplaceID  = s.workplaceid " +
                        "    inner join Section_Complete sc on s.prodmonth = sc.prodmonth and s.sectionid = sc.sectionid inner join endtype e on e.EndTypeID = w.EndTypeID " +
                        //"   where  s.activity = '" + lkpActivity.EditValue.ToString() + "' and s.Prodmonth ='" + ProdMonthTxt.Value.ToString() + "' and sc.MOID='" + procs.ExtractBeforeColon(SectionsCombo.Text) + "' ";
                        "   where  s.activity = '" + act + "' and s.Prodmonth ='" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "' and sc.Sectionid_2='" + section + "' ";
                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _dbMan.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbMan.ResultsTableName   = "BonusDevelopment";
                    _dbMan.ExecuteInstruction();
                    if (_dbMan.ResultsDataTable.Rows.Count == 0)
                    {
                        //gcStoping.Visible = false;
                        //gcDevelopment.Visible = false;
                        MessageBox.Show("There is no data to display.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        theReport.Prepare();
                        theReport.Refresh();
                        ActiveReport.SetReport = theReport;
                        ActiveReport.isDone    = true;
                        return;
                    }
                    else
                    {
                        //gcDevelopment.DataSource = _dbMan.ResultsDataTable;
                    }
                }
                DataSet Bonusdataset = new DataSet();
                Bonusdataset.Tables.Add(_dbMan.ResultsDataTable);
                theReport.RegisterData(Bonusdataset);
                theReport.Load(TGlobalItems.ReportsFolder + "\\BonusReport.frx");
                string activity = "";
                //if(lkpActivity .EditValue .ToString ()=="0")
                if (reportSettings.Activity == "Stoping")
                {
                    activity = "Stoping";
                }
                else
                {
                    activity = "Development";
                }
                theReport.SetParameterValue("Activity", activity);
                theReport.SetParameterValue("Prodmonth", TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth));
                theReport.SetParameterValue("Section", reportSettings.SectionID);
                theReport.SetParameterValue("Banner", SysSettings.Banner);
                theReport.Prepare();
                theReport.Refresh();
                ActiveReport.SetReport = theReport;
                ActiveReport.isDone    = true;
                //}
            }
        }
        private void createReport(Object theReportSettings)
        {
            string Section = procs.ExtractBeforeColon(reportSettings.SectionID);
            string month   = TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth);


            MWDataManager.clsDataAccess _dbManLosses = new MWDataManager.clsDataAccess();
            _dbManLosses.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            if (reportSettings.Activity == "Stoping")
            {
                //_dbManLosses.ConnectionString = ConfigurationManager.AppSettings["SQLConnectionStr"];
                _dbManLosses.SqlStatement  = " select a.*, b.CrewName OrgUnitDS from ( SELECT a.*, b.tick1, b.tick2, b.tick3, b.tick4, b.tick5, b.tick6  from \r\n";
                _dbManLosses.SqlStatement += "(SELECT s2.sectionid MO, s2.name MOName, ss.Banner, \r\n";
                _dbManLosses.SqlStatement += "CONVERT(varchar,CONVERT(int,p.activity))+s.sectionid +':' +p.workplaceid aa, s1.sectionid SBID, s1.name SBName , s.sectionid MINID, \r\n";
                _dbManLosses.SqlStatement += "s.name MINName,  p.Workplaceid, w.Description,p.OrgUnitDay OrgUnitNo, p.Sqm CallSQM, s3.SqmTotal MeasSQM, CAST(p.Activity AS INT) as Activity, (case when p.Activity =0 then 'Stope'  when p.Activity =1 then 'Devlop' end) as ActivityDescription\r\n";
                _dbManLosses.SqlStatement += "from  section s, section s1, section s2, workplace w, planmonth p left outer join SURVEY s3 on \r\n";
                _dbManLosses.SqlStatement += " s3.Activity = p.Activity \r\n";
                _dbManLosses.SqlStatement += "AND s3.ProdMonth = p.Prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND s3.SectionID = p.Sectionid \r\n";
                _dbManLosses.SqlStatement += "AND s3.WorkplaceID = p.Workplaceid,SYSSET ss \r\n";
                _dbManLosses.SqlStatement += "WHERE  p.workplaceid = w.workplaceid \r\n";
                _dbManLosses.SqlStatement += "AND p.prodmonth = s.prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND p.sectionid = s.sectionid \r\n";
                _dbManLosses.SqlStatement += "AND s.prodmonth = s1.prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND s.reporttosectionid = s1.sectionid \r\n";
                _dbManLosses.SqlStatement += "AND s1.prodmonth = s2.prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND s1.reporttosectionid = s2.sectionid \r\n";
                _dbManLosses.SqlStatement += "AND p.activity IN (0,9) \r\n";

                _dbManLosses.SqlStatement += "AND p.prodmonth = '" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "'  \r\n";
                _dbManLosses.SqlStatement += "AND s2.sectionid = '" + reportSettings.SectionID + "' and p.plancode='MP') a \r\n";
                _dbManLosses.SqlStatement += "left outer join (SELECT * FROM MOMeas_Stope WHERE prodmonth = '" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "') b on a.minid = b.sectionid and a.workplaceid = b.workplaceid and a.activity = b.activity \r\n";

                _dbManLosses.SqlStatement += " )a left outer join (select Distinct CrewName, Gangno from crew)b on a.OrgUnitNo = b.Gangno  \r\n";



                _dbManLosses.SqlStatement      += "ORDER BY a.sbid, a.minid, a.OrgUnitNo \r\n";
                _dbManLosses.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbManLosses.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _dbManLosses.ResultsTableName   = "MeasureList"; //get table name
                _dbManLosses.ExecuteInstruction();
            }
            else
            {
                //_dbManLosses.ConnectionString = ConfigurationManager.AppSettings["SQLConnectionStr"];
                _dbManLosses.SqlStatement  = " select a.*, b.CrewName OrgUnitDS from (SELECT a.*, b.tick1, b.tick2, b.tick3, b.tick4, b.tick5, b.tick6  from \r\n";
                _dbManLosses.SqlStatement += "(SELECT s2.sectionid MO, s2.name MOName, ss.Banner, \r\n";
                _dbManLosses.SqlStatement += "CONVERT(varchar,CONVERT(int,p.activity))+s.sectionid +':' +p.workplaceid aa, s1.sectionid SBID, s1.name SBName , s.sectionid MINID, \r\n";
                _dbManLosses.SqlStatement += "s.name MINName,  p.Workplaceid, w.Description,p.OrgUnitDay OrgUnitNo,p.Metresadvance CallAdv,s3.MainMetres    MeasAdv , p.Sqm CallSQM, s3.SqmTotal MeasSQM, CAST(p.Activity AS INT) as Activity, (case when p.Activity =0 then 'Stope'  when p.Activity =1 then 'Devlop' end) as ActivityDescription\r\n";
                _dbManLosses.SqlStatement += "from  section s, section s1, section s2, workplace w, planmonth p left outer join SURVEY s3 on \r\n";
                _dbManLosses.SqlStatement += " s3.Activity = p.Activity \r\n";
                _dbManLosses.SqlStatement += "AND s3.ProdMonth = p.Prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND s3.SectionID = p.Sectionid \r\n";
                _dbManLosses.SqlStatement += "AND s3.WorkplaceID = p.Workplaceid,sysset ss \r\n";
                _dbManLosses.SqlStatement += "WHERE  p.workplaceid = w.workplaceid \r\n";
                _dbManLosses.SqlStatement += "AND p.prodmonth = s.prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND p.sectionid = s.sectionid \r\n";
                _dbManLosses.SqlStatement += "AND s.prodmonth = s1.prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND s.reporttosectionid = s1.sectionid \r\n";
                _dbManLosses.SqlStatement += "AND s1.prodmonth = s2.prodmonth \r\n";
                _dbManLosses.SqlStatement += "AND s1.reporttosectionid = s2.sectionid \r\n";
                _dbManLosses.SqlStatement += "AND p.activity IN (1) \r\n";

                _dbManLosses.SqlStatement      += "AND p.prodmonth = '" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "'  \r\n";
                _dbManLosses.SqlStatement      += "AND s2.sectionid = '" + reportSettings.SectionID + "' and p.plancode='MP') a \r\n";
                _dbManLosses.SqlStatement      += "left outer join (SELECT * FROM MOMeas_Stope WHERE prodmonth = '" + TProductionGlobal.ProdMonthAsString(reportSettings.Prodmonth) + "') b on a.minid = b.sectionid and a.workplaceid = b.workplaceid and a.activity = b.activity \r\n";
                _dbManLosses.SqlStatement      += " )a left outer join (select Distinct CrewName, Gangno from crew)b on a.OrgUnitNo = b.Gangno  \r\n";
                _dbManLosses.SqlStatement      += "ORDER BY a.sbid, a.minid, a.OrgUnitNo \r\n";
                _dbManLosses.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbManLosses.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _dbManLosses.ResultsTableName   = "MeasureList"; //get table name
                _dbManLosses.ExecuteInstruction();
            }
            DataSet ReportDatasetLosses = new DataSet();

            ReportDatasetLosses.Tables.Add(_dbManLosses.ResultsDataTable);
            theReport.RegisterData(ReportDatasetLosses);

            theReport.SetParameterValue("Bob", "None");
            theReport.SetParameterValue("Bob2", "None");
            theReport.SetParameterValue("Bob3", "None");
            theReport.Clear();
            // theReport.Load("MeasuringListRep.frx");
            if (reportSettings.Activity == "Stoping")
            {
                theReport.Load(TGlobalItems.ReportsFolder + "\\MeasuringListRep.frx");
                theReport.SetParameterValue("month", month.ToString());
                //  theReport.Design();
            }
            else
            {
                theReport.Load(TGlobalItems.ReportsFolder + "\\MeasuringListRepDev.frx");
                theReport.SetParameterValue("month", month.ToString());
                // theReport.Design();
            }

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

            // theReport.Design();
            theReport.Prepare();
            theReport.Refresh();
            ActiveReport.SetReport = theReport;
            ActiveReport.isDone    = true;
            // FastReport.Preview.PreviewControl pcReport = new FastReport.Preview.PreviewControl();
            //  theReport.Preview = pcReport;
            // theReport.ShowPrepared();
            //   ActiveReport.SetReport = pcReport;
            //   ActiveReport.isDone = true;
            // pcReport.Click += PcReport_Click;
            //  (theReport.FindObject("Data1") as DataBand).Click += UcMeasuringListReport_Click;
            (theReport.FindObject("Text7") as TextObject).Click += UcMeasuringListReport_Click;
            (theReport.FindObject("Text8") as TextObject).Click += UcMeasuringListReport_Click;
            (theReport.FindObject("Text3") as TextObject).Click += UcMeasuringListReport_Click;

            //(theReport.FindObject("Text157") as TextObject).Click += UcMeasuringListReport_Click;
            //(theReport.FindObject("Text9") as TextObject).Click += UcMeasuringListReport_Click;
            //(theReport.FindObject("Text158") as TextObject).Click += UcMeasuringListReport_Click;
            //(theReport.FindObject("Text160") as TextObject).Click += UcMeasuringListReport_Click;
        }