private void ParametersTextValidated(object sender, System.EventArgs e) { TextBox tb = sender as TextBox; if (tb == null) { return; } UserReportParameter rp = tb.Tag as UserReportParameter; if (rp == null) { return; } try { rp.Value = tb.Text; } catch (ArgumentException ae) { MessageBox.Show(ae.Message, "Invalid Report Parameter"); } }
private void ParametersLeave(object sender, EventArgs e) { ComboBox cb = sender as ComboBox; if (cb == null) { return; } UserReportParameter rp = cb.Tag as UserReportParameter; if (rp == null) { return; } try { rp.Value = cb.Text; } catch (ArgumentException ae) { MessageBox.Show(ae.Message, "Invalid Report Parameter"); } }
public DropdownParameter(UserReportParameter rp) : base(rp) { InitializeComponent(); if (rp != null) { queryLabel.Text = rp.Prompt; // create a label to autosize the combobox Label l = new Label(); l.AutoSize = true; l.Visible = false; int width = 0; foreach (string s in rp.DisplayValues) { l.Text = s; if (width < l.Width) { width = l.Width; } answerDropdown.Items.Add(s); } if (width > 0) { l.Text = "XX"; width += l.Width; // give some extra room for the drop down arrow } else { width = 155; // just force the default } if (rp.DefaultValue != null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < rp.DefaultValue.Length; i++) { if (i > 0) { sb.Append(", "); } sb.Append(rp.DefaultValue[i].ToString()); } answerDropdown.Text = sb.ToString(); } } ClearWarnings(); }
private void saveUserReportParameters(int userReportID, int userId, List <RptParameter> parameters) { ReportProjectDBEntities entities = new ReportProjectDBEntities(); UserReport ur = entities.UserReport.Where(urp => urp.UserReportID == userReportID).First(); foreach (var parm in parameters) { UserReportParameter urp = new UserReportParameter(); urp.UserReport = ur; urp.ReportParameter = entities.ReportParameter.Where(r => r.ReportParameterID == parm.ID).FirstOrDefault(); urp.ParameterValue = parm.DefaultValue; urp.CreatedByUserID = userId; urp.CreatedDate = DateTime.Now; urp.FilterString = parm.FilterString; entities.AddToUserReportParameter(urp); } entities.SaveChanges(); }
public TextboxParameter(UserReportParameter rp) : base(rp) { InitializeComponent(); if (rp != null) { queryLabel.Text = rp.Prompt; if (rp.DefaultValue != null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < rp.DefaultValue.Length; i++) { if (i > 0) { sb.Append(", "); } sb.Append(rp.DefaultValue[i].ToString()); } answerTextbox.Text = sb.ToString(); } } ClearWarnings(); }
public ParameterBase(UserReportParameter rp) { ReportParameter = rp; InitializeComponent(); }