private void btnNewOption_Click(object sender, EventArgs e)
        {
            MWDataManager.clsDataAccess _theData = new MWDataManager.clsDataAccess();
            _theData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _theData.SqlStatement       = "sp_HRStdNorm_AddOption";
            _theData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _theData.queryReturnType    = MWDataManager.ReturnType.DataTable;

            SqlParameter[] _paramCollection =
            {
                _theData.CreateParameter("@TargetID", SqlDbType.Int,       0, theTargetID),
                _theData.CreateParameter("@Activity", SqlDbType.VarChar, 150, theActivity),
            };

            _theData.ParamCollection = _paramCollection;

            _theData.ExecuteInstruction();


            saveData();
            switch (theActivity)
            {
            case 0:
                buildStoping();
                break;

            case 1:
                buildDev();
                break;
            }
            LoadData(theTargetID);
        }
        private void createReport(Object theReportSettings)
        {
            string _act = "";

            if (reportSettings.Activity == "Stoping")
            {
                _act = "0";
            }

            else if (reportSettings.Activity == "Development")
            {
                _act = "1";
            }
            MWDataManager.clsDataAccess _plathondWallRoomReportData = new MWDataManager.clsDataAccess();

            _plathondWallRoomReportData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _plathondWallRoomReportData.SqlStatement       = "sp_PlathondWallRoom";
            _plathondWallRoomReportData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _plathondWallRoomReportData.ResultsTableName   = "PlathondWallRoomData";

            SqlParameter[] _DevparamCollection =
            {
                _plathondWallRoomReportData.CreateParameter("@Prodmonth", SqlDbType.VarChar,  6, THarmonyPASGlobal.ProdMonthAsString(reportSettings.Prodmonth)),
                _plathondWallRoomReportData.CreateParameter("@Section",   SqlDbType.VarChar, 50, reportSettings.NAME),
                _plathondWallRoomReportData.CreateParameter("@Activity",  SqlDbType.VarChar,  1, _act),
            };

            _plathondWallRoomReportData.ParamCollection = _DevparamCollection;
            _plathondWallRoomReportData.queryReturnType = MWDataManager.ReturnType.DataTable;
            clsDataResult result = _plathondWallRoomReportData.ExecuteInstruction();

            if (!result.success)
            {
                throw new ApplicationException("Report Section:MODailyStopeData:" + result.Message);
            }

            DataSet repDataSet = new DataSet();


            repDataSet.Tables.Add(_plathondWallRoomReportData.ResultsDataTable);
            theReport.RegisterData(repDataSet);

            theReport.Load(TGlobalItems.ReportsFolder + "\\PlathondWallRoom.frx");

            theReport.SetParameterValue("Banner", THarmonyPASGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).Mine);
            theReport.SetParameterValue("Prodmonth", THarmonyPASGlobal.ProdMonthAsString(reportSettings.Prodmonth));
            theReport.SetParameterValue("SectionName", reportSettings.NAME);
            theReport.SetParameterValue("TheDate", reportSettings.Activity);
            theReport.SetParameterValue("logo", TGlobalItems.ClientLogo);
            theReport.SetParameterValue("logoMineware", TGlobalItems.CompanyLogo);

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

            theReport.Prepare();
            ActiveReport.SetReport = theReport;
            ActiveReport.isDone    = true;
        }
        private void GetPlanningData()
        {
            MWDataManager.clsDataAccess _PrePlanningData = new MWDataManager.clsDataAccess();
            _PrePlanningData.ConnectionString = TConnections.GetConnectionString(systemDBTag,
                                                                                 UserCurrentInfo.Connection);
            _PrePlanningData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _PrePlanningData.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _PrePlanningData.SqlStatement       = "sp_Load_Planning";

            SqlParameter[] _paramCollection =
            {
                _PrePlanningData.CreateParameter("@ProdMonth",
                                                 SqlDbType.Int,
                                                 0,
                                                 Convert.ToInt32(planningSettings.ProdMonth)),
                _PrePlanningData.CreateParameter("@Sectionid_2",
                                                 SqlDbType.VarChar,
                                                 20,
                                                 planningSettings.MOSectionID),
                _PrePlanningData.CreateParameter("@Activity",                                 SqlDbType.Int,0, planningSettings.ActivityID),
            };


            _PrePlanningData.ParamCollection = _paramCollection;
            var result = _PrePlanningData.ExecuteInstruction();

            _PrePlanningData.ResultsDataTable.Columns["OrgUnitNight"].DataType = typeof(string);
            tblPlanningData = _PrePlanningData.ResultsDataTable.Copy();
            _PrePlanningData.Dispose();
            _PrePlanningData = null;
        }
        /// <summary>
        /// Run when importing data from previous month
        /// </summary>
        private void ImportPreviousMonthData()
        {
            MWDataManager.clsDataAccess _PrePlanningData = new MWDataManager.clsDataAccess();
            _PrePlanningData.ConnectionString = TConnections.GetConnectionString(systemDBTag,
                                                                                 UserCurrentInfo.Connection);
            _PrePlanningData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _PrePlanningData.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _PrePlanningData.SqlStatement       = "sp_preplanning_save_previus_month";

            SqlParameter[] _paramCollection =
            {
                _PrePlanningData.CreateParameter("@ProdMonth",
                                                 SqlDbType.Int,
                                                 0,
                                                 Convert.ToInt32(planningSettings.ProdMonth)),
                _PrePlanningData.CreateParameter("@Sectionid_2",
                                                 SqlDbType.VarChar,
                                                 20,
                                                 planningSettings.MOSectionID),
                _PrePlanningData.CreateParameter("@Activity",                                 SqlDbType.Int,0, planningSettings.ActivityID),
            };


            _PrePlanningData.ParamCollection = _paramCollection;
            var result = _PrePlanningData.ExecuteInstruction();
        }
Beispiel #5
0
        public DataTable get_sICDetail(string _prodmonth, string _sectionid, string _workplaceid, string _activity)
        {
            theData.SqlStatement       = "[sp_Report_SIC_Detail]";
            theData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            theData.ResultsTableName   = "SIC_Detail";

            SqlParameter[] _paramCollection =
            {
                theData.CreateParameter("@ProdMonth",   SqlDbType.VarChar,  6, _prodmonth),
                theData.CreateParameter("@SectionID",   SqlDbType.Text,    20, _sectionid),
                theData.CreateParameter("@WorkplaceID", SqlDbType.Text,    12, _workplaceid),
                theData.CreateParameter("@Activity",    SqlDbType.Text,     1, _activity),
            };

            theData.ParamCollection = _paramCollection;
            theData.queryReturnType = MWDataManager.ReturnType.DataTable;
            clsDataResult errorMsg = theData.ExecuteInstruction();

            if (errorMsg.success == false)
            {
                return(theData.ResultsDataTable);
            }
            else
            {
                return(theData.ResultsDataTable);
            }
        }
Beispiel #6
0
        public void Decline(int ApproveRequestID, string ChangeType, string WPName)
        {
            theApproveRequestID = ApproveRequestID;
            Text = "DECLINE";
            labelControl1.Text = ChangeType + ":  " + WPName;
            ShowDialog();
            if (canceledAction == false)
            {
                // theresult = canceledAction;
                MWDataManager.clsDataAccess _SaveData = new MWDataManager.clsDataAccess();
                _SaveData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _SaveData.SqlStatement       = "[sp_RevisedPlanning_ApproveDecline]";
                _SaveData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;

                SqlParameter[] _paramCollection =
                {
                    _SaveData.CreateParameter("@ApproveRequestID", SqlDbType.Int,       0, Convert.ToInt32(theApproveRequestID)),
                    _SaveData.CreateParameter("@RequestStauts",    SqlDbType.Int,       0, Convert.ToInt32(2)),
                    _SaveData.CreateParameter("@UserID",           SqlDbType.VarChar,  50, TUserInfo.UserID),
                    _SaveData.CreateParameter("@Comments",         SqlDbType.VarChar, 255, editComments.Text),
                };

                _SaveData.ParamCollection = _paramCollection;
                _SaveData.queryReturnType = MWDataManager.ReturnType.longNumber;
                _SaveData.ExecuteInstruction();

                //ucRequeststatus ucreq = new ucRequeststatus();
            }
            else
            {
                //theresult = canceledAction;
            }
        }
