Example #1
0
        public void ExcludeFromAnalytics(short cutId)
        {
            try
            {
                ConnectToMySQL();
                MySqlCommand cmd = new MySqlCommand("spChangeExclude", Connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("in_kCut", cutId);
                cmd.Parameters["in_kCut"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
            }
            finally
            {
                DisconnectFromMySQL();
            }
        }
Example #2
0
        public void CreateImage(short cutId, string imageType, byte[] imageData)
        {
            try
            {
                ConnectToMySQL();
                MySqlCommand cmd = new MySqlCommand("spCreateImage", Connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("in_kCut", cutId);
                cmd.Parameters["in_kCut"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cImageType", imageType);
                cmd.Parameters["in_cImageType"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_xImage", imageData);
                cmd.Parameters["in_xImage"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
            }
            finally
            {
                DisconnectFromMySQL();
            }
        }
Example #3
0
        public void CreateOption(Option option)
        {
            try
            {
                ConnectToMySQL();
                MySqlCommand cmd = new MySqlCommand("spCreateOption", Connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("in_kCut", option.CutId);
                cmd.Parameters["in_kCut"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cKey", option.Key);
                cmd.Parameters["in_cKey"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cUnit", option.Unit);
                cmd.Parameters["in_cUnit"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cValue", option.Value);
                cmd.Parameters["in_cValue"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
            }
            finally
            {
                DisconnectFromMySQL();
            }
        }
Example #4
0
        public void DeleteCut(Cut cut)
        {
            try
            {
                ConnectToMySQL();
                MySqlCommand cmd = new MySqlCommand("spDeleteCut", Connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("in_kAge", cut.Age);
                cmd.Parameters["in_kAge"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cGenotype", cut.Genotype);
                cmd.Parameters["in_cGenotype"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cAnimal", cut.Animal);
                cmd.Parameters["in_cAnimal"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cCutIdentifier", cut.CutIdentifier);
                cmd.Parameters["in_cCutIdentifier"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
            }
            finally
            {
                DisconnectFromMySQL();
            }
        }
Example #5
0
 public static DialogResult Show(int closeTime, string textBtn1, string textBtn2, string message, params object[] args)
 {
     using (MessageBoxAutocloseWithButtons form = new MessageBoxAutocloseWithButtons(closeTime, textBtn1, textBtn2, string.Format(message, args)))
     {
         return(form.ShowDialog());
     }
 }
Example #6
0
 public static DialogResult Show(int closeTime, string textBtn1, string textBtn2, string message)
 {
     using (MessageBoxAutocloseWithButtons form = new MessageBoxAutocloseWithButtons(closeTime, textBtn1, textBtn2, message))
     {
         return(form.ShowDialog());
     }
 }
Example #7
0
 public static DialogResult Show(bool onTop, string textBtn1, string textBtn2, string message, params object[] args)
 {
     using (MessageBoxAutocloseWithButtons form = new MessageBoxAutocloseWithButtons(5, textBtn1, textBtn2, string.Format(message, args)))
     {
         form.TopMost = onTop;
         return(form.ShowDialog());
     }
 }
Example #8
0
 public static DialogResult Show(bool onTop, string textBtn1, string textBtn2, string message)
 {
     using (MessageBoxAutocloseWithButtons form = new MessageBoxAutocloseWithButtons(5, textBtn1, textBtn2, message))
     {
         form.TopMost = onTop;
         return(form.ShowDialog());
     }
 }
Example #9
0
        public void CreateCut(Cut cut)
        {
            DeleteCut(cut);
            try
            {
                ConnectToMySQL();
                MySqlCommand cmd = new MySqlCommand("spCreateCut", Connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("in_kAge", cut.Age);
                cmd.Parameters["in_kAge"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cGenotype", cut.Genotype);
                cmd.Parameters["in_cGenotype"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cAnimal", cut.Animal);
                cmd.Parameters["in_cAnimal"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cCutIdentifier", cut.CutIdentifier);
                cmd.Parameters["in_cCutIdentifier"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cMethod", cut.Method);
                cmd.Parameters["in_cMethod"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_dDateMeasurement", cut.DateMeasurement);
                cmd.Parameters["in_dDateMeasurement"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_dDateStaining", cut.DateStaining);
                cmd.Parameters["in_dDateStaining"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_fZoomFactor", cut.ZoomFactor);
                cmd.Parameters["in_fZoomFactor"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cLayer", cut.Layer);
                cmd.Parameters["in_cLayer"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_cNote", cut.Note);
                cmd.Parameters["in_cNote"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("out_kCut", cut.Id);
                cmd.Parameters["out_kCut"].Direction = ParameterDirection.Output;

                cmd.ExecuteNonQuery();

                cut.Id = Convert.ToInt16(cmd.Parameters["out_kCut"].Value.ToString());
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
            }
            finally
            {
                DisconnectFromMySQL();
            }
        }
Example #10
0
        public List <Point> GetCoordinates(string id)
        {
            List <Point> result = new List <Point>();

            string query = $"SELECT * FROM vCoordinate WHERE kCut = {id}";

            MySqlCommand cmd = new MySqlCommand(query, Connection)
            {
                CommandType = CommandType.Text
            };

            using (MySqlDataReader mySqlDataReader = cmd.ExecuteReader())
            {
                while (mySqlDataReader.Read())
                {
                    try
                    {
                        Point point = new Point();

                        try
                        {
                            point.X = Convert.ToInt32(mySqlDataReader.GetFieldValue <double>(1));
                        }
                        catch (Exception ex)
                        {
                            point.X = 0;
                        }

                        try
                        {
                            point.Y = Convert.ToInt32(mySqlDataReader.GetFieldValue <double>(2));
                        }
                        catch (Exception ex)
                        {
                            point.Y = 0;
                        }

                        result.Add(point);
                    }
                    catch (Exception ex)
                    {
                        MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                            ex.Message);
                    }
                }

                mySqlDataReader.Close();
            }

            return(result);
        }
Example #11
0
        public void CreateCoordinate(short cutId, List <Point> points)
        {
            try
            {
                List <Coordinate> coordinates = new List <Coordinate>();
                foreach (Point point in points)
                {
                    coordinates.Add(new Coordinate(point));
                }

                string jsonCoordinates = JsonConvert.SerializeObject(coordinates);

                ConnectToMySQL();
                MySqlCommand cmd = new MySqlCommand("spCreateCoordinates", Connection)
                {
                    CommandType = CommandType.StoredProcedure
                };

                cmd.Parameters.AddWithValue("in_kCut", cutId);
                cmd.Parameters["in_kCut"].Direction = ParameterDirection.Input;

                cmd.Parameters.AddWithValue("in_jsonCoordinates", jsonCoordinates);
                cmd.Parameters["in_jsonCoordinates"].Direction = ParameterDirection.Input;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
            }
            finally
            {
                DisconnectFromMySQL();
            }
        }
Example #12
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            MySQL mysql = new MySQL();

            Result result_fisPer_1 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "1",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_1_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_1);

            Result result_fisPer_2 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "2",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_2_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_2);

            Result result_fisPer_3 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "3",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_3_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_3);

            Result result_fisPer_4 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "4",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_4_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_4);

            Result result_fisPer_5 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "5",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_5_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_5);

            Result result_fisPer_6 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "6",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_6_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_6);

            Result result_fisPer_7 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "7",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_7_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_7);

            Result result_fisPer_8 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "8",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_8_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_8);

            Result result_fisPer_9 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "9",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_9_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_9);

            Result result_fisPer_10 = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "10",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fisPeri_10_new.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_10);

            if (fisPeri_1_new > 0)
            {
                fissurePeriSum += fisPeri_1_new;
            }

            if (fisPeri_2_new > 0)
            {
                fissurePeriSum += fisPeri_2_new;
            }

            if (fisPeri_3_new > 0)
            {
                fissurePeriSum += fisPeri_3_new;
            }

            if (fisPeri_4_new > 0)
            {
                fissurePeriSum += fisPeri_4_new;
            }

            if (fisPeri_5_new > 0)
            {
                fissurePeriSum += fisPeri_5_new;
            }

            if (fisPeri_6_new > 0)
            {
                fissurePeriSum += fisPeri_6_new;
            }

            if (fisPeri_7_new > 0)
            {
                fissurePeriSum += fisPeri_7_new;
            }

            if (fisPeri_8_new > 0)
            {
                fissurePeriSum += fisPeri_8_new;
            }

            if (fisPeri_9_new > 0)
            {
                fissurePeriSum += fisPeri_9_new;
            }

            if (fisPeri_10_new > 0)
            {
                fissurePeriSum += fisPeri_10_new;
            }

            Result result_fisPer_avg = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "Ø",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = (fissurePeriSum / fissureCount).ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_avg);

            Result result_fisPer_sum = new Result
            {
                CutId      = cut.Id,
                ResultType = "fissure",
                Identifier = "Σ",
                Key        = "perimeter",
                Unit       = "µm",
                Value      = fissurePeriSum.ToString(FormWorker.FLOAT_ACCURACY)
            };

            mysql.CreateResultOnlyValid(result_fisPer_sum);



            if (MessageBoxAutocloseWithButtons.Show(0, true, "No", "Yes",
                                                    $"Show result online?") == DialogResult.Cancel)
            //if (MessageBox.Show("Show result online?", "Result", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Process.Start($"{Config.HomepageBaseUrl}/php/details.php?age={cut.Age}&genotype={cut.Genotype}&animal={cut.Animal}&cutidentifier={cut.CutIdentifier}");
            }


            Close();
        }
Example #13
0
        public List <Cut> GetCut(int minId, int maxId, string orderBy = "kCut")
        {
            List <Cut> result = new List <Cut>();

            try
            {
                string query = $"SELECT * FROM vCut WHERE kCut >= {minId} AND kCut <= {maxId} ORDER BY {orderBy}";

                MySqlCommand cmd = new MySqlCommand(query, Connection)
                {
                    CommandType = CommandType.Text
                };

                using (MySqlDataReader mySqlDataReader = cmd.ExecuteReader())
                {
                    while (mySqlDataReader.Read())
                    {
                        //Cut cut = new Cut();

                        //cut.Id = Convert.ToInt16(mySqlDataReader.GetFieldValue<UInt16>(0));
                        //cut.Age = Convert.ToInt16(mySqlDataReader.GetFieldValue<byte>(1));
                        //cut.Genotype = mySqlDataReader.GetFieldValue<string>(2);
                        //cut.Animal = mySqlDataReader.GetFieldValue<string>(3);
                        //cut.CutIdentifier = mySqlDataReader.GetFieldValue<string>(4);
                        //cut.Method = mySqlDataReader.GetFieldValue<string>(5);

                        //if (DateTime.TryParse(mySqlDataReader.GetValue(6)?.ToString(), out var dateMeasurement))
                        //{
                        //    cut.DateMeasurement = dateMeasurement;
                        //}

                        //if (DateTime.TryParse(mySqlDataReader.GetValue(7)?.ToString(), out var dateStaining))
                        //{
                        //    cut.DateStaining = dateStaining;
                        //}

                        //cut.ZoomFactor = (float) Convert.ToDouble(mySqlDataReader.GetFieldValue<Single>(8));
                        //cut.Layer = mySqlDataReader.GetFieldValue<string>(9);
                        //cut.Note = mySqlDataReader.GetFieldValue<string>(10);

                        //result.Add(cut);

                        try
                        {
                            Cut cut = new Cut();

                            try
                            {
                                cut.Id = Convert.ToInt16(mySqlDataReader.GetFieldValue <UInt16>(0));
                            }
                            catch (Exception ex)
                            {
                                cut.Id = -1;
                            }

                            try
                            {
                                cut.Age = Convert.ToInt16(mySqlDataReader.GetFieldValue <byte>(1));
                            }
                            catch (Exception ex)
                            {
                                cut.Age = -1;
                            }

                            try
                            {
                                cut.Genotype = mySqlDataReader.GetFieldValue <string>(2);
                            }
                            catch (Exception ex)
                            {
                                cut.Genotype = "KO";
                            }

                            try
                            {
                                cut.Animal = mySqlDataReader.GetFieldValue <string>(3);
                            }
                            catch (Exception ex)
                            {
                                cut.Animal = "unknown";
                            }

                            try
                            {
                                cut.CutIdentifier = mySqlDataReader.GetFieldValue <string>(4);
                            }
                            catch (Exception ex)
                            {
                                cut.CutIdentifier = "unknown";
                            }

                            try
                            {
                                cut.Method = mySqlDataReader.GetFieldValue <string>(5);
                            }
                            catch (Exception ex)
                            {
                                cut.Method = "unknown";
                            }

                            try
                            {
                                if (DateTime.TryParse(mySqlDataReader.GetValue(6)?.ToString(), out var dateMeasurement))
                                {
                                    cut.DateMeasurement = dateMeasurement;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                                    ex.Message);
                            }

                            try
                            {
                                if (DateTime.TryParse(mySqlDataReader.GetValue(7)?.ToString(), out var dateStaining))
                                {
                                    cut.DateStaining = dateStaining;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                                    ex.Message);
                            }

                            try
                            {
                                cut.ZoomFactor = (float)Convert.ToDouble(mySqlDataReader.GetFieldValue <Single>(8));
                            }
                            catch (Exception ex)
                            {
                                cut.ZoomFactor = -1;
                            }

                            try
                            {
                                cut.Layer = mySqlDataReader.GetFieldValue <string>(9);
                            }
                            catch (Exception ex)
                            {
                                cut.Layer = "unknown";
                            }

                            try
                            {
                                cut.Note = mySqlDataReader.GetFieldValue <string>(10);
                            }
                            catch (Exception ex)
                            {
                                cut.Note = "unknown";
                            }

                            result.Add(cut);
                        }
                        catch (Exception ex)
                        {
                            MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                                ex.Message);
                        }
                    }

                    mySqlDataReader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
            }

            return(result);
        }
Example #14
0
        public void GetImage(string id, string type, string localFilePath)
        {
            MySQL innerMySql = null;

            try
            {
                if (File.Exists(localFilePath))
                {
                    File.Delete(localFilePath);
                }

                string query = $"SELECT cImage FROM vImage WHERE cType = '{type}' AND kCut = {id}";

                innerMySql           = new MySQL();
                innerMySql._waitTime = _waitTime;
                innerMySql.ConnectToMySQL();

                MySqlCommand cmd = new MySqlCommand(query, innerMySql.Connection);
                cmd.CommandType = CommandType.Text;

                using (MySqlDataReader mySqlDataReader = cmd.ExecuteReader())
                {
                    while (mySqlDataReader.Read())
                    {
                        try
                        {
                            int size      = (int)mySqlDataReader.GetBytes(0, 0, null, 0, 0);
                            var result    = new byte[size];
                            int bytesRead = 0;
                            int curPos    = 0;
                            while (curPos < size)
                            {
                                bytesRead += (int)mySqlDataReader.GetBytes(0, curPos, result, curPos, size - curPos);
                                curPos    += bytesRead;
                            }

                            File.WriteAllBytes(localFilePath, result);
                        }
                        catch (Exception ex)
                        {
                            MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                                ex.Message);
                        }
                    }

                    mySqlDataReader.Close();
                }

                try
                {
                    innerMySql.DisconnectFromMySQL();
                }
                catch (Exception ex)
                {
                    MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                        ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                    ex.Message);
                try
                {
                    innerMySql.DisconnectFromMySQL();
                }
                catch (Exception exInner)
                {
                    MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                        exInner.Message);
                }
            }
            finally
            {
                if (innerMySql != null)
                {
                    try
                    {
                        innerMySql.DisconnectFromMySQL();
                    }
                    catch (Exception ex)
                    {
                        MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                            ex.Message);
                    }
                }
            }
        }
Example #15
0
        public Cut GetCut(string kAge, string cGenoType, string cAnimal, string cCutIdentifier)
        {
            string query = $"SELECT * FROM vCut WHERE kAge = '{kAge}' AND cGenoType = '{cGenoType}' AND cAnimal = '{cAnimal}' AND cCutIdentifier = '{cCutIdentifier}' LIMIT 1";

            MySqlCommand cmd = new MySqlCommand(query, Connection)
            {
                CommandType = CommandType.Text
            };

            using (MySqlDataReader mySqlDataReader = cmd.ExecuteReader())
            {
                while (mySqlDataReader.Read())
                {
                    try
                    {
                        Cut cut = new Cut();

                        try
                        {
                            cut.Id = Convert.ToInt16(mySqlDataReader.GetFieldValue <UInt16>(0));
                        }
                        catch (Exception ex)
                        {
                            cut.Id = -1;
                        }

                        try
                        {
                            cut.Age = Convert.ToInt16(mySqlDataReader.GetFieldValue <byte>(1));
                        }
                        catch (Exception ex)
                        {
                            cut.Age = -1;
                        }

                        try
                        {
                            cut.Genotype = mySqlDataReader.GetFieldValue <string>(2);
                        }
                        catch (Exception ex)
                        {
                            cut.Genotype = "KO";
                        }

                        try
                        {
                            cut.Animal = mySqlDataReader.GetFieldValue <string>(3);
                        }
                        catch (Exception ex)
                        {
                            cut.Animal = "unknown";
                        }

                        try
                        {
                            cut.CutIdentifier = mySqlDataReader.GetFieldValue <string>(4);
                        }
                        catch (Exception ex)
                        {
                            cut.CutIdentifier = "unknown";
                        }

                        try
                        {
                            cut.Method = mySqlDataReader.GetFieldValue <string>(5);
                        }
                        catch (Exception ex)
                        {
                            cut.Method = "unknown";
                        }

                        try
                        {
                            if (DateTime.TryParse(mySqlDataReader.GetValue(6)?.ToString(), out var dateMeasurement))
                            {
                                cut.DateMeasurement = dateMeasurement;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                                ex.Message);
                        }

                        try
                        {
                            if (DateTime.TryParse(mySqlDataReader.GetValue(7)?.ToString(), out var dateStaining))
                            {
                                cut.DateStaining = dateStaining;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                                ex.Message);
                        }

                        try
                        {
                            cut.ZoomFactor = (float)Convert.ToDouble(mySqlDataReader.GetFieldValue <Single>(8));
                        }
                        catch (Exception ex)
                        {
                            cut.ZoomFactor = -1;
                        }

                        try
                        {
                            cut.Layer = mySqlDataReader.GetFieldValue <string>(9);
                        }
                        catch (Exception ex)
                        {
                            cut.Layer = "unknown";
                        }

                        try
                        {
                            cut.Note = mySqlDataReader.GetFieldValue <string>(10);
                        }
                        catch (Exception ex)
                        {
                            cut.Note = "unknown";
                        }

                        return(cut);
                    }
                    catch (Exception ex)
                    {
                        MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                            ex.Message);
                    }
                }

                mySqlDataReader.Close();
            }

            return(null);
        }
Example #16
0
        private void picImage_MouseClick(object sender, MouseEventArgs e)
        {
            int x = e.X;
            int y = e.Y;

            if (_pickEndClicked)
            {
                if (FindNearestPointOnline(x, y, out Point endPoint) == false)
                {
                    MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                        $"No point where found, please pick end point ON line!");
                    //MessageBox.Show("No point where found, please pick end point ON line!");
                    return;
                }

                _pickEndClicked   = false;
                lbladvice.Visible = false;
                picImage.Cursor   = Cursors.Default;
                picZoom.Visible   = false;
                txbEndX.Text      = endPoint.X.ToString();
                txbEndY.Text      = endPoint.Y.ToString();

                DrawEndPoint(endPoint);

                btnPickEnd.Enabled = false;
                txbEndX.Enabled    = false;
                txbEndY.Enabled    = false;
            }

            if (_pickStartClicked)
            {
                if (FindNearestPointOnline(x, y, out Point startPoint) == false)
                {
                    MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Ok", "Cancel",
                                                        $"No point where found, please pick start point ON line!");
                    //MessageBox.Show("No point where found, please pick start point ON line!");
                    return;
                }

                _pickStartClicked = false;
                lbladvice.Visible = false;
                picImage.Cursor   = Cursors.Default;
                picZoom.Visible   = false;
                txbStartX.Text    = startPoint.X.ToString();
                txbStartY.Text    = startPoint.Y.ToString();

                DrawStartPoint(startPoint);

                btnPickStart.Enabled = false;
                txbStartX.Enabled    = false;
                txbStartY.Enabled    = false;

                PickEnd();
            }

            if (string.IsNullOrEmpty(txbStartX.Text) == false &&
                string.IsNullOrEmpty(txbStartY.Text) == false &&
                string.IsNullOrEmpty(txbEndX.Text) == false &&
                string.IsNullOrEmpty(txbEndY.Text) == false)
            {
                int startX = Convert.ToInt32(txbStartX.Text);
                int startY = Convert.ToInt32(txbStartY.Text);
                int endX   = Convert.ToInt32(txbEndX.Text);
                int endY   = Convert.ToInt32(txbEndY.Text);

                DrawLobule(new Point(startX, startY), new Point(endX, endY));

                if (MessageBoxAutocloseWithButtons.Show(_waitTime, true, "Yes", "No",
                                                        $"Is this correct?") == DialogResult.OK)
                //if (MessageBox.Show("Is this correct?", "Check", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Ok();
                }
            }
        }