コード例 #1
0
ファイル: FormNuclide.cs プロジェクト: emptytong/dsa-lims
        private void FormNuclide_Load(object sender, EventArgs e)
        {
            tbProtons.KeyPress  += CustomEvents.Integer_KeyPress;
            tbNeutrons.KeyPress += CustomEvents.Integer_KeyPress;
            tbHalflife.KeyPress += CustomEvents.Numeric_KeyPress;

            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("csp_select_nuclide", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ID", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Nuclide with ID " + p["id"] + " was not found");
                        }

                        reader.Read();

                        tbName.Text                      = reader.GetString("name");
                        tbProtons.Text                   = reader.GetString("protons");
                        tbNeutrons.Text                  = reader.GetString("neutrons");
                        cbMetaStable.Checked             = reader.GetBoolean("meta_stable");
                        tbHalflife.Text                  = reader.GetDouble("half_life_year").ToString(Utils.ScientificFormat);
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        tbComment.Text                   = reader.GetString("comment");
                        p["create_date"]                 = reader["create_date"];
                        p["create_id"]                   = reader["create_id"];
                        p["update_date"]                 = reader["update_date"];
                        p["update_id"]                   = reader["update_id"];
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource    = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #2
0
        private void FormGeometry_Load(object sender, EventArgs e)
        {
            tbMinFillHeight.KeyPress += CustomEvents.Numeric_KeyPress;
            tbMaxFillHeight.KeyPress += CustomEvents.Numeric_KeyPress;
            tbVolume.KeyPress        += CustomEvents.Numeric_KeyPress;
            tbRadius.KeyPress        += CustomEvents.Numeric_KeyPress;

            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("csp_select_preparation_geometry", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Geometry with ID " + p["id"] + " was not found");
                        }

                        reader.Read();
                        tbName.Text                      = reader.GetString("name");
                        tbMinFillHeight.Text             = reader.GetDouble("min_fill_height_mm").ToString();
                        tbMaxFillHeight.Text             = reader.GetDouble("max_fill_height_mm").ToString();
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        tbComment.Text                   = reader.GetString("comment");
                        tbVolume.Text                    = reader.GetString("volume_l");
                        tbRadius.Text                    = reader.GetString("radius_mm");
                        p["create_date"]                 = reader.GetDateTime("create_date");
                        p["create_id"]                   = reader.GetGuid("create_id");
                        p["update_date"]                 = reader.GetDateTime("update_date");
                        p["update_id"]                   = reader.GetGuid("update_id");
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource    = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #3
0
        private void FormMunicipality_Load(object sender, EventArgs e)
        {
            tbNumber.KeyPress += CustomEvents.Integer_KeyPress;

            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("select name from county where id = @id", conn);
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@id", p["county_id"]);
                    tbCounty.Text = cmd.ExecuteScalar().ToString();

                    cmd.CommandText = "csp_select_municipality";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Municipality with ID " + p["id"] + " was not found");
                        }

                        reader.Read();

                        tbName.Text   = reader.GetString("name");
                        tbNumber.Text = reader.GetString("municipality_number");
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        p["create_date"] = reader["create_date"];
                        p["create_id"]   = reader["create_id"];
                        p["update_date"] = reader["update_date"];
                        p["update_id"]   = reader["update_id"];
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource    = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #4
0
ファイル: FormSampler.cs プロジェクト: emptytong/dsa-lims
        private void FormSampler_Load(object sender, EventArgs e)
        {
            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    UI.PopulateComboBoxes(conn, "csp_select_persons_short", new SqlParameter[] { }, cboxPersons);

                    UI.PopulateComboBoxes(conn, "csp_select_companies_short", new[] {
                        new SqlParameter("instance_status_level", InstanceStatus.Active)
                    }, cboxCompanies);

                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("csp_select_sampler", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            Common.Log.Error("Sampler with ID " + p["id"] + " was not found");
                            MessageBox.Show("Sampler with ID " + p["id"] + " was not found");
                            Close();
                        }

                        reader.Read();

                        cboxPersons.SelectedValue        = reader.GetGuid("person_id");
                        cboxCompanies.SelectedValue      = reader.GetGuid("company_id");
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        tbComment.Text   = reader.GetString("comment");
                        p["create_date"] = reader["create_date"];
                        p["create_id"]   = reader["create_id"];
                        p["update_date"] = reader["update_date"];
                        p["update_id"]   = reader["update_id"];

                        cboxPersons.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #5
0
        private void FormPreparationMethod_Load(object sender, EventArgs e)
        {
            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("csp_select_preparation_method", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Preparation method with ID " + p["id"] + " was not found");
                        }

                        reader.Read();

                        tbName.Text                      = reader.GetString("name");
                        tbShortName.Text                 = reader.GetString("name_short");
                        tbDescriptionLink.Text           = reader.GetString("description_link");
                        cbDestructive.Checked            = reader.GetBoolean("destructive");
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        tbComment.Text                   = reader.GetString("comment");
                        p["create_date"]                 = reader["create_date"];
                        p["create_id"]                   = reader["create_id"];
                        p["update_date"]                 = reader["update_date"];
                        p["update_id"]                   = reader["update_id"];
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource    = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #6
0
ファイル: FormCompany.cs プロジェクト: emptytong/dsa-lims
        private void FormCompany_Load(object sender, EventArgs e)
        {
            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("csp_select_company", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Company with ID " + p["id"] + " was not found");
                        }

                        reader.Read();
                        tbName.Text    = reader.GetString("name");
                        tbEmail.Text   = reader.GetString("email");
                        tbPhone.Text   = reader.GetString("phone");
                        tbAddress.Text = reader.GetString("address");
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        tbComment.Text   = reader.GetString("comment");
                        p["create_date"] = reader.GetDateTime("create_date");
                        p["create_id"]   = reader.GetGuid("create_id");
                        p["update_date"] = reader.GetDateTime("update_date");
                        p["update_id"]   = reader.GetGuid("update_id");
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource    = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #7
0
ファイル: FormSampler.cs プロジェクト: emptytong/dsa-lims
        public FormSampler()
        {
            InitializeComponent();

            Text = "DSA-Lims - Add sampler";
            using (SqlConnection conn = DB.OpenConnection())
            {
                UI.PopulateComboBoxes(conn, "csp_select_persons_short", new SqlParameter[] { }, cboxPersons);

                UI.PopulateComboBoxes(conn, "csp_select_companies_short", new[] {
                    new SqlParameter("instance_status_level", InstanceStatus.Active)
                }, cboxCompanies);

                cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
            }
            cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
        }
コード例 #8
0
ファイル: FormUser.cs プロジェクト: emptytong/dsa-lims
        private void FormUser_Load(object sender, EventArgs e)
        {
            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    UI.PopulateComboBoxes(conn, "csp_select_persons_short", new SqlParameter[] { }, cboxPersons);

                    UI.PopulateComboBoxes(conn, "csp_select_laboratories_short", new[] {
                        new SqlParameter("@instance_status_level", InstanceStatus.Deleted)
                    }, cboxLaboratory);

                    SqlCommand cmd = new SqlCommand("csp_select_account", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Account with id " + p["id"] + " was not found");
                        }

                        reader.Read();

                        tbUsername.Text                  = reader.GetString("username");
                        cboxPersons.SelectedValue        = reader.GetGuid("person_id");
                        cboxLaboratory.SelectedValue     = reader.GetGuid("laboratory_id");
                        cboxLanguage.Text                = reader.GetString("language_code");
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        p["create_date"]                 = reader["create_date"];
                        p["update_date"]                 = reader["update_date"];
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    UI.PopulateComboBoxes(conn, "csp_select_persons_short", new SqlParameter[] { }, cboxPersons);

                    UI.PopulateComboBoxes(conn, "csp_select_laboratories_short", new[] {
                        new SqlParameter("@instance_status_level", InstanceStatus.Inactive)
                    }, cboxLaboratory);

                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #9
0
        private void FormLaboratory_Load(object sender, EventArgs e)
        {
            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("csp_select_laboratory", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Laboratory with ID " + p["id"] + " was not found");
                        }

                        reader.Read();

                        tbName.Text    = reader.GetString("name");
                        tbPrefix.Text  = reader.GetString("name_prefix");
                        tbAddress.Text = reader.GetString("address");
                        tbEmail.Text   = reader.GetString("email");
                        tbPhone.Text   = reader.GetString("phone");
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        tbComment.Text = reader.GetString("comment");

                        if (DB.IsValidField(reader["laboratory_logo"]))
                        {
                            p["laboratory_logo"]       = (byte[])reader["laboratory_logo"];
                            picLaboratoryLogo.Image    = Image.FromStream(new MemoryStream((byte[])p["laboratory_logo"]));
                            lblLaboratoryLogoSize.Text = picLaboratoryLogo.Image.Width.ToString() + " x " + picLaboratoryLogo.Image.Height.ToString();
                        }
                        else
                        {
                            p["laboratory_logo"] = picLaboratoryLogo.Image = null;
                        }

                        if (DB.IsValidField(reader["accredited_logo"]))
                        {
                            p["accredited_logo"]       = (byte[])reader["accredited_logo"];
                            picAccreditedLogo.Image    = Image.FromStream(new MemoryStream((byte[])p["accredited_logo"]));
                            lblAccreditedLogoSize.Text = picAccreditedLogo.Image.Width.ToString() + " x " + picAccreditedLogo.Image.Height.ToString();
                        }
                        else
                        {
                            p["accredited_logo"] = picAccreditedLogo.Image = null;
                        }

                        p["assignment_counter"] = reader.GetInt32("assignment_counter");
                        p["create_date"]        = reader.GetDateTime("create_date");
                        p["create_id"]          = reader.GetGuid("create_id");
                        p["update_date"]        = reader.GetDateTime("update_date");
                        p["update_id"]          = reader.GetGuid("update_id");
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource    = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }
コード例 #10
0
        private void FormStation_Load(object sender, EventArgs e)
        {
            tbAltitude.KeyPress += CustomEvents.Numeric_KeyPress;

            string NL = Environment.NewLine;

            ttCoords.SetToolTip(lblLatitude, "Latitude, Longitude" + NL + NL
                                + "Formats: " + NL + "61° 34' 12\" N   11° 67' 20\" E" + NL + "61° 34" + Utils.NumberSeparator + "23' N   11° 67" + Utils.NumberSeparator + "33' E"
                                + NL + "61" + Utils.NumberSeparator + "543478 N   11" + Utils.NumberSeparator + "776344 E" + NL + "61" + Utils.NumberSeparator + "543478   -11" + Utils.NumberSeparator + "776344" + NL + NL + "° can be replaced with *");

            ttCoords.SetToolTip(lblLongitude, "Latitude, Longitude" + NL + NL
                                + "Formats: " + NL + "61° 34' 12\" N   11° 67' 20\" E" + NL + "61° 34" + Utils.NumberSeparator + "23' N   11° 67" + Utils.NumberSeparator + "33' E"
                                + NL + "61" + Utils.NumberSeparator + "543478 N   11" + Utils.NumberSeparator + "776344 E" + NL + "61" + Utils.NumberSeparator + "543478   -11" + Utils.NumberSeparator + "776344" + NL + NL + "° can be replaced with *");

            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();

                if (p.ContainsKey("id"))
                {
                    cboxInstanceStatus.DataSource = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);

                    SqlCommand cmd = new SqlCommand("csp_select_station", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", p["id"]);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            throw new Exception("Station with ID " + p["id"] + " was not found");
                        }

                        reader.Read();

                        tbName.Text      = reader.GetString("name");
                        tbLatitude.Text  = reader.GetString("latitude");
                        tbLongitude.Text = reader.GetString("longitude");
                        tbAltitude.Text  = reader.GetString("altitude");
                        cboxInstanceStatus.SelectedValue = reader.GetInt32("instance_status_id");
                        tbComment.Text   = reader.GetString("comment");
                        p["create_date"] = reader["create_date"];
                        p["create_id"]   = reader["create_id"];
                        p["update_date"] = reader["update_date"];
                        p["update_id"]   = reader["update_id"];
                    }
                }
                else
                {
                    cboxInstanceStatus.DataSource    = DB.GetIntLemmata(conn, null, "csp_select_instance_status", false);
                    cboxInstanceStatus.SelectedValue = InstanceStatus.Active;
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }
        }