Beispiel #7
0
        //public void loadRequestList()
        //{


        //}

        public void loadTemplateData(int ProdMonth, string section, int TemplateID, int ActivityType)
        {
            gcRequestList.Refresh();
            gvRequestList.RefreshData();

            // GlobalVar.ActivityType = ActivityType;
            //// GlobalVar.captureOption = captureOption;
            // GlobalVar.ProdMonth = ProdMonth;
            //// GlobalVar.Readonly = Readonly;
            // GlobalVar.section = section;
            // GlobalVar.TemplateID = TemplateID;
            //  GlobalVar.WorkPlaceID = WorkPlaceID;


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

            //_RequestList.ConnectionString = TUserInfo.ConnectionString;
            //_RequestList.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            //_RequestList.queryReturnType = MWDataManager.ReturnType.DataTable;
            //_RequestList.SqlStatement = "spUNAPPROVALWorkplaceLIST '";// + TUserInfo.UserID + "'";
            //_RequestList.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            // _RequestList.ExecuteInstruction();

            SqlParameter[] _paramCollection =
            {
                _RequestList.CreateParameter("@ProdMonth",    SqlDbType.Int,      7, ProdMonth),
                _RequestList.CreateParameter("@SectionID ",   SqlDbType.VarChar, 10, section),
                _RequestList.CreateParameter("@TemplateID",   SqlDbType.Int,      0, TemplateID),

                _RequestList.CreateParameter("@ActivityType", SqlDbType.Int,      0, ActivityType),
                //  _RequestList.CreateParameter("@ActivityType", SqlDbType.VarChar , 50,captureOption),

                // _RequestList.CreateParameter("@WorkplaceID", SqlDbType.Int, 0,WorkPlaceID),
            };

            _RequestList.ParamCollection = _paramCollection;
            _RequestList.queryReturnType = MWDataManager.ReturnType.DataTable;
            _RequestList.ExecuteInstruction();

            if (_RequestList.ResultsDataTable.DefaultView.Count == 0)
            {
                //if(_RequestList .ResultsDataTable .Columns
                Visible = false;
                // ucplantrotdataview.DoApproveData("APPROVE");
            }
            else
            {
                gcRequestList.DataSource = _RequestList.ResultsDataTable;
                abc = _RequestList.ResultsDataTable;
                ShowDialog();
                frmLockUnlockData frmunlc = new frmLockUnlockData();
                frmunlc.Visible = false;
            }
        }
        private void saveData()
        {
            foreach (DataRow r in theMainData.Rows)
            {
                MWDataManager.clsDataAccess _theData = new MWDataManager.clsDataAccess();
                _theData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _theData.SqlStatement       = "sp_HRStdNorm_UpdateData";
                _theData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                _theData.queryReturnType    = MWDataManager.ReturnType.DataTable;

                SqlParameter[] _paramCollection =
                {
                    _theData.CreateParameter("@StdAndNormID",    SqlDbType.Int,     0, r["StdAndNormID"]),
                    _theData.CreateParameter("@NightShift",      SqlDbType.Bit,     0, r["NightShift"]),
                    _theData.CreateParameter("@PanelLengthMin",  SqlDbType.Decimal, 0, r["PanelLengthMin"]),
                    _theData.CreateParameter("@PanelLengthMax",  SqlDbType.Decimal, 0, r["PanelLengthMax"]),
                    _theData.CreateParameter("@SWMin",           SqlDbType.Decimal, 0, r["SWMin"]),
                    _theData.CreateParameter("@SWMax",           SqlDbType.Decimal, 0, r["SWMax"]),
                    _theData.CreateParameter("@NumWinch",        SqlDbType.Int,     0, r["NumWinch"]),
                    _theData.CreateParameter("@NumberOfEnds",    SqlDbType.Int,     0, r["NumberOfEnds"]),
                    _theData.CreateParameter("@RiggTypeID",      SqlDbType.Int,     0, r["RiggTypeID"]),
                    _theData.CreateParameter("@TippingDistance", SqlDbType.Int,     0, r["TippingDistance"]),
                };

                _theData.ParamCollection = _paramCollection;

                _theData.ExecuteInstruction();

                foreach (DataRow rr in selectedDesignationsData.Rows)
                {
                    if (theMainData.Columns.Contains(rr["Designation"].ToString()) == true)
                    {
                        MWDataManager.clsDataAccess _saveDesignationsData = new MWDataManager.clsDataAccess();
                        _saveDesignationsData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                        _saveDesignationsData.SqlStatement       = "sp_HRStdNorm_UpdateDesignationData";
                        _saveDesignationsData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                        _saveDesignationsData.queryReturnType    = MWDataManager.ReturnType.longNumber;

                        SqlParameter[] _paramCollection2 =
                        {
                            _saveDesignationsData.CreateParameter("@StdAndNormID", SqlDbType.Int,       0, r["StdAndNormID"]),
                            _saveDesignationsData.CreateParameter("@Designation",  SqlDbType.VarChar, 150, rr["Designation"]),
                            _saveDesignationsData.CreateParameter("@Day",          SqlDbType.Int,       0, r[rr["Designation"] + " Day"]),
                            _saveDesignationsData.CreateParameter("@Night",        SqlDbType.Int,       0, r[rr["Designation"] + " Night"]),
                        };

                        _saveDesignationsData.ParamCollection = _paramCollection2;

                        _saveDesignationsData.ExecuteInstruction();
                    }
                }
            }
        }
        private void AddWorkplace(string WPDesc)
        {
            MWDataManager.clsDataAccess _NewWorkPlace = new MWDataManager.clsDataAccess();
            _NewWorkPlace.ConnectionString = TConnections.GetConnectionString(systemDBTag, UserCurrentInfo.Connection);

            _NewWorkPlace.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _NewWorkPlace.queryReturnType    = MWDataManager.ReturnType.DataTable;
            // _NewWorkPlace.SqlStatement = "spAddPrePlanningWorkPlace";
            _NewWorkPlace.SqlStatement = "sp_PrePlanning_AddWorkplace";


            SqlParameter[] _paramCollection =
            {
                _NewWorkPlace.CreateParameter("@Prodmonth",     SqlDbType.Int,       0, Convert.ToInt32(PlanningSettings.ProdMonth)),
                _NewWorkPlace.CreateParameter("@Sectionid_2",   SqlDbType.VarChar,  20, PlanningSettings.MOSectionID),
                _NewWorkPlace.CreateParameter("@WPDESCRIPTION", SqlDbType.VarChar, 100, WPDesc),
                _NewWorkPlace.CreateParameter("@ActivityCode",  SqlDbType.Int,       0, PlanningSettings.ActivityID),
            };

            _NewWorkPlace.ParamCollection = _paramCollection;
            clsDataResult exr = _NewWorkPlace.ExecuteInstruction();

            if (exr.success == false)
            {
                MessageBox.Show(exr.Message);
            }

            if (_NewWorkPlace.ResultsDataTable.Rows.Count != 0)
            {
                CPMBusinessLayer.clsBusinessLayer BMEBL = new CPMBusinessLayer.clsBusinessLayer();
                BMEBL._queryReturnType   = CPMBusinessLayer.ReturnType.DataTable;
                BMEBL.SetsystemDBTag     = systemDBTag;
                BMEBL.SetUserCurrentInfo = this.UserCurrentInfo;

                //  DataTable theDates = new DataTable();
                if (BMEBL.get_BeginEndDates(PlanningSettings.MOSectionID, PlanningSettings.ProdMonth) == true)
                {
                    theDates = BMEBL.ResultsDataTable;
                }

                if (_NewWorkPlace.ResultsDataTable.Rows.Count > 0)
                {
                    foreach (DataRow r in _NewWorkPlace.ResultsDataTable.Rows)
                    {
                        tblPlanningData.ImportRow(r);
                    }
                }
            }
        }
        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 loadData(int TargetID)
        {
            MWDataManager.clsDataAccess _theAvalibalData = new MWDataManager.clsDataAccess();
            _theAvalibalData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _theAvalibalData.SqlStatement       = "sp_HR_Designations";
            _theAvalibalData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _theAvalibalData.queryReturnType    = MWDataManager.ReturnType.DataTable;

            SqlParameter[] _paramCollection =
            {
                _theAvalibalData.CreateParameter("@TargetID", SqlDbType.VarChar, 10, TargetID.ToString()),
            };

            _theAvalibalData.ParamCollection = _paramCollection;

            _theAvalibalData.ExecuteInstruction();
            theAvalibalData = _theAvalibalData.ResultsDataTable.Copy();

            gcAvalibalData.DataSource = theAvalibalData;

            MWDataManager.clsDataAccess _theSelectedData = new MWDataManager.clsDataAccess();
            _theSelectedData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _theSelectedData.SqlStatement       = "SELECT Designation FROM HRSTDNORMDESIGNATION WHERE TargetID = " + TargetID.ToString();
            _theSelectedData.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _theSelectedData.queryReturnType    = MWDataManager.ReturnType.DataTable;

            gcSelectedData.DataSource = _theSelectedData.ResultsDataTable;

            _theSelectedData.ExecuteInstruction();
            theSelectedData = _theSelectedData.ResultsDataTable.Copy();

            gcSelectedData.DataSource = theSelectedData;
        }
        private void LoadData(int TargetID)
        {
            MWDataManager.clsDataAccess _theData = new MWDataManager.clsDataAccess();
            _theData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _theData.SqlStatement       = "sp_HRStdNorm_GetData";
            _theData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _theData.queryReturnType    = MWDataManager.ReturnType.DataTable;



            SqlParameter[] _paramCollection =
            {
                _theData.CreateParameter("@TargetID", SqlDbType.Int, 0, TargetID),
            };


            _theData.ParamCollection = _paramCollection;

            _theData.ExecuteInstruction();

            //theMainData = _theData.ResultsDataTable.Clone();
            theMainData           = _theData.ResultsDataTable.Copy();
            vgcOptions.DataSource = theMainData;

            _theData.SqlStatement       = "SELECT * FROM HRSTDNORMDESIGNATION WHERE TargetID = " + TargetID.ToString();
            _theData.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _theData.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _theData.ExecuteInstruction();


            selectedDesignationsData = _theData.ResultsDataTable.Copy();

            foreach (DataRow r in selectedDesignationsData.Rows)
            {
                if (theMainData.Columns.Contains(r["Designation"].ToString()) == false)
                {
                    addDesignationsCol(r["Designation"].ToString());
                }

                if (theMainData.Columns.Contains(r["Designation"].ToString()) == true)
                {
                    foreach (DataRow rr in theMainData.Rows)
                    {
                        _theData.SqlStatement = "SELECT *FROM [HRSTDNORMDESIGNATIONDATA] " +
                                                "WHERE StdAndNormID = " + rr["StdAndNormID"].ToString() + " and " +
                                                "Designation = '" + r["Designation"].ToString() + "'";
                        _theData.ExecuteInstruction();

                        if (_theData.ResultsDataTable.Rows.Count == 1)
                        {
                            foreach (DataRow rrr in _theData.ResultsDataTable.Rows)
                            {
                                rr[r["Designation"] + " Day"]   = rrr["Day"];
                                rr[r["Designation"] + " Night"] = rrr["Night"];
                            }
                        }
                    }
                }
            }
        }
        private void createReport(Object theReportSettings)
        {
            try
            {
                ActiveReport.reportType = Global.ReportsControls.SharedItems.reportTypes.AsposeExcel;
                clsDuplicateSampleReportSettings currentReportSettings = theReportSettings as clsDuplicateSampleReportSettings;
                string designerFile = TGlobalItems.ReportsFolder + "\\DuplicateSampleData.Xlsx";
                MWDataManager.clsDataAccess _courseBlankData = new MWDataManager.clsDataAccess();
                _courseBlankData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _courseBlankData.SqlStatement       = "sp_DuplicateSampleReport";
                _courseBlankData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                _courseBlankData.ResultsTableName   = "DuplicateSampleData";

                SqlParameter[] _paramCollection =
                {
                    _courseBlankData.CreateParameter("@Shaft", SqlDbType.VarChar, 50, reportSettings.Shaft.ToString())
                };

                _courseBlankData.ParamCollection = _paramCollection;
                _courseBlankData.queryReturnType = MWDataManager.ReturnType.DataTable;
                _courseBlankData.ExecuteInstruction();
                DataSet repDataSet = new DataSet();
                repDataSet.Tables.Add(_courseBlankData.ResultsDataTable);
                ActiveReport.SetReport = designerFile;
                ActiveReport.SetReportData(repDataSet);
                ActiveReport.isDone = true;
            }
            catch (Exception _exception)
            {
                Mineware.Systems.Global.sysNotification.TsysNotification.showNotification("Exception Error", _exception.Message, Color.Red);
            }
        }
        public void LoadDetails(int ChangeRequestID)
        {
            MWDataManager.clsDataAccess _WPData = new MWDataManager.clsDataAccess();
            _WPData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            _WPData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _WPData.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _WPData.SqlStatement       = "[sp_prePlanning_data]";

            SqlParameter[] _paramCollectionS =
            {
                _WPData.CreateParameter("@ChangeRequestID", SqlDbType.Int, 0, Convert.ToString(ChangeRequestID))
            };
            _WPData.ParamCollection = _paramCollectionS;
            _WPData.ExecuteInstruction();

            foreach (DataRow r in _WPData.ResultsDataTable.Rows)
            {
                editFL.Text = r["FL"].ToString();
                editMiningMethod.Properties.NullText = r["Description"].ToString();

                editSection.Text = r["Name_2"].ToString();

                textEdit2.Text = r["ProdMonth"].ToString();

                editToWorkplace.Properties.NullText = r["WPDesc"].ToString();

                memoEdit1.Text = r["Comments"].ToString();


                loadManageValues(r["OldWorkplaceID"].ToString(), Convert.ToInt32(r["ProdMonth"].ToString()), r["SectionID"].ToString(), r["SectionID_2"].ToString(), true);
            }
        }
        private void btnShow_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            rpReplanning.Visible  = true;
            rpPreplanning.Visible = false;
            MainGrid.Visible      = true;
            panelControl1.Visible = true;
            LoadOrgUnits(prodmonth1.EditValue.ToString(), section.EditValue.ToString());
            LoadMinerList(prodmonth1.EditValue.ToString(), section.EditValue.ToString());

            editProdmonth.Text = prodmonth1.EditValue.ToString();
            MWDataManager.clsDataAccess _MOSection = new MWDataManager.clsDataAccess();
            _MOSection.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _MOSection.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _MOSection.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _MOSection.SqlStatement       = "SELECT DISTINCT NAME_2,Name_2 FROM dbo.SECTION_COMPLETE " +
                                            "WHERE PRODMONTH = '" + prodmonth1.EditValue.ToString() + "' AND " +
                                            "SECTIONID_2 = '" + section.EditValue.ToString() + "'";
            _MOSection.ExecuteInstruction();
            editMoSectionID.Text = section.EditValue.ToString();
            foreach (DataRow r in _MOSection.ResultsDataTable.Rows)
            {
                editMoSection.Text = r["Name_2"].ToString();
            }

            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_SundryMiningMeasurements]";
            int    prodmonth = Convert.ToInt32(prodmonth1.EditValue);
            string desc      = section.EditValue.ToString();
            int    activ     = Convert.ToInt32(activity.EditValue);

            SqlParameter[] _paramCollection =
            {
                _dbMan.CreateParameter("@prodmonth", SqlDbType.Int,      0, Convert.ToInt32(prodmonth)),
                _dbMan.CreateParameter("@sectionid", SqlDbType.VarChar, 50, section.EditValue.ToString()),
            };

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

            dt = _dbMan.ResultsDataTable;
            MainGrid.DataSource = dt;
        }
        public void LoadPlanningCycle()
        {
            try
            {
                MWDataManager.clsDataAccess _PrePlanningCycleData = new MWDataManager.clsDataAccess();
                _PrePlanningCycleData.ConnectionString = TConnections.GetConnectionString(systemDBTag,
                                                                                          UserCurrentInfo.Connection);
                _PrePlanningCycleData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                _PrePlanningCycleData.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _PrePlanningCycleData.SqlStatement       = "sp_LoadPlanningCycle";

                SqlParameter[] _paramCollection =
                {
                    _PrePlanningCycleData.CreateParameter("@sectionid",
                                                          SqlDbType.VarChar,
                                                          20,
                                                          (planningSettings.MOSectionID)),
                    _PrePlanningCycleData.CreateParameter("@sectionidMO",
                                                          SqlDbType.VarChar,
                                                          20,
                                                          planningSettings.MOSectionID),
                    _PrePlanningCycleData.CreateParameter("@ProdMonth",
                                                          SqlDbType.Int,
                                                          0,
                                                          Convert.ToInt32(planningSettings.ProdMonth)),

                    _PrePlanningCycleData.CreateParameter("@Activity",
                                                          SqlDbType.Int,
                                                          0,
                                                          planningSettings.ActivityID)
                };


                _PrePlanningCycleData.ParamCollection = _paramCollection;
                var result = _PrePlanningCycleData.ExecuteInstruction();
                tblPlanningCycleData = _PrePlanningCycleData.ResultsDataTable.Copy();
                planningCycle.LoadPlanningCycleData(tblPlanningCycleData);
                _PrePlanningCycleData.Dispose();
                _PrePlanningCycleData = null;
            }
            catch (Exception)
            {
            }
        }
        public void AddCyclePlan(string workplaceID, string sectionid, string sectionidMO, string ProdMonth, int Activity, double FL)
        {
            MWDataManager.clsDataAccess _NewCyclePlan = new MWDataManager.clsDataAccess();
            _NewCyclePlan.ConnectionString = TConnections.GetConnectionString(systemDBTag, UserCurrentInfo.Connection);

            _NewCyclePlan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _NewCyclePlan.queryReturnType    = MWDataManager.ReturnType.DataTable;
            // _NewWorkPlace.SqlStatement = "spAddPrePlanningWorkPlace";
            _NewCyclePlan.SqlStatement = "sp_LoadPlanningCycleWP";


            SqlParameter[] _paramCollection =
            {
                _NewCyclePlan.CreateParameter("@workplaceID", SqlDbType.VarChar,  12, workplaceID),
                _NewCyclePlan.CreateParameter("@sectionid",   SqlDbType.VarChar,  20, sectionid),
                _NewCyclePlan.CreateParameter("@sectionidMO", SqlDbType.VarChar, 100, sectionidMO),
                _NewCyclePlan.CreateParameter("@ProdMonth",   SqlDbType.Int,       0, ProdMonth),
                _NewCyclePlan.CreateParameter("@Activity",    SqlDbType.Int,       0, Activity),
                _NewCyclePlan.CreateParameter("@FL",          SqlDbType.Int,       0, FL),
            };

            _NewCyclePlan.ParamCollection = _paramCollection;

            clsDataResult exr = _NewCyclePlan.ExecuteInstruction();

            if (exr.success)
            {
                planningCycle.LoadPlanningCycleData(_NewCyclePlan.ResultsDataTable);
            }
        }
        private SqlParameter[] SetParamters(string WORKPLACEID, Int32 PRODMONTH, string SectionID_2, int ActicityCode, string sectionID)
        {
            MWDataManager.clsDataAccess theData = new MWDataManager.clsDataAccess();

            SqlParameter[] _paramCollection =
            {
                theData.CreateParameter("@Prodmonth",   SqlDbType.Int,       0, PRODMONTH.ToString()),
                theData.CreateParameter("@SectionID",   SqlDbType.VarChar,  20, sectionID),
                theData.CreateParameter("@Sectionid_2", SqlDbType.VarChar,  20, SectionID_2),
                theData.CreateParameter("@WorkplaceID", SqlDbType.VarChar,  20, WORKPLACEID),
                theData.CreateParameter("@Activity",    SqlDbType.Int,       0, ActicityCode),
                theData.CreateParameter("@UserID",      SqlDbType.VarChar,  50, TUserInfo.UserID),
                theData.CreateParameter("@NetworkID",   SqlDbType.VarChar, 100, System.Environment.UserName),
                theData.CreateParameter("@MachineID",   SqlDbType.VarChar, 100, System.Environment.MachineName),
            };


            return(_paramCollection);
        }
