예제 #1
0
        private void cboxSampleParameterNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            tbSampleParameterValue.Text = "";

            if (cboxSampleParameterNames.SelectedItem == null)
            {
                return;
            }

            tbSampleParameterValue.KeyPress -= CustomEvents.Integer_KeyPress;
            tbSampleParameterValue.KeyPress -= CustomEvents.Numeric_KeyPress;

            SampleParameterName spn = cboxSampleParameterNames.SelectedItem as SampleParameterName;

            switch (spn.Type)
            {
            case SampleParameterType.Integer:
                tbSampleParameterValue.KeyPress += CustomEvents.Integer_KeyPress;
                break;

            case SampleParameterType.Decimal:
                tbSampleParameterValue.KeyPress += CustomEvents.Numeric_KeyPress;
                break;
            }

            lblTypeInfo.Text = "Parameter type: " + spn.Type;
        }
예제 #2
0
        private void FormSampleParameter_Load(object sender, EventArgs e)
        {
            lblTypeInfo.Text = "";

            SampleParameterName spn = new SampleParameterName();

            spn.Id   = Guid.Empty;
            spn.Name = "";
            spn.Type = "";
            cboxSampleParameterNames.Items.Add(spn);

            SqlConnection conn = null;

            try
            {
                conn = DB.OpenConnection();
                SqlDataReader reader = DB.GetDataReader(conn, null, "select id, name, type from sample_parameter_name order by name", CommandType.Text);
                while (reader.Read())
                {
                    spn      = new SampleParameterName();
                    spn.Id   = reader.GetGuid("id");
                    spn.Name = reader.GetString("name");
                    spn.Type = reader.GetString("type");
                    cboxSampleParameterNames.Items.Add(spn);
                }
            }
            catch (Exception ex)
            {
                Common.Log.Error(ex);
                MessageBox.Show(ex.Message);
                DialogResult = DialogResult.Abort;
                Close();
            }
            finally
            {
                conn?.Close();
            }

            cboxSampleParameterNames.DisplayMember = "Name";
            cboxSampleParameterNames.ValueMember   = "Id";

            if (mSPId != Guid.Empty)
            {
                SampleParameter p = mSample.Parameters.Find(x => x.Id == mSPId);
                cboxSampleParameterNames.Text    = p.Name;
                cboxSampleParameterNames.Enabled = false;
                tbSampleParameterValue.Text      = p.Value;
                lblTypeInfo.Text = "Parameter type: " + p.Type;
            }
        }
예제 #3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            SampleParameterName spn = cboxSampleParameterNames.SelectedItem as SampleParameterName;

            if (spn.Id == Guid.Empty)
            {
                MessageBox.Show("You must select a valid parameter type");
                return;
            }

            if (string.IsNullOrEmpty(tbSampleParameterValue.Text.Trim()))
            {
                MessageBox.Show("You must provide a value for this parameter");
                return;
            }

            if (mSPId == Guid.Empty)
            {
                if (mSample.Parameters.Exists(x => x.SampleId == mSample.Id && x.SampleParameterNameId == spn.Id))
                {
                    MessageBox.Show("This sample already have this parameter");
                    return;
                }

                SampleParameter p = new SampleParameter();
                p.SampleId = mSample.Id;
                p.SampleParameterNameId = spn.Id;
                p.Name  = spn.Name;
                p.Type  = spn.Type;
                p.Value = tbSampleParameterValue.Text.ToString();
                mSample.Parameters.Add(p);
                p.Dirty = true;
            }
            else
            {
                SampleParameter p = mSample.Parameters.Find(x => x.Id == mSPId);
                p.Value = tbSampleParameterValue.Text.ToString();
                p.Dirty = true;
            }

            DialogResult = DialogResult.OK;
            Close();
        }