private void set_page_samples() { ds_analytics.req_samplesDataTable req_samp_dt = req_samples.getSamplesByReqid(process_reqid); //1. Removing extra tabpanels int no_tabs = Convert.ToInt32(Math.Ceiling(no_samples / Convert.ToDouble(no_samples_intab))); while (TabContainer1.Tabs.Count > no_tabs) { TabContainer1.Tabs.RemoveAt(TabContainer1.Tabs.Count - 1); } //2. Removing extra samples from last gridview int sample_inlastgrid = no_samples % no_samples_intab; int columns_tokeep = sample_inlastgrid + 2; //2 columns for Property ID, Name string gv_last = "GridView" + no_tabs.ToString(); //loop through tabcontainer int tab_no = 1; AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabContainer1; foreach (object obj in container.Controls) { if (obj is AjaxControlToolkit.TabPanel) { AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj; { GridView gv = ((GridView)(tabPanel.FindControl("GridView" + tab_no.ToString()))); if ((gv.ID == gv_last) && (sample_inlastgrid != 0)) { while (gv.Columns.Count > columns_tokeep) { //removing extra samples from last tab gv.Columns.RemoveAt(gv.Columns.Count - 1); } } DataTable dt_for_gv = get_dt_for_gv(tab_no, no_samples_intab, gv.Columns.Count - 2, req_samp_dt); //2 columns for Property ID, Name gv.DataSource = dt_for_gv; gv.DataBind(); //setting dropdown in gridview according to the Property value int col_gv = gv.Columns.Count; for (int i = 2; i <= col_gv - 1; i++) { DropDownList ddl_stor = ((DropDownList)(gv.Rows[gv.Rows.Count - 1].Cells[i].Controls[5])); ddl_stor.SelectedValue = dt_for_gv.Rows[gv.Rows.Count - 1][i].ToString(); } } tab_no++; } } }
private void bind_req_samples() { ds_analytics.req_samplesDataTable req_samp_dt = req_samples.getSamplesByReqid(reqid); int no_samples = req_samp_dt.Rows.Count; int no_samples_intab = int.Parse(System.Configuration.ConfigurationManager.AppSettings["no_samples_intab"].ToString()); //removing extra tabpanels int no_tabs = Convert.ToInt32(Math.Ceiling(no_samples / Convert.ToDouble(no_samples_intab))); while (TabContainer1.Tabs.Count > no_tabs) { TabContainer1.Tabs.RemoveAt(TabContainer1.Tabs.Count - 1); } //removing extra samples from last tab int sample_inlastgrid = no_samples % no_samples_intab; int columns_tokeep = sample_inlastgrid + 2; //2 columns for Property ID, Name string gv_last = "GridView" + no_tabs.ToString(); //loop through tabcontainer int tab_no = 1; AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabContainer1; foreach (object obj in container.Controls) { if (obj is AjaxControlToolkit.TabPanel) { AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj; { GridView gv = ((GridView)(tabPanel.FindControl("GridView" + tab_no.ToString()))); if ((gv.ID == gv_last) && (sample_inlastgrid != 0)) { while (gv.Columns.Count > columns_tokeep) { //removing extra samples from last tab gv.Columns.RemoveAt(gv.Columns.Count - 1); } } gv.DataSource = get_dt_for_gv(tab_no, no_samples_intab, gv.Columns.Count - 2, req_samp_dt); //2 columns for Property ID, Name gv.DataBind(); } tab_no++; } } }
private void set_page_samples() { //1. Removing extra tabpanels int no_tabs = Convert.ToInt32(Math.Ceiling(no_samples / Convert.ToDouble(no_samples_intab))); while (TabContainer1.Tabs.Count > no_tabs) { TabContainer1.Tabs.RemoveAt(TabContainer1.Tabs.Count - 1); } //2. Removing extra samples from last gridview int sample_inlastgrid = no_samples % no_samples_intab; int columns_tokeep = sample_inlastgrid + 2; //2 columns for Property ID, Name string gv_last = "GridView" + no_tabs.ToString(); //loop through tabcontainer DataTable dt_properties = other.getProperties(); int tab_no = 1; AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabContainer1; foreach (object obj in container.Controls) { if (obj is AjaxControlToolkit.TabPanel) { AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj; { GridView gv = ((GridView)(tabPanel.FindControl("GridView" + tab_no.ToString()))); if ((gv.ID == gv_last) && (sample_inlastgrid != 0)) { while (gv.Columns.Count > columns_tokeep) { //removing extra samples from last tab gv.Columns.RemoveAt(gv.Columns.Count - 1); } } gv.DataSource = dt_properties; gv.DataBind(); } tab_no++; } } }
protected void btn_submit_Click(object sender, EventArgs e) { if (mode == "edit") { //update existing request data #region Request //1. update request process_req_row.projectid = Convert.ToInt64(ddl_project.SelectedValue); process_req_row.analysistype = ddl_typeanalysis.SelectedValue; process_req_row.reqtype = ddl_typerequest.SelectedValue; process_req_row.responsible = ddl_lead.SelectedValue; process_req_row.statusid = 2; process_req_row.req_cmnt = tb_addinfo.Text; requests.update_Request(process_req_row); #endregion #region Samples //2. update sample values int tab_no = 1; AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabContainer1; foreach (object obj in container.Controls) { if (obj is AjaxControlToolkit.TabPanel) { AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj; { GridView gv = ((GridView)(tabPanel.FindControl("GridView" + tab_no.ToString()))); int cols = gv.Columns.Count; for (int i_col = 2; i_col < cols; i_col++) { int sampleno = Convert.ToInt32(gv.Columns[i_col].HeaderText.Substring(6)); string sampleid = String.Concat(process_reqid, sampleno.ToString("00")); //insert a row in req_samples table String value = ""; int propertyid; foreach (GridViewRow gvr in gv.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { propertyid = Convert.ToInt32(gvr.Cells[0].Text); if (gvr.RowIndex != 11) { value = ((TextBox)(gvr.Cells[i_col].Controls[1])).Text; } else { value = ((DropDownList)(gvr.Cells[i_col].Controls[5])).SelectedValue; } //update a row in sample_pvalue table sample_pvalue.updateSample_Pvalue(sampleid, propertyid, value); } } } } tab_no++; } } #endregion #region Tests foreach (GridViewRow gvr in gv_tests.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { long test_id = Convert.ToInt64(gv_tests.DataKeys[gvr.RowIndex].Value); string testname = ((TextBox)gvr.FindControl("tb_testname")).Text; string reference = ((DropDownList)gvr.FindControl("dd_specification")).SelectedValue; string standard = ((TextBox)gvr.FindControl("tb_standard")).Text; string unit = ((TextBox)gvr.FindControl("tb_unit")).Text; //Update Test Details in req_tests table req_tests.update_Req_Tests(testname, reference, standard, unit, test_id); } } #endregion #region Test_Samples if (!is_test_sample_selected()) { string errorText = "You have not selected the samples for all tests. You should select at least one sample for each test."; ClientScriptManager cs = Page.ClientScript; cs.RegisterStartupScript(this.GetType(), "error", "<script>alert('" + errorText + "');</script>"); } else if (gv_test_sample.EditIndex == -1) { dt_test_sample = (DataTable)Session["dt_test_sample"]; foreach (DataRow dr in dt_test_sample.Rows) { long test_id = Convert.ToInt64(dr["test_id"]); for (int no = 3; no <= dt_test_sample.Columns.Count - 1; no++) { bool isselected = Convert.ToBoolean(dr[no]); string sampleid = process_reqid + (no - 2).ToString("00"); //update test_sample test_samples.updateTest_Sample(test_id, sampleid, isselected); } } //redirect string url = "home.aspx"; ClientScript.RegisterStartupScript(this.GetType(), "callfunction", "alert('Updated Request Submitted Successfully.');window.location.href = '" + url + "';", true); } else { string errorText = "Error: Selection of Samples for Test is not correct. Please ensure you have selected samples for each test."; ClientScriptManager cs = Page.ClientScript; cs.RegisterStartupScript(this.GetType(), "error", "<script>alert('" + errorText + "');</script>"); } #endregion //mail do_mail(mode, process_req_row.reqid); } else if (mode == "copy") { if (!is_test_sample_selected()) { string errorText = "You have not selected the samples for all tests. You should select at least one sample for each test."; ClientScriptManager cs = Page.ClientScript; cs.RegisterStartupScript(this.GetType(), "error", "<script>alert('" + errorText + "');</script>"); } else if (gv_test_sample.EditIndex == -1) { //insert new request data #region Request string new_reqid = requests.get_new_reqid(); //Insert Request Details + add info requests.insert_request(new_reqid, Convert.ToInt64(ddl_project.SelectedValue), ddl_typeanalysis.SelectedValue, ddl_typerequest.SelectedValue, userid, ddl_lead.SelectedValue, ddl_lead.SelectedValue, null, 2, tb_addinfo.Text); #endregion #region Samples int tab_no = 1; AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)TabContainer1; foreach (object obj in container.Controls) { if (obj is AjaxControlToolkit.TabPanel) { AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj; { GridView gv = ((GridView)(tabPanel.FindControl("GridView" + tab_no.ToString()))); int cols = gv.Columns.Count; for (int i_col = 2; i_col < cols; i_col++) { int sampleno = Convert.ToInt32(gv.Columns[i_col].HeaderText.Substring(6)); string sampleid = String.Concat(new_reqid, sampleno.ToString("00")); //insert a row in req_samples table req_samples.insert_Req_Samples(sampleid, new_reqid, sampleno, true); String value = ""; int propertyid; foreach (GridViewRow gvr in gv.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { propertyid = Convert.ToInt32(gvr.Cells[0].Text); if (gvr.RowIndex != 11) { value = ((TextBox)(gvr.Cells[i_col].Controls[1])).Text; } else { value = ((DropDownList)(gvr.Cells[i_col].Controls[5])).SelectedValue; } //insert a row in sample_pvalue table sample_pvalue.insertSample_Pvalue(sampleid, propertyid, value); } } } } tab_no++; } } #endregion #region Tests foreach (GridViewRow gvr in gv_tests.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { string testname = ((TextBox)gvr.FindControl("tb_testname")).Text; string reference = ((DropDownList)gvr.FindControl("dd_specification")).SelectedValue; string standard = ((TextBox)gvr.FindControl("tb_standard")).Text; string unit = ((TextBox)gvr.FindControl("tb_unit")).Text; //Insert Test Details in req_tests table long?test_id = req_tests.insert_Req_Tests(new_reqid, testname, reference, standard, unit); if (test_id.HasValue) { #region Test-Samples dt_test_sample = (DataTable)Session["dt_test_sample"]; for (int no = 3; no <= dt_test_sample.Columns.Count - 1; no++) { //in copy request "dt_test_sample" has one extra column named test_id bool isselected = Convert.ToBoolean(dt_test_sample.Rows[gvr.RowIndex][no]); string sampleid = new_reqid + (no - 2).ToString("00"); //Insert Test-Samples Selected in test_samples table test_samples.insertTest_Sample(test_id, sampleid, isselected); } #endregion } } } #endregion //mail do_mail(mode, new_reqid); //redirect string url = "home.aspx"; ClientScript.RegisterStartupScript(this.GetType(), "callfunction", "alert('Request Submitted Successfully.');window.location.href = '" + url + "';", true); } else { string errorText = "You have not selected the samples for tests appropriately. You should select at least one sample for each test."; ClientScriptManager cs = Page.ClientScript; cs.RegisterStartupScript(this.GetType(), "error", "<script>alert('" + errorText + "');</script>"); } } }
//Dataset value to each control on panel, a part of form design public void SetPanelControlValue(TabPanel oPanel, DataSet oDSFields) { if (oDSFields.Tables.Count > 0) { if (oDSFields.Tables[0].Rows.Count > 0) { for (int n = 0; n <= oDSFields.Tables[0].Columns.Count - 1; n++) { String ControlName = oDSFields.Tables[0].Columns[n].ToString(); System.Web.UI.Control oCnt = oPanel.FindControl(ControlName); if (oCnt != null) { if (oCnt is TextBox) { TextBox oTextBox = (TextBox)oCnt; //Check Read only if (oTextBoxList != null) { if (IsNotDefaultSeasonID) { oTextBox.Enabled = false; } if (oDSFields.Tables[0].Rows[0][ControlName].ToString() != null) { if (oDSFields.Tables[0].Rows[0][ControlName].ToString() != string.Empty) { String sText = oDSFields.Tables[0].Rows[0][ControlName].ToString(); oTextBox.Text = HttpUtility.HtmlDecode(sText); } else { oTextBox.Text = string.Empty; } } } } else if (oCnt is DropDownList) { DropDownList oDDL = (DropDownList)oCnt; //if (IsNotDefaultSeasonID) //{ // oDDL.Enabled = false; //} for (int i = 0; i <= oDDL.Items.Count - 1; i++) if (oDSFields.Tables[0].Rows[0][ControlName] != null) { if (oDSFields.Tables[0].Rows[0][ControlName].ToString() != string.Empty) { if (oDDL.Items[i].Value == oDSFields.Tables[0].Rows[0][ControlName].ToString()) { oDDL.SelectedIndex = i; break; } } } } else if (oCnt is CheckBox) { CheckBox oCk = (CheckBox)oCnt; if (IsNotDefaultSeasonID) { oCk.Enabled = false; } if (oDSFields.Tables[0].Rows[0][ControlName] != null) { if (oDSFields.Tables[0].Rows[0][ControlName].ToString() != string.Empty) { if (Convert.ToBoolean(oDSFields.Tables[0].Rows[0][ControlName]) == true) { oCk.Checked = true; } else { oCk.Checked = false; } } } //oCk.Checked = true; } } } } } }
public static void SetDataToControls(TabPanel oPanel, DataTable oDT, int eFormID) { foreach (System.Web.UI.Control oControl in oPanel.Controls) { for (int n = 0; n <= oDT.Columns.Count - 1; n++) { string ColumnName = oDT.Columns[n].ColumnName; Control oWControl = oPanel.FindControl("txtEform" + ColumnName )as Control; if (oWControl != null) { TextBox oText = oWControl as TextBox; oText.Text = oDT.Rows[0][ColumnName].ToString(); } Control oOtherControl = oPanel.FindControl( ColumnName) as Control; if (oOtherControl != null) { if (oOtherControl is TextBox) { TextBox oText = oOtherControl as TextBox; oText.Text = oDT.Rows[0][ColumnName].ToString(); } else if (oOtherControl is DropDownList) { DropDownList oDDL = oOtherControl as DropDownList; oDDL.SelectedValue = oDT.Rows[0][ColumnName].ToString(); } else if (oOtherControl is CheckBox) { CheckBox oChk = oOtherControl as CheckBox; if (oDT.Rows[0][ColumnName].ToString() != string.Empty ) { if (Convert.ToBoolean(oDT.Rows[0][ColumnName]) == false) { oChk.Checked = false; } else { oChk.Checked = true; } } } else if (oOtherControl is UserControl ) { if (oDT.Rows[0][ColumnName] != null) { if (oDT.Rows[0][ColumnName].ToString() != string.Empty) { if (HttpContext.Current.Session[ImageList] == null) { Hashtable oImageValue = new Hashtable(); oImageValue.Add(oOtherControl.ClientID, oDT.Rows[0][ColumnName].ToString()); HttpContext.Current.Session[ImageList] = oImageValue; ucImageControl oImage = oOtherControl as ucImageControl; HttpContext.Current.Session[FormDesign.SessionImageList] = oImageValue; oImage.SetImagePath(); } else { if (oDT.Rows[0][ColumnName] != null) { Hashtable oImageValue = HttpContext.Current.Session[ImageList] as Hashtable; if (!oImageValue.ContainsKey(oOtherControl.ClientID)) { oImageValue.Add(oOtherControl.ClientID, oDT.Rows[0][ColumnName].ToString()); HttpContext.Current.Session[ImageList] = oImageValue; HttpContext.Current.Session[FormDesign.SessionImageList] = oImageValue; ucImageControl oImage = oOtherControl as ucImageControl ; oImage.SetImagePath(); } } } } } } } } } }