Beispiel #19
0
        public void LoadDetails(int ChangeRequestID)
        {
            MWDataManager.clsDataAccess _WPData = new MWDataManager.clsDataAccess();
            _WPData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _WPData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _WPData.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _WPData.SqlStatement       = "[sp_prePlanning_data]";

            SqlParameter[] _paramCollectionS =
            {
                _WPData.CreateParameter("@ChangeRequestID", SqlDbType.Int, 0, Convert.ToString(ChangeRequestID))
            };
            _WPData.ParamCollection = _paramCollectionS;
            _WPData.ExecuteInstruction();

            foreach (DataRow r in _WPData.ResultsDataTable.Rows)
            {
                txtSection.Text       = r["Name_2"].ToString();
                txtProdMonth.Text     = r["ProdMonth"].ToString();
                txtWorkplaceID.Text   = r["WorkplaceID"].ToString();
                txtWorkplaceName.Text = r["WPDesc"].ToString();
                editSNewCube.Text     = r["CubicMeters"].ToString();
                editSNewOffRSQM.Text  = r["WasteSQM"].ToString();
                editSNewOnRSQM.Text   = r["ReefSQM"].ToString();
                editNewDevCube.Text   = r["CubicMeters"].ToString();
                editDevNewOffRM.Text  = r["MetersWaste"].ToString();
                editDevNewOnRM.Text   = r["Meters"].ToString();
                memoReason.Text       = r["Comments"].ToString();
                dateStop.DateTime     = Convert.ToDateTime(r["StopDate"].ToString());
                try
                {
                    DeleteBooking.Checked = Convert.ToBoolean(r["DeleteBookings"].ToString());
                }
                catch
                {
                    DeleteBooking.Checked = false;
                }

                dateStop.Properties.ReadOnly   = true;
                memoReason.Properties.ReadOnly = true;

                loadCurrentValues(r["WorkplaceID"].ToString(), Convert.ToInt32(r["ProdMonth"].ToString()), r["SectionID"].ToString(), r["SectionID_2"].ToString(), true);
            }
        }
        public void LoadDetails(int ChangeRequestID)
        {
            MWDataManager.clsDataAccess _WPData = new MWDataManager.clsDataAccess();
            _WPData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            _WPData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _WPData.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _WPData.SqlStatement       = "[sp_prePlanning_data]";

            SqlParameter[] _paramCollectionS =
            {
                _WPData.CreateParameter("@ChangeRequestID", SqlDbType.Int, 0, Convert.ToString(ChangeRequestID))
            };
            _WPData.ParamCollection = _paramCollectionS;
            _WPData.ExecuteInstruction();

            foreach (DataRow r in _WPData.ResultsDataTable.Rows)
            {
                txtSection.Text       = r["Name_2"].ToString();
                txtProdMonth.Text     = r["ProdMonth"].ToString();
                txtWorkplaceID.Text   = r["WorkplaceID"].ToString();
                txtWorkplaceName.Text = r["WPDesc"].ToString();


                txtOnReefSQMNewC.Text  = r["ReefSQM"].ToString();
                txtOffReefSQMNewC.Text = r["WasteSQM"].ToString();
                txtCubicMeterNEWs.Text = r["CubicMeters"].ToString();
                spinFLNew.Text         = r["FL"].ToString();


                txtOnReefMetersNewC.Text  = r["Meters"].ToString();
                txtOffReefMetersNewC.Text = r["MetersWaste"].ToString();
                txtCubicMeterNEW.Text     = r["CubicMeters"].ToString();
                memoReson.Text            = r["Comments"].ToString();

                memoReson.Properties.ReadOnly = true;
                theActivity = Convert.ToInt32(r["Activity"]);
                loadCurrentValues(r["WorkplaceID"].ToString(), Convert.ToInt32(r["ProdMonth"].ToString()), r["SectionID"].ToString(), r["SectionID_2"].ToString(), true);
            }
        }
