private void create_dt_quantity() { //creating datatable to enter quantity per sample per lab DataTable dt_labs = (DataTable)ViewState["dt_labs"]; DataTable dt_quantity = AddColumns_DataTableQuantity(); foreach (DataRow dr_labs in dt_labs.Rows) { DataRow dr_qty = dt_quantity.NewRow(); long ts_id = Convert.ToInt64(dr_labs["ts_id"]); ds_analytics.test_samplesDataTable ts_dt = test_samples.getTestSampleBy_ts_id(ts_id); dr_qty["labid"] = Convert.ToInt64(dr_labs["labid"]); dr_qty["labname"] = m_labs.getLabByLabid(Convert.ToInt64(dr_labs["labid"]))[0].labname; dr_qty["sampleid"] = ts_dt[0].sampleid; dt_quantity.Rows.Add(dr_qty); } DataView view = new DataView(dt_quantity); dt_quantity = view.ToTable(true, "labid", "labname", "sampleid"); gv_lab_sample_quantity.DataSource = dt_quantity; gv_lab_sample_quantity.DataBind(); ViewState["dt_quantity"] = dt_quantity; ViewState["SortOrder"] = " ASC"; }
private void bind_test_samples() { //Getting req_tests table from the database ds_analytics.req_testsDataTable dt_test = req_tests.getTestsbyReqid(reqid); //Make test_sample DataTable to bind to Gridview DataTable dt_test_sample = new DataTable(); dt_test_sample.Columns.Add(new DataColumn("Test", typeof(System.String))); for (int i = 1; i <= req_samples.countSamplesByReqId(reqid); i++) { dt_test_sample.Columns.Add(new DataColumn(i.ToString(), typeof(System.Boolean))); } //building Datatable for gridview using test_samples in server foreach (ds_analytics.req_testsRow dr in dt_test.Rows) { DataRow dr_new = dt_test_sample.NewRow(); dr_new["Test"] = dr.testname; ds_analytics.test_samplesDataTable ts_dt = test_samples.getTest_SamplesByTestid(dr.test_id); int i = 1; foreach (ds_analytics.test_samplesRow ts_row in ts_dt.Rows) { dr_new[i.ToString()] = ts_row.isselected; i++; } dt_test_sample.Rows.Add(dr_new); } //Databind gv_test_sample.DataSource = dt_test_sample; gv_test_sample.DataBind(); }
protected void gv_ts_lab_selection_RowDataBound(object sender, GridViewRowEventArgs e) { GridView gv = (GridView)sender; if (e.Row.RowType == DataControlRowType.DataRow) { long test_id = Convert.ToInt64(gv.DataKeys[e.Row.RowIndex].Value); for (int i = 2; i <= gv.Columns.Count - 1; i++) { if ((e.Row.Cells[i].Controls[0].GetType() == typeof(Button))) { Button btn = ((Button)e.Row.Cells[i].Controls[0]); if (btn.Visible == true) { btn.Attributes.Add("onmouseover", "mouse_move(" + e.Row.RowIndex + "," + i + ",'over')"); btn.Attributes.Add("onmouseout", "mouse_move(" + e.Row.RowIndex + "," + i + ",'out')"); //e.Row.Cells[i].Attributes.Add("onmouseout", "style.backgroundColor='#FFFFFF'; style.color='black'"); e.Row.Cells[i].ToolTip = "Click to Select Lab to send the Sample " + gv_ts_lab_selection.HeaderRow.Cells[i].Text + " for " + e.Row.Cells[1].Text + " test."; string sampleid = reqid + Convert.ToInt32(gv.Columns[i].HeaderText).ToString("00"); ds_analytics.test_samplesDataTable ts_dt = test_samples.getTestSampleBy_TestidandSampleid(test_id, sampleid); btn.CommandName = "AddLab"; btn.CommandArgument = ts_dt[0]["ts_id"].ToString(); } } } } }
private void bind_test_samples() { //Getting req_tests table from the database ds_analytics.req_testsDataTable dt_test = req_tests.getTestsbyReqid(reqid); //Make test_sample DataTable to bind to Gridview DataTable dt_test_sample = new DataTable(); dt_test_sample.Columns.Add(new DataColumn("Test", typeof(System.String))); for (int i = 1; i <= req_samples.countSamplesByReqId(reqid); i++) { dt_test_sample.Columns.Add(new DataColumn(i.ToString(), typeof(System.String))); } //building Datatable for gridview using test_samples in server foreach (ds_analytics.req_testsRow dr in dt_test.Rows) { DataRow dr_new = dt_test_sample.NewRow(); dr_new["Test"] = dr.testname; ds_analytics.test_samplesDataTable ts_dt = test_samples.getTest_SamplesByTestid(dr.test_id); int i = 1; foreach (ds_analytics.test_samplesRow ts_row in ts_dt.Rows) { if (ts_row.isselected) { //dr_new[i.ToString()] = isPDFrequest ? "True" : "\u2713"; dr_new[i.ToString()] = "True"; } i++; } dt_test_sample.Rows.Add(dr_new); } //Databind gv_test_sample.DataSource = dt_test_sample; gv_test_sample.DataBind(); // Align in center foreach (TableCell cell in gv_test_sample.HeaderRow.Cells) { if (gv_test_sample.HeaderRow.Cells.GetCellIndex(cell) > 0) { cell.Style.Add("text-align", "center"); } } foreach (GridViewRow gvr in gv_test_sample.Rows) { foreach (TableCell cell in gvr.Cells) { if (gvr.Cells.GetCellIndex(cell) > 0) { cell.Style.Add("text-align", "center"); } } } }
protected void gv_labs_RowDataBound(object sender, GridViewRowEventArgs e) { GridView gv = (GridView)sender; if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.CssClass = "row"; long ts_id = Convert.ToInt64(gv.DataKeys[e.Row.RowIndex].Value); ds_analytics.test_samplesDataTable ts_dt = test_samples.getTestSampleBy_ts_id(ts_id); e.Row.Cells[2].Text = req_tests.getTestbyTestid(ts_dt[0].test_id)[0].testname; e.Row.Cells[3].Text = ts_dt[0].sampleid.Substring(8); ((Label)e.Row.Cells[4].FindControl("lbl_labid")).Text = m_labs.getLabByLabid(Convert.ToInt64(((Label)e.Row.Cells[4].FindControl("lbl_labid")).Text))[0].labname; } }
protected void gv_ts_lab_selection_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "AddLab") { Button btn = (Button)e.CommandSource; GridViewRow gvr = (GridViewRow)btn.NamingContainer; //managing footer long ts_id = Convert.ToInt64(e.CommandArgument); ds_analytics.test_samplesDataTable ts_dt = test_samples.getTestSampleBy_ts_id(ts_id); DataTable dt_labs_global = (DataTable)ViewState["dt_labs"]; if (dt_labs_global.Rows.Count > 0) { //Controls in FooterTemplate: very useful (used for lab count also) //invisible gv_labs.FooterRow.Cells[0].Text = ts_dt[0].ts_id.ToString(); gv_labs.FooterRow.Cells[0].ToolTip = gvr.RowIndex.ToString() + "-" + btn.ID; //visible gv_labs.FooterRow.Cells[2].Text = req_tests.getTestbyTestid(ts_dt[0].test_id)[0].testname; gv_labs.FooterRow.Cells[2].ToolTip = ts_dt[0].test_id.ToString(); gv_labs.FooterRow.Cells[3].Text = ts_dt[0].sampleid.Substring(8); gv_labs.FooterRow.Cells[3].ToolTip = ts_dt[0].sampleid; } else { //Controls in EmptyDataTemplate: very useful (used for lab count also) //invisible ((Label)gv_labs.Controls[0].Controls[0].FindControl("lbl_empty_ts_id")).Text = ts_dt[0].ts_id.ToString(); ((Label)gv_labs.Controls[0].Controls[0].FindControl("lbl_empty_ts_id")).ToolTip = gvr.RowIndex.ToString() + "-" + btn.ID; //visible ((Label)gv_labs.Controls[0].Controls[0].FindControl("lbl_empty_test")).Text = req_tests.getTestbyTestid(ts_dt[0].test_id)[0].testname; ((Label)gv_labs.Controls[0].Controls[0].FindControl("lbl_empty_test")).ToolTip = ts_dt[0].test_id.ToString(); ((Label)gv_labs.Controls[0].Controls[0].FindControl("lbl_empty_sample")).Text = ts_dt[0].sampleid.Substring(8); ((Label)gv_labs.Controls[0].Controls[0].FindControl("lbl_empty_sample")).ToolTip = ts_dt[0].sampleid; ((DropDownList)gv_labs.Controls[0].Controls[0].FindControl("dd_empty_lab")).DataSource = m_labs.getAllActiveLabs(); ((DropDownList)gv_labs.Controls[0].Controls[0].FindControl("dd_empty_lab")).DataBind(); } } }
private void build_dt_test_sample() { //Getting req_tests table from the database ds_analytics.req_testsDataTable dt_test = req_tests.getTestsbyReqid(process_reqid); //Make test_sample DataTable to bind to Gridview dt_test_sample = new DataTable(); dt_test_sample.Columns.Add(new DataColumn("test_id", typeof(System.Int64))); dt_test_sample.Columns.Add(new DataColumn("testname", typeof(System.String))); dt_test_sample.Columns.Add(new DataColumn("all", typeof(System.Boolean))); for (int i = 1; i <= no_samples; i++) { dt_test_sample.Columns.Add(new DataColumn(i.ToString(), typeof(System.Boolean))); } //building datatable for gridview foreach (ds_analytics.req_testsRow dr in dt_test.Rows) { DataRow dr_new = dt_test_sample.NewRow(); dr_new["test_id"] = dr.test_id; dr_new["testname"] = dr.testname; bool all_selected = true; ds_analytics.test_samplesDataTable ts_dt = test_samples.getTest_SamplesByTestid(dr.test_id); int i = 1; foreach (ds_analytics.test_samplesRow ts_row in ts_dt.Rows) { dr_new[i.ToString()] = ts_row.isselected; i++; if (!ts_row.isselected) { all_selected = false; } } dr_new["all"] = all_selected; dt_test_sample.Rows.Add(dr_new); } Session["dt_test_sample"] = (DataTable)dt_test_sample; }
private DataTable get_dt_ts_lab_selection() { int no_samples = req_samples.countSamplesByReqId(reqid); //Getting req_tests table from the database ds_analytics.req_testsDataTable dt_test = req_tests.getTestsbyReqid(reqid); //Make test_sample DataTable Columns to bind to Gridview DataTable dt_test_sample = new DataTable(); dt_test_sample.Columns.Add(new DataColumn("test_id", typeof(System.Int64))); dt_test_sample.Columns.Add(new DataColumn("testname", typeof(System.String))); for (int i = 1; i <= no_samples; i++) { dt_test_sample.Columns.Add(new DataColumn(i.ToString(), typeof(System.Boolean))); } //building Datatable for gridview using test_samples in server foreach (ds_analytics.req_testsRow dr in dt_test.Rows) { DataRow dr_new = dt_test_sample.NewRow(); dr_new["test_id"] = dr.test_id; dr_new["testname"] = dr.testname; ds_analytics.test_samplesDataTable ts_dt = test_samples.getTest_SamplesByTestid(dr.test_id); int i = 1; foreach (ds_analytics.test_samplesRow ts_row in ts_dt.Rows) { dr_new[i.ToString()] = ts_row.isselected; i++; } dt_test_sample.Rows.Add(dr_new); } return(dt_test_sample); }