Example #1
0
        /// <summary>
        /// Перерисовака графика
        /// </summary>
        private void CreateChart()
        {
            int WidthDifference  = pbChart.Location.X + chart.Indent + 5;
            int HeightDifference = pbChart.Location.Y + chart.Indent + 10;

            pbChart.Size = new Size(this.Size.Width - WidthDifference, this.Size.Height - HeightDifference);
            StateClass stateClass =
                CalculationDefectsController.GetCurrentStateClass(StateClassController.GetShaft(cbMachines.SelectedItem as Machine),
                                                                  (cbMachines.SelectedItem as Machine).Head);
            List <ResultDiagnostics> resultDiagnostics = new List <ResultDiagnostics>();
            List <Repairs>           repairs           = RepairsController.GetRepairs((cbMachines.SelectedItem as Machine));
            List <ResultForecast>    forecasts         = new List <ResultForecast>();

            if (rbBearing.Checked)
            {
                resultDiagnostics = DiagnosticResultController.GetBearingResult(cbMachines.SelectedItem as Machine);
            }
            else
            {
                resultDiagnostics = DiagnosticResultController.GetShaftResult(cbMachines.SelectedItem as Machine);
            }
            if (rbStandartForecast.Checked)
            {
                forecasts =
                    ForecastController.GetStandartForecast(resultDiagnostics,
                                                           stateClass,
                                                           (cbMachines.SelectedItem as Machine));
            }
            else
            {
                forecasts =
                    ForecastController.GetSimpleForecast(resultDiagnostics,
                                                         stateClass,
                                                         (cbMachines.SelectedItem as Machine));
            }

            chart = new Chart(pbChart.ClientRectangle, resultDiagnostics, forecasts, stateClass, repairs);
            pbChart.Invalidate();
        }
Example #2
0
        public bool Add(Machine value, List <StateClass> ShaftClasses, List <StateClass> BearingClasses)
        {
            StateClassRepos stateClassRepos = new StateClassRepos();
            string          sql             = "start transaction;" +
                                              "insert into `machine` (`marking`,`number`,`speed`,`power`,`countpairs`,`head`) values (" +
                                              "\'" + value.Marking + "\'," + "\'" + value.Number + "\'," + value.Speed + ","
                                              + value.Power + "," + value.CountPairs + "," + value.Head + ");";

            StateClassController.AddShaft(ShaftClasses, ref sql);
            StateClassController.AddBearing(BearingClasses, ref sql);
            //stateClassRepos.AddShaftClasses(ShaftClasses, ref sql);
            //stateClassRepos.AddBearingClasses(BearingClasses, ref sql);
            sql += "commit;";
            string       sqlrb = "rollback;";
            MySqlCommand cmd   = new MySqlCommand();
            MySqlCommand cmdrb = new MySqlCommand();

            using (MySqlConnection conn = DBUtils.GetDBConnection())
            {
                try
                {
                    conn.Open();
                    cmd.Connection  = conn;
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Машина успешно добавлена!");
                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    cmd.CommandText = sqlrb;
                    cmd.ExecuteNonQuery();
                    return(false);
                }
            }
        }