Beispiel #21
0
        public void LoadDetails(int ChangeRequestID)
        {
            MWDataManager.clsDataAccess _WPData = new MWDataManager.clsDataAccess();
            _WPData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);

            _WPData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _WPData.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _WPData.SqlStatement       = "[sp_prePlanning_data]";

            SqlParameter[] _paramCollectionS =
            {
                _WPData.CreateParameter("@ChangeRequestID", SqlDbType.Int, 0, Convert.ToString(ChangeRequestID))
            };
            _WPData.ParamCollection = _paramCollectionS;
            _WPData.ExecuteInstruction();

            foreach (DataRow r in _WPData.ResultsDataTable.Rows)
            {
                txtSection.Text   = r["Name_2"].ToString();
                txtProdMonth.Text = r["ProdMonth"].ToString();
                txtWorkplace.Text = r["WPDesc"].ToString();



                editMiner1.Properties.NullText     = r["Name"].ToString();
                editDay1.Properties.NullText       = "";
                editNight1.Properties.NullText     = "";
                editRoming1.Properties.NullText    = "";
                editAfternoon1.Properties.NullText = "";

                memoReason.Text = r["Comments"].ToString();

                theActivity = Convert.ToInt32(r["Activity"]);
                loadManageValues(r["WorkplaceID"].ToString(), Convert.ToInt32(r["ProdMonth"].ToString()), r["SectionID"].ToString(), r["SectionID_2"].ToString(), true);
            }
        }
        private void loadingData()
        {
            cmbType.Items.Add("Stoping");
            cmbType.Items.Add("Development");
            userList.DataSource = getUserList("", TempID);

            userList.ValueMember   = "USERID";
            userList.DisplayMember = "NAME";

            //gridControl1.ForceInitialize();

            //   Add new template

            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
            _dbMan.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _dbMan.SqlStatement       = "[spUpdate_PlanningTemplate_UserSecurity_Table]";
            _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            SqlParameter[] _paramCollection =
            {
                _dbMan.CreateParameter("@Prodmonth", SqlDbType.Int, 7, TProductionGlobal.getSystemSettingsProductioInfo(UserCurrentInfo.Connection).CurrentProductionMonth),
            };
            _dbMan.ParamCollection = _paramCollection;
            _dbMan.queryReturnType = MWDataManager.ReturnType.longNumber;
            _dbMan.ExecuteInstruction();

            SqlDataAdapter oleDBAdapter1 = new SqlDataAdapter("SELECT TemplateID, TemplateName FROM PlanProt_Template WHERE TemplateID =  " + TempID.ToString(), TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection));
            SqlDataAdapter oleDBAdapter2 = new SqlDataAdapter("SELECT * FROM PlanProt_ApproveUsers WHERE SEction = 'NONE' and Shaft <> 'NONE' ORDER BY Shaft ", TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection));
            SqlDataAdapter oleDBAdapter3 = new SqlDataAdapter("SELECT * FROM PlanProt_ApproveUsers WHERE SEction <> 'NONE' ORDER BY Section ", TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection));
            SqlDataAdapter oleDBAdapter4 = new SqlDataAdapter("SELECT DISTINCT  * FROM PlanProt_ApproveUsers WHERE SEction = 'NONE' and Shaft = 'NONE' ORDER BY Shaft,Unit ", TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection));


            oleDBAdapter1.Fill(dsTemplateSecurity.theTemplates);
            oleDBAdapter2.Fill(dsTemplateSecurity.theShaft);
            oleDBAdapter3.Fill(dsTemplateSecurity.theSection);
            oleDBAdapter4.Fill(dsTemplateSecurity.theUnits);

            if (formAction == currentAction.caAdd)
            {
                // Load all User Profiles in CPM
                MWDataManager.clsDataAccess _dbManLastMonthWP = new MWDataManager.clsDataAccess();
                _dbManLastMonthWP.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _dbManLastMonthWP.SqlStatement       = "SELECT USERPROFILEID ProfileName,CAST(FullAccess AS BIT) FullAccess,CAST(ReadOnlyAccess AS BIT) ReadOnlyAccess FROM (SELECT USERPROFILEID,0 FullAccess,1 ReadOnlyAccess FROM dbo.USERPROFILES) theProfile";
                _dbManLastMonthWP.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbManLastMonthWP.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _dbManLastMonthWP.ExecuteInstruction();

                using (DataTableReader reader = new DataTableReader(_dbManLastMonthWP.ResultsDataTable))
                {
                    dtProfileInfo.Clear();
                    dtProfileInfo.Load(reader);
                }
                gridSecurity.DataSource = dtProfileInfo; // Populate grid


                MWDataManager.clsDataAccess _dbManTemplate = new MWDataManager.clsDataAccess();
                _dbManTemplate.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _dbManTemplate.SqlStatement       = "select MAX(TemplateID) TemplateID from PlanProt_Template";
                _dbManTemplate.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbManTemplate.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _dbManTemplate.ExecuteInstruction();

                using (DataTableReader readerTemplate = new DataTableReader(_dbManTemplate.ResultsDataTable))
                {
                    tableTemplate.Load(readerTemplate);
                }

                foreach (DataRow Temp in tableTemplate.Rows)
                {
                    if (Temp["TemplateID"].ToString() == "")
                    {
                        TempID = 1;
                    }
                    else
                    {
                        TempID = Convert.ToInt32(Temp["TemplateID"].ToString()) + 1;
                    }
                }
            }
            else
            if (formAction == currentAction.caEdit)
            {
                MWDataManager.clsDataAccess _dbManTemplateDetail = new MWDataManager.clsDataAccess();
                _dbManTemplateDetail.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _dbManTemplateDetail.SqlStatement       = "Select * from PLANPROT_TEMPLATE where TemplateID = '" + TempID + "'";
                _dbManTemplateDetail.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbManTemplateDetail.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _dbManTemplateDetail.ExecuteInstruction();


                _dbApproveUsers.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _dbApproveUsers.SqlStatement       = "SELECT TemplateID,Shaft,User1,User2 FROM dbo.PLANPROT_APPROVEUSERS WHERE TemplateID = '" + TempID + "'";
                _dbApproveUsers.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbApproveUsers.queryReturnType    = MWDataManager.ReturnType.DataTable;
                _dbApproveUsers.ExecuteInstruction();

                cmbType.Enabled        = false;
                txtDescription.Enabled = false;

                //   gcApproveData.DataSource = _dbApproveUsers.ResultsDataTable;

                using (DataTableReader readerTempDetail = new DataTableReader(_dbManTemplateDetail.ResultsDataTable))
                {
                    tableTemplate.Load(readerTempDetail);
                }

                foreach (DataRow dr in tableTemplate.Rows)
                {
                    if (dr["Activity"].ToString() == "0")
                    {
                        cmbType.SelectedIndex = 0;
                    }
                    else
                    {
                        cmbType.SelectedIndex = 1;
                    }

                    txtDescription.Text = dr["TemplateName"].ToString();
                    string edit1;

                    if (dr["ApprovalRequired"].ToString() == "True")
                    {
                        rgReqApproval.SelectedIndex = 0;
                    }
                    else
                    {
                        rgReqApproval.SelectedIndex = 1;
                    }
                }

                DataTable CPMProfiles = new DataTable();

                MWDataManager.clsDataAccess _dbManLastMonthWP = new MWDataManager.clsDataAccess();
                _dbManLastMonthWP.ConnectionString = TConnections.GetConnectionString("SystemSettings", UserCurrentInfo.Connection);
                //_dbManLastMonthWP.SqlStatement = "SELECT USERPROFILEID FROM USERPROFILES ";
                _dbManLastMonthWP.SqlStatement = "SELECT DepartmentID,Description FROM tblDepartments ";

                _dbManLastMonthWP.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _dbManLastMonthWP.queryReturnType    = MWDataManager.ReturnType.DataTable;
                var result = _dbManLastMonthWP.ExecuteInstruction();
                if (!result.success)
                {
                    MessageItem.viewMessage(MessageType.Error, "SQL ERROR", theSystemDBTag, "frmPlanProtTemplateSetup", "loadingData", result.Message, ButtonTypes.OK, MessageDisplayType.FullScreen);
                    return;
                }

                DataTableReader reader = new DataTableReader(_dbManLastMonthWP.ResultsDataTable);
                CPMProfiles.Load(reader);

                _dbManLastMonthWP.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _dbManLastMonthWP.SqlStatement     = "SELECT DepartmentID ,TemplateID ,FullAccess ,ReadOnlyAccess , '' Description , CAST(DATA1 .AccessLevel as bit) AccessLevel FROM ( " +
                                                     "select DepartmentID ,TemplateID, cast(data.FullAccess as bit) FullAccess, cast(data.ReadOnlyAccess as bit) ReadOnlyAccess, AccessLevel = CASE WHEN FullAccess = 0 THEN '0' ELSE '1' END  from ( " +
                                                     "SELECT PPA.DepartmentID ,PPA .TemplateID , " +
                                                     "FullAccess= CASE WHEN PPA .AccessLevel=1 then '1' else '0' end, " +
                                                     "ReadOnlyAccess= case when PPA.AccessLevel =1 then '0' else '1' end , " +
                                                     "PPA.AccessLevel   FROM PLANPROT_PROFILEACCESS PPA WHERE TemplateID = '" + TempID.ToString() + "')data)DATA1 ";
                result = _dbManLastMonthWP.ExecuteInstruction();
                if (!result.success)
                {
                    MessageItem.viewMessage(MessageType.Error, "SQL ERROR", theSystemDBTag, "frmPlanProtTemplateSetup", "loadingData", result.Message, ButtonTypes.OK, MessageDisplayType.FullScreen);
                    return;
                }

                DataTableReader reader2 = new DataTableReader(_dbManLastMonthWP.ResultsDataTable);
                dtProfileInfo.Load(reader2);

                foreach (DataRow dr in CPMProfiles.Rows)
                {
                    string expression;
                    //expression = "ProfileName = '" + dr["USERPROFILEID"].ToString() + "'";
                    expression = "DepartmentID = '" + dr["DepartmentID"].ToString() + "'";
                    DataRow[] foundRows;
                    foundRows = dtProfileInfo.Select(expression);

                    var description = dr["Description"].ToString();
                    if (foundRows.Length == 0)
                    {
                        //dtProfileInfo.Rows.Add(dr["USERPROFILEID"].ToString(), 0, TempID);
                        //dtProfileInfo.Rows.Add(dr["Description"].ToString(), 0, TempID);
                        dtProfileInfo.Rows.Add(dr["DepartmentID"].ToString(), TempID, false, true, description);
                    }
                    else
                    {
                        foundRows[0]["Description"] = description;
                    }
                }

                dtProfileInfo.Select("");

                //dtProfileInfo.Columns.Add("Access1", typeof(bool));


                //
                //{
                //    if (dr["ProfileAccess"] == DBNull.Value)
                //    {
                //        dr["Access1"] = false;
                //    }
                //    else
                //    {
                //        dr["Access1"] = dr["ProfileAccess"];
                //    }
                //}

                //bandedGridView1.PopulateColumns(dtProfileInfo);
                //LoadColumns();
                gridSecurity.DataSource = dtProfileInfo; // Populate grid
                //bandedGridView1.Columns[1].Visible = false;
            }

            MWDataManager.clsDataAccess _dbManGrid = new MWDataManager.clsDataAccess();
            _dbManGrid.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _dbManGrid.SqlStatement     = "select Distinct pf.FieldID [FieldID],pf.FieldName [Field Name],ppf.fieldDescription [Field Type],pf2.FieldName[Parent]  from PlanProt_Fields pf " +
                                          "left outer join " +
                                          "PlanProt_FieldTypes ppf " +
                                          "on pf.FieldType = ppf.fieldTypeID " +
                                          "left outer join PLANPROT_DATA pg " +
                                          "on pf.FieldID = pg.FieldID " +
                                          "left outer join " +
                                          "PlanProt_Fields pf2 " +
                                          "on pg.FieldID = pf2.parentID " +
                                          " where pf.TemplateID = '" + TempID + "' Order by pf.FieldID ";
            _dbManGrid.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _dbManGrid.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _dbManGrid.ExecuteInstruction();

            DataTableReader readerGrid = new DataTableReader(_dbManGrid.ResultsDataTable);

            tableGrid.Load(readerGrid);

            gridOutput.DataSource = tableGrid; // Populate Grid
            // bandedGridView2.Columns[0].Visible = false;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //int AccessType = 0;
                foreach (DataRow dr in dtProfileInfo.Rows)
                {
                    MWDataManager.clsDataAccess _dbManDelete = new MWDataManager.clsDataAccess();
                    _dbManDelete.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _dbManDelete.SqlStatement       = "Delete from PlanProt_ProfileAccess where DepartmentID = '" + dr["DepartmentID"].ToString() + "' and TemplateID = '" + TempID + "'";
                    _dbManDelete.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _dbManDelete.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbManDelete.ExecuteInstruction();

                    MWDataManager.clsDataAccess _dbManLastMonthWP = new MWDataManager.clsDataAccess();
                    _dbManLastMonthWP.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    //_dbManLastMonthWP.SqlStatement = "Insert into PlanProt_ProfileAccess (DepartmentID ,FullAccess ,ReadOnlyAccess, TemplateID)  values ('" + dr["ProfileName"].ToString() + "' , '" + dr["FullAccess"] + "' , '" + dr["ReadOnlyAccess"] + "', '" + TempID + "')";
                    if (dr["FullAccess"].ToString() == "True")
                    {
                        _dbManLastMonthWP.SqlStatement = "Insert into PlanProt_ProfileAccess (DepartmentID ,TemplateID,AccessLevel)  values ('" + dr["DepartmentID"].ToString() + "' , '" + TempID + "' ,  'True')";
                    }
                    else
                    {
                        _dbManLastMonthWP.SqlStatement = "Insert into PlanProt_ProfileAccess (DepartmentID ,TemplateID,AccessLevel)  values ('" + dr["DepartmentID"].ToString() + "' , '" + TempID + "' ,  'False')";
                    }


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

                if (formAction == currentAction.caAdd)
                {
                    MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _dbMan.SqlStatement       = "sp_PlanProt_TemplateSetupSave";
                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    SqlParameter[] _paramCollection =
                    {
                        _dbMan.CreateParameter("@TemplateID",    SqlDbType.Int,       7, TempID),
                        _dbMan.CreateParameter("@TemplateName",  SqlDbType.VarChar, 200, txtDescription.Text),
                        _dbMan.CreateParameter("@Activity",      SqlDbType.Int,       7, cmbType.SelectedIndex),
                        _dbMan.CreateParameter("@Fieldid",       SqlDbType.Int,      50, DBNull.Value),
                        // _dbMan.CreateParameter("@FieldType", SqlDbType.VarChar ,30 ,DBNull.Value ),
                        _dbMan.CreateParameter("@SelectedValue", SqlDbType.VarChar,   4, DBNull.Value),
                        _dbMan.CreateParameter("@MinValue",      SqlDbType.VarChar,   4, DBNull.Value),
                        _dbMan.CreateParameter("@MaxValue",      SqlDbType.VarChar,   4, DBNull.Value),
                        _dbMan.CreateParameter("@RiskRating",    SqlDbType.Int,       3, DBNull.Value),
                        _dbMan.CreateParameter("@ParentID",      SqlDbType.Int,       3, DBNull.Value),
                        _dbMan.CreateParameter("@FrontBack",     SqlDbType.Int,       3,                                                                 1),
                        _dbMan.CreateParameter("@Action",        SqlDbType.Int,       3,                                                                 0),
                        _dbMan.CreateParameter("@FieldUpdate",   SqlDbType.Int,       3, DBNull.Value),
                        _dbMan.CreateParameter("@User1",         SqlDbType.VarChar,  50, ""),
                        _dbMan.CreateParameter("@User2",         SqlDbType.VarChar,  50, ""),
                        _dbMan.CreateParameter("@AprovalReq",    SqlDbType.Bit,       0, rgReqApproval.Properties.Items[rgReqApproval.SelectedIndex].Value),
                    };
                    _dbMan.ParamCollection = _paramCollection;
                    _dbMan.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _dbMan.ExecuteInstruction();


                    MessageBox.Show("Data Saved Successfully", "Data Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _dbMan.SqlStatement       = "sp_PlanProt_TemplateSetupSave";
                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    SqlParameter[] _paramCollection =
                    {
                        _dbMan.CreateParameter("@TemplateID",    SqlDbType.Int,       7, TempID),
                        _dbMan.CreateParameter("@TemplateName",  SqlDbType.VarChar, 200, txtDescription.Text),
                        _dbMan.CreateParameter("@Activity",      SqlDbType.Int,       7, cmbType.SelectedIndex),
                        _dbMan.CreateParameter("@Fieldid",       SqlDbType.Int,      50, DBNull.Value),
                        //_dbMan.CreateParameter("@FieldType", SqlDbType.VarChar ,30 ,DBNull.Value ),
                        _dbMan.CreateParameter("@SelectedValue", SqlDbType.VarChar,   4, DBNull.Value),
                        _dbMan.CreateParameter("@MinValue",      SqlDbType.VarChar,   4, DBNull.Value),
                        _dbMan.CreateParameter("@MaxValue",      SqlDbType.VarChar,   4, DBNull.Value),
                        _dbMan.CreateParameter("@RiskRating",    SqlDbType.Int,       3, DBNull.Value),
                        _dbMan.CreateParameter("@ParentID",      SqlDbType.Int,       3, DBNull.Value),
                        _dbMan.CreateParameter("@FrontBack",     SqlDbType.Int,       3,                                                                 1),
                        _dbMan.CreateParameter("@Action",        SqlDbType.Int,       3,                                                                 1),
                        _dbMan.CreateParameter("@FieldUpdate",   SqlDbType.Int,       3, DBNull.Value),
                        _dbMan.CreateParameter("@User1",         SqlDbType.VarChar,  50, ""),
                        _dbMan.CreateParameter("@User2",         SqlDbType.VarChar,  50, ""),
                        _dbMan.CreateParameter("@AprovalReq",    SqlDbType.Bit,       0, rgReqApproval.Properties.Items[rgReqApproval.SelectedIndex].Value),
                    };
                    _dbMan.ParamCollection = _paramCollection;
                    _dbMan.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _dbMan.ExecuteInstruction();

                    MWDataManager.clsDataAccess _UpdateData = new MWDataManager.clsDataAccess();
                    _UpdateData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _UpdateData.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _UpdateData.queryReturnType    = MWDataManager.ReturnType.DataTable;


                    foreach (DataRow r in dsTemplateSecurity.theUnits.Rows)
                    {
                        if (r["IsUpdated"].ToString() == "1")
                        {
                            _UpdateData.SqlStatement = "UPDATE PlanProt_ApproveUsers SET User1 = '" + r["User1"].ToString() + "'," +
                                                       "                                 User2 = '" + r["User2"].ToString() + "' " +
                                                       "WHERE TemplateID = '" + r["TemplateID"].ToString() + "' and " +
                                                       "      Shaft = '" + r["Shaft"].ToString() + "' and " +
                                                       "      Unit= '" + r["Unit"].ToString() + "' and" +
                                                       "      Section =  '" + r["Section"].ToString() + "' ";

                            _UpdateData.ExecuteInstruction();
                        }
                    }

                    foreach (DataRow r in dsTemplateSecurity.theSection.Rows)
                    {
                        if (r["IsUpdated"].ToString() == "1")
                        {
                            _UpdateData.SqlStatement = "UPDATE PlanProt_ApproveUsers SET User1 = '" + r["User1"].ToString() + "'," +
                                                       "                                 User2 = '" + r["User2"].ToString() + "' " +
                                                       "WHERE TemplateID = '" + r["TemplateID"].ToString() + "' and " +
                                                       "      Shaft = '" + r["Shaft"].ToString() + "' and " +
                                                       "      Section =  '" + r["Section"].ToString() + "' ";

                            _UpdateData.ExecuteInstruction();
                        }
                    }

                    foreach (DataRow r in dsTemplateSecurity.theShaft.Rows)
                    {
                        if (r["IsUpdated"].ToString() == "1")
                        {
                            _UpdateData.SqlStatement = "UPDATE PlanProt_ApproveUsers SET User1 = '" + r["User1"].ToString() + "'," +
                                                       "                                 User2 = '" + r["User2"].ToString() + "' " +
                                                       "WHERE TemplateID = '" + r["TemplateID"].ToString() + "' and " +
                                                       "      Shaft = '" + r["Shaft"].ToString() + "' and " +
                                                       "      Section =  '" + r["Section"].ToString() + "' ";


                            _UpdateData.ExecuteInstruction();
                        }
                    }

                    TsysNotification.showNotification("Data Saved", "Template data was saved successfully", Color.CornflowerBlue);

                    CanClose = true;
                }
                dtProfileInfo.Clear();
                dsTemplateSecurity.theTemplates.Clear();
                dsTemplateSecurity.theShaft.Clear();
                dsTemplateSecurity.theSection.Clear();
                dsTemplateSecurity.theUnits.Clear();

                loadingData();
                // this.Close();
                //gridControl1.Refresh();
                //gridControl1.RefreshDataSource();
                //  gridControl1.DataSource = "";
            }
            catch (SqlException s)
            {
                MessageItem.viewMessage(MessageType.Error, "ERROR SAVING DATA", theSystemTag, "frmPlanProtTemplateSetup", "btnSave_Click", s.Message, ButtonTypes.OK, MessageDisplayType.FullScreen);
                CanClose = false;
            }
        }
Beispiel #24
0
        public bool unApproveSelected()
        {
            MWDataManager.clsDataAccess _UnApproveData = new MWDataManager.clsDataAccess();
            _UnApproveData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _UnApproveData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _UnApproveData.queryReturnType    = MWDataManager.ReturnType.longNumber;
            _UnApproveData.SqlStatement       = "sp_PrePlanning_Unapprove";

            if (editReason.Text == "")
            {
                MessageBox.Show("Provide a Reason for this Un-Approve procedure.");
                return(false);
            }
            else
            {
                foreach (DataRow row in theUnApproveData.Rows)
                {
                    try
                    {
                        if (Convert.ToBoolean(row["Selected"].ToString()) == true)
                        {
                            // Unapprove all dinamic plan
                            SqlParameter[] _paramCollection =
                            {
                                _UnApproveData.CreateParameter("@Prodmonth",    SqlDbType.VarChar, 20, row["Prodmonth"].ToString()),
                                _UnApproveData.CreateParameter("@WorkplaceID",  SqlDbType.VarChar, 20, row["Workplaceid"]),
                                _UnApproveData.CreateParameter("@Activitycode", SqlDbType.Int,      0, row["Activity"]),
                                _UnApproveData.CreateParameter("@Sectionid",    SqlDbType.VarChar, 20, row["Sectionid"]),
                                _UnApproveData.CreateParameter("@CurrentUser",  SqlDbType.VarChar, 20, TUserInfo.UserID),
                                _UnApproveData.CreateParameter("@Reason",       SqlDbType.VarChar,  0, editReason.Text),
                            };
                            _UnApproveData.ParamCollection = _paramCollection;
                            var result = _UnApproveData.ExecuteInstruction();

                            if (Convert.ToDecimal(row["CubicMetres"].ToString()) > 0)
                            {
                                // unapprove cube
                                SqlParameter[] _paramCollection1 =
                                {
                                    _UnApproveData.CreateParameter("@Prodmonth",    SqlDbType.VarChar, 20, row["Prodmonth"].ToString()),
                                    _UnApproveData.CreateParameter("@WorkplaceID",  SqlDbType.VarChar, 20, row["Workplaceid"]),
                                    _UnApproveData.CreateParameter("@Activitycode", SqlDbType.Int,      0,                           7),
                                    _UnApproveData.CreateParameter("@Sectionid",    SqlDbType.VarChar, 20, row["Sectionid"]),
                                    _UnApproveData.CreateParameter("@CurrentUser",  SqlDbType.VarChar, 20, TUserInfo.UserID),
                                    _UnApproveData.CreateParameter("@Reason",       SqlDbType.VarChar,  0, editReason.Text),
                                };
                                _UnApproveData.ParamCollection = _paramCollection1;
                                _UnApproveData.ExecuteInstruction();
                            }
                        }
                    }
                    catch (Exception _exception)
                    {
                        throw new ApplicationException(_exception.Message, _exception);
                    }
                }

                return(true);
            }
        }
        public void countcheck()
        {
            string text      = "";
            string separator = "";

            foreach (DataRow r in dsHRPlanning.PrePlanning.Rows)
            {
                string textCMB = text;
                MWDataManager.clsDataAccess _RequiredData = new MWDataManager.clsDataAccess();
                _RequiredData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _RequiredData.SqlStatement       = "spCountMiningMethod";
                _RequiredData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;

                if (Convert.ToInt32(r["TargetIDValid"].ToString()) == 0)
                {
                    SqlParameter[] _paramCollection1 =
                    {
                        _RequiredData.CreateParameter("@Prodmonth",    SqlDbType.Int,      7, Convert.ToInt32(r["Prodmonth"].ToString())),
                        _RequiredData.CreateParameter("@Sectionid_2 ", SqlDbType.VarChar, 50, r["Sectionid_2"].ToString()),
                        //_RequiredData.CreateParameter("@WorkplaceID", SqlDbType.Int, 0,r["WORKPLACEID"]),
                        //_RequiredData.CreateParameter("@TemplateID", SqlDbType.Int, 0,r["TemplateID"]),
                        // _RequiredData.CreateParameter("@ApprovedBy", SqlDbType.VarChar, 0,TUserInfo.UserID),
                        _RequiredData.CreateParameter("@Activity",     SqlDbType.Int,      0, r["Activitycode"]),
                        //  _SaveData.CreateParameter("@ApproveItem", SqlDbType.VarChar, 0,"YES"),
                    };

                    _RequiredData.ParamCollection = _paramCollection1;
                    _RequiredData.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _RequiredData.ExecuteInstruction();

                    DataTable dt = new DataTable();
                    dt = _RequiredData.ResultsDataTable;

                    foreach (DataRow dr in dt.Rows)
                    {
                        if (Convert.ToInt32(dr["MiningMethodCount"]) > 0)
                        {
                            text     += separator + r["WorkplaceDesc"];
                            separator = ",";
                            // textCMB += text;

                            string ss = string.Join(",", r["WorkplaceDesc"]);
                        }
                    }
                }
            }
            if (text == "")
            {
            }
            else
            {
                MessageBox.Show("Please provide Mining Methods required for the Workplaces " + text, "", MessageBoxButtons.OK);
            }

            string text1      = "";
            string separator1 = "";

            foreach (DataRow r in dsHRPlanning.PrePlanning.Rows)
            {
                string textCMB = text1;
                MWDataManager.clsDataAccess _RequiredData = new MWDataManager.clsDataAccess();
                _RequiredData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _RequiredData.SqlStatement       = "spCountNightCrew";
                _RequiredData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;

                if (Convert.ToInt32(r["NightCrewValid"].ToString()) == 0)
                {
                    SqlParameter[] _paramCollection1 =
                    {
                        _RequiredData.CreateParameter("@Prodmonth",    SqlDbType.Int,      7, Convert.ToInt32(r["Prodmonth"].ToString())),
                        _RequiredData.CreateParameter("@Sectionid_2 ", SqlDbType.VarChar, 50, r["Sectionid_2"].ToString()),
                        //_RequiredData.CreateParameter("@WorkplaceID", SqlDbType.Int, 0,r["WORKPLACEID"]),
                        //_RequiredData.CreateParameter("@TemplateID", SqlDbType.Int, 0,r["TemplateID"]),
                        // _RequiredData.CreateParameter("@ApprovedBy", SqlDbType.VarChar, 0,TUserInfo.UserID),
                        _RequiredData.CreateParameter("@Activity",     SqlDbType.Int,      0, r["Activitycode"]),
                        //  _SaveData.CreateParameter("@ApproveItem", SqlDbType.VarChar, 0,"YES"),
                    };

                    _RequiredData.ParamCollection = _paramCollection1;
                    _RequiredData.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _RequiredData.ExecuteInstruction();

                    DataTable dt = new DataTable();
                    dt = _RequiredData.ResultsDataTable;

                    foreach (DataRow dr in dt.Rows)
                    {
                        if (Convert.ToInt32(dr["NightCrewCount"]) > 0)
                        {
                            text1     += separator1 + r["WorkplaceDesc"];
                            separator1 = ",";
                            // textCMB += text;

                            string ss = string.Join(",", r["WorkplaceDesc"]);
                        }
                    }
                }
            }
            if (text1 == "")
            {
            }
            else
            {
                MessageBox.Show("Please provide Night Crews required for the Workplaces " + text1, "", MessageBoxButtons.OK);
            }

            string text2      = "";
            string separator2 = "";

            foreach (DataRow r in dsHRPlanning.PrePlanning.Rows)
            {
                string textCMB = text1;
                MWDataManager.clsDataAccess _RequiredData = new MWDataManager.clsDataAccess();
                _RequiredData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _RequiredData.SqlStatement       = "spCountPanelLengthValid";
                _RequiredData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;

                if (Convert.ToInt32(r["PanelLengthValid"].ToString()) == 0)
                {
                    SqlParameter[] _paramCollection1 =
                    {
                        _RequiredData.CreateParameter("@Prodmonth",    SqlDbType.Int,      7, Convert.ToInt32(r["Prodmonth"].ToString())),
                        _RequiredData.CreateParameter("@Sectionid_2 ", SqlDbType.VarChar, 50, r["Sectionid_2"].ToString()),
                        //_RequiredData.CreateParameter("@WorkplaceID", SqlDbType.Int, 0,r["WORKPLACEID"]),
                        //_RequiredData.CreateParameter("@TemplateID", SqlDbType.Int, 0,r["TemplateID"]),
                        // _RequiredData.CreateParameter("@ApprovedBy", SqlDbType.VarChar, 0,TUserInfo.UserID),
                        _RequiredData.CreateParameter("@Activity",     SqlDbType.Int,      0, r["Activitycode"]),
                        //  _SaveData.CreateParameter("@ApproveItem", SqlDbType.VarChar, 0,"YES"),
                    };

                    _RequiredData.ParamCollection = _paramCollection1;
                    _RequiredData.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _RequiredData.ExecuteInstruction();

                    DataTable dt = new DataTable();
                    dt = _RequiredData.ResultsDataTable;

                    foreach (DataRow dr in dt.Rows)
                    {
                        if (Convert.ToInt32(dr["PanelLengthCount"]) > 0)
                        {
                            text2     += separator2 + r["WorkplaceDesc"];
                            separator2 = ",";
                            // textCMB += text;

                            string ss = string.Join(",", r["WorkplaceDesc"]);
                        }
                    }
                }
            }
            if (text2 == "")
            {
            }
            else
            {
                MessageBox.Show("Please provide Panel Length required for the Workplaces " + text2, "", MessageBoxButtons.OK);
            }

            string text3      = "";
            string separator3 = "";

            foreach (DataRow r in dsHRPlanning.PrePlanning.Rows)
            {
                string textCMB = text1;
                MWDataManager.clsDataAccess _RequiredData = new MWDataManager.clsDataAccess();
                _RequiredData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _RequiredData.SqlStatement       = "spCountStopeWidthValid";
                _RequiredData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;

                if (Convert.ToInt32(r["StopeWidthValid"].ToString()) == 0)
                {
                    SqlParameter[] _paramCollection1 =
                    {
                        _RequiredData.CreateParameter("@Prodmonth",    SqlDbType.Int,      7, Convert.ToInt32(r["Prodmonth"].ToString())),
                        _RequiredData.CreateParameter("@Sectionid_2 ", SqlDbType.VarChar, 50, r["Sectionid_2"].ToString()),

                        _RequiredData.CreateParameter("@Activity",     SqlDbType.Int,      0, r["Activitycode"]),
                    };

                    _RequiredData.ParamCollection = _paramCollection1;
                    _RequiredData.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _RequiredData.ExecuteInstruction();

                    DataTable dt = new DataTable();
                    dt = _RequiredData.ResultsDataTable;

                    foreach (DataRow dr in dt.Rows)
                    {
                        if (Convert.ToInt32(dr["StopeWidthCount"]) > 0)
                        {
                            text3     += separator3 + r["WorkplaceDesc"];
                            separator3 = ",";
                            // textCMB += text;

                            string ss = string.Join(",", r["WorkplaceDesc"]);
                        }
                    }
                }
            }
            if (text3 == "")
            {
            }
            else
            {
                MessageBox.Show("Please provide Stope Width required for the Workplaces " + text3, "", MessageBoxButtons.OK);
            }
        }
        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;
        }
Beispiel #27
0
        public void sendRequest(string theSystemDBTag, string userConnection)
        {
            MWDataManager.clsDataAccess _sendRequest = new MWDataManager.clsDataAccess();
            _sendRequest.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, userConnection);
            _sendRequest.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
            _sendRequest.queryReturnType    = MWDataManager.ReturnType.DataTable;
            _sendRequest.SqlStatement       = "sp_RevisedPLanning_Request";



            SqlParameter[] _paramCollectionS =
            {
                _sendRequest.CreateParameter("@requestType",    SqlDbType.Int,       0, _requestType),
                _sendRequest.CreateParameter("@ProdMonth",      SqlDbType.Int,       0, _ProdMonth),
                _sendRequest.CreateParameter("@WorkplaceID",    SqlDbType.VarChar,  50, _WorkplaceID),
                _sendRequest.CreateParameter("@SectionID",      SqlDbType.VarChar,  20, _SectionID),
                _sendRequest.CreateParameter("@SectionID_2",    SqlDbType.VarChar,  20, _SectionID_2),
                _sendRequest.CreateParameter("@DayCrew",        SqlDbType.VarChar,  50, _DayCrew),
                _sendRequest.CreateParameter("@NightCrew",      SqlDbType.VarChar,  50, _NightCrew),
                _sendRequest.CreateParameter("@AfternoonCrew",  SqlDbType.VarChar,  50, _AfternoonCrew),
                _sendRequest.CreateParameter("@RovingCrew",     SqlDbType.VarChar,  50, _RovingCrew),
                _sendRequest.CreateParameter("@StartDate",      SqlDbType.VarChar,  20, String.Format("{0:yyy/MM/dd}",_StartDate)),
                _sendRequest.CreateParameter("@StopDate",       SqlDbType.VarChar,  20, String.Format("{0:yyy/MM/dd}",_StopDate)),
                _sendRequest.CreateParameter("@UserComments",   SqlDbType.VarChar, 600, _UserComments),
                _sendRequest.CreateParameter("@RequestBy",      SqlDbType.VarChar,  20, TUserInfo.UserID),
                _sendRequest.CreateParameter("@SQMOn",          SqlDbType.Float,     0, _SQMOn),
                _sendRequest.CreateParameter("@SQMOff",         SqlDbType.Float,     0, _SQMOff),
                _sendRequest.CreateParameter("@Cube",           SqlDbType.Float,     0, _Cube),
                _sendRequest.CreateParameter("@MeterOn",        SqlDbType.Float,     0, _MeterOn),
                _sendRequest.CreateParameter("@MeterOff",       SqlDbType.Float,     0, _MeterOff),
                _sendRequest.CreateParameter("@MiningMethod",   SqlDbType.VarChar,  20, _MiningMethod),
                _sendRequest.CreateParameter("@OldWorkplaceID", SqlDbType.VarChar,  50, _OldWorkplaceID),
                _sendRequest.CreateParameter("@activity",       SqlDbType.Int,       0, _activity),
                _sendRequest.CreateParameter("@Facelength",     SqlDbType.Int,       0, _Facelength),
                _sendRequest.CreateParameter("@DrillRig",       SqlDbType.VarChar, 150, _DrillRig),
                _sendRequest.CreateParameter("@DeleteBookings", SqlDbType.Bit,     150, _DeleteBookings)
            };

            StringBuilder tempstring = new StringBuilder();

            foreach (SqlParameter a in _paramCollectionS)
            {
                //x += 1;
                tempstring.AppendLine(a.ParameterName.ToString() + " = " + a.SqlValue.ToString() + ",");
            }

            _sendRequest.ParamCollection = _paramCollectionS;
            clsDataResult DataResults = _sendRequest.ExecuteInstruction();

            if (DataResults.success == false)
            {
                MessageBox.Show(DataResults.Message, "Error sending request!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void LoadReportData()
        {
            if (reportSettings.useShiftsDefault == false)
            {
                _DefaultShift = "N";
            }

            string _topPanels = "";

            if (reportSettings.TopPanels == "Gold")
            {
                _topPanels = "G";
            }

            if (reportSettings.TopPanels == "Cmgt")
            {
                _topPanels = "C";
            }

            if (reportSettings.TopPanels == "Top Panels")
            {
                _topPanels = "T";
            }

            ucGradeReport _ucEfficiency = new ucGradeReport {
                theConnection = ActiveReport.UserCurrentInfo.Connection
            };

            try
            {
                if (reportSettings.Activity.ToString() == "0")
                {
                    _DailyGradeReportData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _DailyGradeReportData.SqlStatement       = "SP_DailyGradeReport";
                    _DailyGradeReportData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _DailyGradeReportData.ResultsTableName   = "DailyGradeReportData";
                    SqlParameter[] _paramCollection1 =
                    {
                        _DailyGradeReportData.CreateParameter("@TheDate",      SqlDbType.DateTime, 50, reportSettings.ReportDate.ToString("yyyy-MM-dd")),
                        _DailyGradeReportData.CreateParameter("@ShiftsNo",     SqlDbType.Int,      10, reportSettings.ShiftsNo),
                        _DailyGradeReportData.CreateParameter("@DefaultShift", SqlDbType.VarChar,   1, _DefaultShift),
                        _DailyGradeReportData.CreateParameter("@PayLimit",     SqlDbType.Int,      10, reportSettings.Paylimit),
                        _DailyGradeReportData.CreateParameter("@CutOffGrade",  SqlDbType.Int,      10, reportSettings.CutOffGrade),
                        _DailyGradeReportData.CreateParameter("@TopPanels",    SqlDbType.VarChar,   1, _topPanels),
                    };
                    _DailyGradeReportData.ParamCollection = _paramCollection1;
                    _DailyGradeReportData.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _DailyGradeReportData.ExecuteInstruction();
                }
                else
                {
                    _DailyGradeReportData.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _DailyGradeReportData.SqlStatement       = "sp_DailyGradeReport_Development";
                    _DailyGradeReportData.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _DailyGradeReportData.ResultsTableName   = "DailyGradeReportData";
                    SqlParameter[] _paramCollection1 =
                    {
                        _DailyGradeReportData.CreateParameter("@TheDate",      SqlDbType.DateTime, 50, reportSettings.ReportDate.ToString("yyyy-MM-dd")),
                        _DailyGradeReportData.CreateParameter("@ShiftsNo",     SqlDbType.Int,      10, reportSettings.ShiftsNo),
                        _DailyGradeReportData.CreateParameter("@DefaultShift", SqlDbType.VarChar,   1, _DefaultShift),
                        _DailyGradeReportData.CreateParameter("@PayLimit",     SqlDbType.Int,      10, reportSettings.Paylimit),
                        _DailyGradeReportData.CreateParameter("@CutOffGrade",  SqlDbType.Int,      10, reportSettings.CutOffGrade),
                    };
                    _DailyGradeReportData.ParamCollection = _paramCollection1;
                    _DailyGradeReportData.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _DailyGradeReportData.ExecuteInstruction();
                }
            }
            catch (Exception _exception)
            {
                throw new ApplicationException("Report Section:Grade Report:" + _exception.Message, _exception);
            }
            if (_DailyGradeReportData.ResultsDataTable.Rows.Count == 0)
            {
                _sysMessagesClass.viewMessage(MessageType.Info, "Grade Report", "No data found for your selection", ButtonTypes.OK, MessageDisplayType.Small);
                ErrFound = true;
            }
        }
        private void createReport(Object theReportSettings)
        {
            Report theReport = new Report();
            ProblemAnalysisReportProperties currentReportSettings  = theReportSettings as ProblemAnalysisReportProperties;
            ucProblemAnalysisReport         _ProblemAnalysisReport = new ucProblemAnalysisReport {
                theConnection = ActiveReport.UserCurrentInfo.Connection
            };

            //DevExpress.XtraEditors.CheckedComboBoxEdit editor = (sender as DevExpress.XtraEditors.CheckedComboBoxEdit);
            //editor.CheckAll();
            TheAvailableText = reportSettings.Available;
            result           = TheAvailableText.Split(',').ToList();

            MWDataManager.clsDataAccess _ProblemAnalysis = new MWDataManager.clsDataAccess();
            _ProblemAnalysis.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
            _ProblemAnalysis.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
            _ProblemAnalysis.SqlStatement       = "DELETE FROM Temp_Problem_Analysis";
            _ProblemAnalysis.queryReturnType    = MWDataManager.ReturnType.longNumber;
            _ProblemAnalysis.ExecuteInstruction();

            foreach (string ProblemCode in result)
            {
                _ProblemAnalysis.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                _ProblemAnalysis.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                _ProblemAnalysis.SqlStatement       = "Insert into Temp_Problem_Analysis Values ('" + UserCurrentInfo.UserID + "', '" + ProblemCode.Trim() + "')";
                _ProblemAnalysis.queryReturnType    = MWDataManager.ReturnType.longNumber;
                _ProblemAnalysis.ExecuteInstruction();
            }

            //DataSet repUserActivitySet = new DataSet();
            //MWDataManager.clsDataAccess _ProblemAnalysis = new MWDataManager.clsDataAccess();

            if (reportSettings.Activity == "Stoping")
            {
                try
                {
                    _ProblemAnalysis.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _ProblemAnalysis.SqlStatement       = "SP_Problem_Analysis_Report_Stp";
                    _ProblemAnalysis.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _ProblemAnalysis.ResultsTableName   = "Problem Analysis Data Stp";

                    SqlParameter[] _paramCollection =
                    {
                        _ProblemAnalysis.CreateParameter("@Period",    SqlDbType.VarChar, 10, reportSettings.Period),
                        _ProblemAnalysis.CreateParameter("@FromMonth", SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsString(reportSettings.FromProdmonth)),
                        _ProblemAnalysis.CreateParameter("@ToMonth",   SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsString(reportSettings.ToProdmonth)),
                        _ProblemAnalysis.CreateParameter("@Section",   SqlDbType.VarChar, 60, reportSettings.NAME),
                        _ProblemAnalysis.CreateParameter("@UserID",    SqlDbType.VarChar, 50, UserCurrentInfo.UserID),
                        _ProblemAnalysis.CreateParameter("@FromDate",  SqlDbType.Date,    50, reportSettings.FromDate),
                        _ProblemAnalysis.CreateParameter("@ToDate",    SqlDbType.Date,    50, reportSettings.ToDate),
                    };

                    _ProblemAnalysis.ParamCollection = _paramCollection;
                    _ProblemAnalysis.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _ProblemAnalysis.ExecuteInstruction();
                }
                catch (Exception _exception)
                {
                    throw new ApplicationException("Report Section:_ProblemAnalysis:" + _exception.Message, _exception);
                }

                DataSet repDataSet = new DataSet();
                repDataSet.Tables.Add(_ProblemAnalysis.ResultsDataTable);
                theReport.RegisterData(repDataSet);

                theReport.Load(TGlobalItems.ReportsFolder + "\\ProblemAnalysisReport_Stp.frx");

                theReport.SetParameterValue("Banner", SysSettings.Banner);
                theReport.SetParameterValue("Prodmonth", TProductionGlobal.ProdMonthAsString(reportSettings.FromProdmonth) + " - " + TProductionGlobal.ProdMonthAsString(reportSettings.ToProdmonth));
                theReport.SetParameterValue("Sections", reportSettings.NAME);
                theReport.SetParameterValue("logo", TGlobalItems.ClientLogo);
                theReport.SetParameterValue("logoMineware", TGlobalItems.CompanyLogo);
            }
            else if (reportSettings.Activity == "Development")
            {
                try
                {
                    _ProblemAnalysis.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _ProblemAnalysis.SqlStatement       = "SP_Problem_Analysis_Report_Dev";
                    _ProblemAnalysis.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    _ProblemAnalysis.ResultsTableName   = "Problem Analysis Data Dev";

                    SqlParameter[] _paramCollection =
                    {
                        _ProblemAnalysis.CreateParameter("@Period",    SqlDbType.VarChar, 10, reportSettings.Period),
                        _ProblemAnalysis.CreateParameter("@FromMonth", SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsString(reportSettings.FromProdmonth)),
                        _ProblemAnalysis.CreateParameter("@ToMonth",   SqlDbType.Int,      0, TProductionGlobal.ProdMonthAsString(reportSettings.ToProdmonth)),
                        _ProblemAnalysis.CreateParameter("@Section",   SqlDbType.VarChar, 60, reportSettings.NAME),
                        _ProblemAnalysis.CreateParameter("@UserID",    SqlDbType.VarChar, 50, UserCurrentInfo.UserID),
                        _ProblemAnalysis.CreateParameter("@FromDate",  SqlDbType.Date,    50, reportSettings.FromDate),
                        _ProblemAnalysis.CreateParameter("@ToDate",    SqlDbType.Date,    50, reportSettings.ToDate),
                    };

                    _ProblemAnalysis.ParamCollection = _paramCollection;
                    _ProblemAnalysis.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _ProblemAnalysis.ExecuteInstruction();
                }
                catch (Exception _exception)
                {
                    throw new ApplicationException("Report Section:_ProblemAnalysis:" + _exception.Message, _exception);
                }

                DataSet repDataSet = new DataSet();
                repDataSet.Tables.Add(_ProblemAnalysis.ResultsDataTable);
                theReport.RegisterData(repDataSet);

                theReport.Load(TGlobalItems.ReportsFolder + "\\ProblemAnalysisReport_Dev.frx");

                theReport.SetParameterValue("Banner", SysSettings.Banner);
                theReport.SetParameterValue("Prodmonth", TProductionGlobal.ProdMonthAsString(reportSettings.FromProdmonth) + " - " + TProductionGlobal.ProdMonthAsString(reportSettings.ToProdmonth));
                theReport.SetParameterValue("Sections", reportSettings.NAME);
            }


            if (TParameters.DesignReport)
            {
                theReport.Design();
                ActiveReport.SetReport = theReport;
                ActiveReport.isDone    = true;
            }
            else
            {
                theReport.Prepare();
                ActiveReport.SetReport = theReport;
                ActiveReport.isDone    = true;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbParent.ItemIndex == -1)
                {
                    ParentID = 0;
                }
                else
                {
                    ParentID = Convert.ToInt32(cmbParent.EditValue.ToString());
                }

                if (table.Rows.Count == 0 && formAction1 == currentAction.caAdd)
                {
                    MWDataManager.clsDataAccess _dbManInsert = new MWDataManager.clsDataAccess();
                    _dbManInsert.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                    _dbManInsert.SqlStatement       = "Select MAX(FIELDID) FIELDID from PlanProt_Fields";
                    _dbManInsert.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _dbManInsert.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbManInsert.ExecuteInstruction();


                    Int32 TheFieldID = Convert.ToInt32(_dbManInsert.ResultsDataTable.Rows[0]["FIELDID"].ToString()) + 1;

                    _dbManInsert.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                    _dbManInsert.SqlStatement       = "Insert into PlanProt_Fields(FieldID, TemplateID,FieldName,FieldType,NoCharacters,NoLines) values('" + TheFieldID + "','" + TempId + "','" + txtFieldName.Text + "','" + cmbFieldType.EditValue.ToString() + "','" + lcCharacters.Text + "','" + lcLines.Text + "')";
                    _dbManInsert.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _dbManInsert.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbManInsert.ExecuteInstruction();

                    MWDataManager.clsDataAccess _dbManFieldName = new MWDataManager.clsDataAccess();
                    _dbManFieldName.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                    _dbManFieldName.SqlStatement     = "select FieldId = FieldID from PlanProt_Fields " +
                                                       "where FieldName = '" + txtFieldName.Text + "'";
                    _dbManFieldName.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                    _dbManFieldName.queryReturnType    = MWDataManager.ReturnType.DataTable;
                    _dbManFieldName.ExecuteInstruction();

                    DataTableReader readerName = new DataTableReader(_dbManFieldName.ResultsDataTable);
                    dtFieldID.Load(readerName);

                    foreach (DataRow dt in dtFieldID.Rows)
                    {
                        FieldValuesFieldID = Convert.ToInt32(dt["FieldId"].ToString());
                    }

                    MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                    _dbMan.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                    _dbMan.SqlStatement       = "sp_PlanProt_TemplateSetupSave";
                    _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                    SqlParameter[] _paramCollection =
                    {
                        _dbMan.CreateParameter("@TemplateID",    SqlDbType.Int,      7, TempId),
                        _dbMan.CreateParameter("@TemplateName",  SqlDbType.VarChar,  7, DBNull.Value),
                        _dbMan.CreateParameter("@Activity",      SqlDbType.Int,      7, DBNull.Value),
                        _dbMan.CreateParameter("@FieldID",       SqlDbType.Int,     50, FieldValuesFieldID),
                        // _dbMan.CreateParameter("@FieldType", SqlDbType.VarChar ,30 ,cmbFieldType.SelectedValue.ToString() ),
                        _dbMan.CreateParameter("@SelectedValue", SqlDbType.VarChar, 50, DBNull.Value),
                        _dbMan.CreateParameter("@MinValue",      SqlDbType.VarChar, 30, DBNull.Value),
                        _dbMan.CreateParameter("@MaxValue",      SqlDbType.VarChar, 30, DBNull.Value),
                        _dbMan.CreateParameter("@RiskRating",    SqlDbType.Int,      3, DBNull.Value),
                        _dbMan.CreateParameter("@ParentID",      SqlDbType.Int,      3, ParentID),
                        _dbMan.CreateParameter("@FrontBack",     SqlDbType.Int,      3,                  2),
                        _dbMan.CreateParameter("@Action",        SqlDbType.Int,      3,                  0),
                        _dbMan.CreateParameter("@FieldUpdate",   SqlDbType.Int,      3,                  0),
                        _dbMan.CreateParameter("@User1",         SqlDbType.VarChar, 50, ""),
                        _dbMan.CreateParameter("@User2",         SqlDbType.VarChar, 50, ""),
                        _dbMan.CreateParameter("@AprovalReq",    SqlDbType.Int,      0, 0)
                    };
                    _dbMan.ParamCollection = _paramCollection;
                    _dbMan.queryReturnType = MWDataManager.ReturnType.DataTable;
                    _dbMan.ExecuteInstruction();

                    MessageBox.Show("Data Saved Successfull", "Data Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (formAction1 == currentAction.caAdd)
                    {
                        Boolean Deleted = false;

                        if (ceDeleted.Checked == true)
                        {
                            Deleted = true;
                        }

                        MWDataManager.clsDataAccess _dbManInsert = new MWDataManager.clsDataAccess();
                        _dbManInsert.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                        _dbManInsert.SqlStatement       = "Insert into PlanProt_Fields(TemplateID,FieldName,FieldType, Deleted) values('" + TempId + "','" + txtFieldName.Text + "','" + cmbFieldType.EditValue.ToString() + "','" + Deleted + "')";
                        _dbManInsert.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                        _dbManInsert.queryReturnType    = MWDataManager.ReturnType.DataTable;
                        _dbManInsert.ExecuteInstruction();

                        MWDataManager.clsDataAccess _dbManFieldName = new MWDataManager.clsDataAccess();
                        _dbManFieldName.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                        _dbManFieldName.SqlStatement     = "select FieldId = FieldID from PlanProt_Fields " +
                                                           "where FieldName = '" + txtFieldName.Text + "'";
                        _dbManFieldName.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                        _dbManFieldName.queryReturnType    = MWDataManager.ReturnType.DataTable;
                        _dbManFieldName.ExecuteInstruction();

                        DataTableReader readerName = new DataTableReader(_dbManFieldName.ResultsDataTable);
                        dtFieldID.Load(readerName);

                        foreach (DataRow dt in dtFieldID.Rows)
                        {
                            FieldValuesFieldID = Convert.ToInt16(dt["FieldId"].ToString());
                        }

                        foreach (DataRow dr in table.Rows)
                        {
                            if (cmbFieldType.Text == "Selection")
                            {
                                Max = dr[1].ToString();
                                Max = "0";
                            }
                            else
                            {
                                Max = dr[1].ToString();
                            }

                            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                            _dbMan.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                            _dbMan.SqlStatement       = "sp_PlanProt_TemplateSetupSave";
                            _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                            SqlParameter[] _paramCollection =
                            {
                                _dbMan.CreateParameter("@TemplateID",    SqlDbType.Int,      7, TempId),
                                _dbMan.CreateParameter("@TemplateName",  SqlDbType.VarChar,  7, " "),
                                _dbMan.CreateParameter("@Activity",      SqlDbType.Int,      7,                                 0),
                                _dbMan.CreateParameter("@FieldID",       SqlDbType.Int,     50, FieldValuesFieldID),
                                // _dbMan.CreateParameter("@FieldType", SqlDbType.VarChar ,30 ,cmbFieldType.SelectedValue.ToString() ),
                                _dbMan.CreateParameter("@SelectedValue", SqlDbType.VarChar, 50, cmbFieldType.EditValue.ToString()),
                                _dbMan.CreateParameter("@MinValue",      SqlDbType.VarChar, 30, dr[0].ToString()),
                                _dbMan.CreateParameter("@MaxValue",      SqlDbType.VarChar, 30, Max),
                                _dbMan.CreateParameter("@RiskRating",    SqlDbType.Int,      3, dr["Risk Rating"].ToString()),
                                _dbMan.CreateParameter("@ParentID",      SqlDbType.Int,      3, ParentID),
                                _dbMan.CreateParameter("@FrontBack",     SqlDbType.Int,      3,                                 2),
                                _dbMan.CreateParameter("@Action",        SqlDbType.Int,      3,                                 0),
                                _dbMan.CreateParameter("@FieldUpdate",   SqlDbType.Int,      3,                                 0),
                                _dbMan.CreateParameter("@User1",         SqlDbType.VarChar, 50, ""),
                                _dbMan.CreateParameter("@User2",         SqlDbType.VarChar, 50, ""),
                                _dbMan.CreateParameter("@AprovalReq",    SqlDbType.Int,      0, 0)
                            };

                            _dbMan.ParamCollection = _paramCollection;
                            _dbMan.queryReturnType = MWDataManager.ReturnType.DataTable;
                            clsDataResult result = _dbMan.ExecuteInstruction();
                        }

                        MessageBox.Show("Data Saved Successfull", "Data Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }


                    else // Forms CurrentAction = Edit
                    {
                        if (checkEdit1.Checked == true)
                        {
                            bool abc = true;
                            MWDataManager.clsDataAccess _dbManInsert = new MWDataManager.clsDataAccess();
                            _dbManInsert.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                            _dbManInsert.SqlStatement       = "Update PlanProt_Fields Set TemplateID = '" + TempId + "' ,FieldName = '" + txtFieldName.Text + "' ,FieldType = '" + cmbFieldType.EditValue.ToString() + "',NoCharacters='" + txtCharacters.Text + "',NoLines='" + txtLines.Text + "',FieldRequired='" + abc + "', Deleted = '" + ceDeleted.Checked + "' where FieldID = '" + FieldID + "' ";
                            _dbManInsert.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                            _dbManInsert.queryReturnType    = MWDataManager.ReturnType.DataTable;
                            _dbManInsert.ExecuteInstruction();
                        }
                        else
                        {
                            bool abc1 = false;
                            MWDataManager.clsDataAccess _dbManInsert = new MWDataManager.clsDataAccess();
                            _dbManInsert.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                            _dbManInsert.SqlStatement       = "Update PlanProt_Fields Set TemplateID = '" + TempId + "' ,FieldName = '" + txtFieldName.Text + "' ,FieldType = '" + cmbFieldType.EditValue.ToString() + "',NoCharacters='" + txtCharacters.Text + "',NoLines='" + txtLines.Text + "',FieldRequired='" + abc1 + "', Deleted = '" + ceDeleted.Checked + "' where FieldID = '" + FieldID + "' ";
                            _dbManInsert.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                            _dbManInsert.queryReturnType    = MWDataManager.ReturnType.DataTable;
                            _dbManInsert.ExecuteInstruction();
                        }

                        MWDataManager.clsDataAccess _dbManFieldName = new MWDataManager.clsDataAccess();
                        _dbManFieldName.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                        _dbManFieldName.SqlStatement     = "select FieldId = FieldID from PlanProt_Fields " +
                                                           "where FieldName = '" + txtFieldName.Text + "' and TemplateID = '" + TempId + "'";
                        _dbManFieldName.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                        _dbManFieldName.queryReturnType    = MWDataManager.ReturnType.DataTable;
                        _dbManFieldName.ExecuteInstruction();

                        DataTableReader readerName = new DataTableReader(_dbManFieldName.ResultsDataTable);
                        dtFieldID.Load(readerName);

                        MWDataManager.clsDataAccess _dbManDelete = new MWDataManager.clsDataAccess();
                        _dbManDelete.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);//ConfigurationSettings.AppSettings["SQLConnectionStr"];
                        _dbManDelete.SqlStatement       = "delete from PlanProt_FieldValue where FieldID = '" + FieldID + "'";
                        _dbManDelete.queryExecutionType = MWDataManager.ExecutionType.GeneralSQLStatement;
                        _dbManDelete.queryReturnType    = MWDataManager.ReturnType.DataTable;
                        _dbManDelete.ExecuteInstruction();


                        foreach (DataRow dt in dtFieldID.Rows)
                        {
                            FieldValuesFieldID = Convert.ToInt32(dt["FieldId"].ToString());
                        }

                        foreach (DataRow dr in table.Rows)
                        {
                            if (cmbFieldType.Text == "Selection")
                            {
                                //Max = dr[1].ToString();
                                Max = "0";
                            }
                            else
                            {
                                Max = dr[1].ToString();
                            }

                            MWDataManager.clsDataAccess _dbMan = new MWDataManager.clsDataAccess();
                            _dbMan.ConnectionString   = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection);
                            _dbMan.SqlStatement       = "sp_PlanProt_TemplateSetupSave";
                            _dbMan.queryExecutionType = MWDataManager.ExecutionType.StoreProcedure;
                            SqlParameter[] _paramCollection =
                            {
                                _dbMan.CreateParameter("@TemplateID",    SqlDbType.Int,      7, TempId),
                                _dbMan.CreateParameter("@TemplateName",  SqlDbType.VarChar,  7, " "),
                                _dbMan.CreateParameter("@Activity",      SqlDbType.Int,      7,                                 0),
                                _dbMan.CreateParameter("@FieldID",       SqlDbType.Int,     50, FieldValuesFieldID),
                                //_dbMan.CreateParameter("@FieldType", SqlDbType.VarChar ,30 ,cmbFieldType.EditValue.ToString() ),
                                _dbMan.CreateParameter("@SelectedValue", SqlDbType.VarChar,  2, cmbFieldType.EditValue.ToString()),
                                _dbMan.CreateParameter("@MinValue",      SqlDbType.VarChar, 50, dr[0].ToString()),
                                _dbMan.CreateParameter("@MaxValue",      SqlDbType.VarChar,  4, Max),
                                _dbMan.CreateParameter("@RiskRating",    SqlDbType.Int,      3, dr["Risk Rating"].ToString()),
                                _dbMan.CreateParameter("@ParentID",      SqlDbType.Int,      3, ParentID),
                                _dbMan.CreateParameter("@FrontBack",     SqlDbType.Int,      3,                                 2),
                                _dbMan.CreateParameter("@Action",        SqlDbType.Int,      3,                                 0),
                                _dbMan.CreateParameter("@FieldUpdate",   SqlDbType.Int,      3,                                 1),
                                _dbMan.CreateParameter("@User1",         SqlDbType.VarChar, 50, ""),
                                _dbMan.CreateParameter("@User2",         SqlDbType.VarChar, 50, ""),
                                _dbMan.CreateParameter("@AprovalReq",    SqlDbType.Int,      0, 0)
                            };

                            _dbMan.ParamCollection = _paramCollection;
                            _dbMan.queryReturnType = MWDataManager.ReturnType.DataTable;
                            clsDataResult result = _dbMan.ExecuteInstruction();
                        }

                        MessageBox.Show("Data Edited Successfull", "Data Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                this.Close();
            }

            catch (SqlException x)
            {
                MessageBox.Show("Data could not be saved" + x.Message.ToString(), "Save Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }