<asp:Button ID="btnHiddenPerson" runat="Server" Style="display: none" /> <ajaxToolKit:ModalPopupExtender ID="mpePerson" runat="server" BackgroundCssClass="modalBackground" TargetControlID="btnHiddenPerson" PopupControlID="Panel1" PopupDragHandleControlID="Panel2" Drag="True"> </ajaxToolKit:ModalPopupExtender> <asp:Panel ID="Panel1" runat="server" CssClass="modalBox" Style="display: none;" BackColor="White" Width="500px"> <asp:ImageButton ID="btnid" runat="server" Height="29px" ImageUrl="~/Image/close.jpg" onclientclick="window.close();" Width="27px" align="right" /> <asp:Panel ID="Panel2" runat="server" CssClass="caption" Style="margin-bottom: 10px; cursor: hand;"> Lot Information </asp:Panel> <asp:HiddenField ID="hidPersonEditIndex" runat="server" Value="-1" /> <div class="divCol"> Report Name</div> <div class="divColLast"> <asp:DropDownList ID="ddlreportname" runat="server" OnSelectedIndexChanged="ddlreportname_OnSelectedIndexChanged" AutoCompleteType="FirstName" MaxLength="64" Width="180"> </asp:DropDownList> <asp:ImageButton ID="ImageButton2" runat="server" Height="19px" ImageUrl="~/Image/refresh.jpg" Width="27px" onclick="Refreshpopup_Click" /> </div> <div class="clearer"> </div> <div class="divCol"> Report Selection</div> <div class="divColLast"> <asp:RadioButton ID="rbncompulsy" runat="server" Text="Compulsary" GroupName="RbnSelected" Enabled="false" /> <asp:RadioButton ID="rbnoptional" runat="server" Text="Optional" GroupName="RbnSelected" Enabled="false" /> </div> <div class="clearer"> </div> <div class="divCol"> Lot No</div> <div class="divColLast"> <asp:TextBox ID="txtLotNo" runat="server" ReadOnly="true" AutoCompleteType="FirstName" MaxLength="64" Width="100"></asp:TextBox> </div> <div class="clearer"> </div> <div style="width: auto; height: 300px; overflow: auto"> <asp:GridView ID="GridView3" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDataBound="GridView3_RowDataBound"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <EditRowStyle BackColor="#999999" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></HeaderStyle> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <SortedAscendingCellStyle BackColor="#E9E7E2" /> <SortedAscendingHeaderStyle BackColor="#506C8C" /> <SortedDescendingCellStyle BackColor="#FFFDF8" /> <SortedDescendingHeaderStyle BackColor="#6F8DAE" /> </asp:GridView> </div> <div style="white-space: nowrap; text-align: center;"> <asp:Button ID="btnSavePerson" runat="server" Text="Save" OnClick="SaveLinewise" CausesValidation="true" /> </div> </asp:Panel>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Show")) { MtrRef_flag = true; int index = Convert.ToInt32(e.CommandArgument.ToString()); DataSet ds = cmncls.GetProjReportName(ddlProjectName.SelectedItem.Text); ddlreportname.DataValueField = "SamId"; ddlreportname.DataTextField = "RepID"; ddlreportname.DataSource = ds; ddlreportname.DataBind(); if (ds.Tables[0].Rows[0]["Compulsary"].ToString() == "True") { rbncompulsy.Checked = true; rbnoptional.Checked = false; } else { rbncompulsy.Checked = false; rbnoptional.Checked = true; } Label LotNo = (Label)GridView1.Rows[index].FindControl("LblLotNo"); Label StartingNo = (Label)GridView1.Rows[index].FindControl("LblStartingNo"); Label EndingNo = (Label)GridView1.Rows[index].FindControl("LblEndingNo"); diffMeterNo = ((Convert.ToInt32(EndingNo.Text)) - (Convert.ToInt32(StartingNo.Text))); LowerVal = (Convert.ToInt32(StartingNo.Text)); UpperVal = (Convert.ToInt32(EndingNo.Text)); txtLotNo.Text = LotNo.Text; GridView3.DataSource = null; GridView3.DataBind(); mpePerson.Show(); } } protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowIndex==0) { ddlMeterNo = new DropDownList(); ddlMeterNo.ID = "ddlMeterNo"; ddlMeterNo.Width = 60; e.Row.Cells[2].Controls.Add(ddlMeterNo); ddlMeterNo.Items.Clear(); ddlMeterNo.Items.Add("Select Metere No"); for (int range = LowerVal; range < UpperVal; range++) { if (!list.Contains(range)) ddlMeterNo.Items.Add(range.ToString()); } } if (e.Row.RowIndex > 0) { for (int i = 0; i < list.Count; i++) { TextBox txtMeterNo = new TextBox(); txtMeterNo.ID = "Meter" + (i + 1).ToString(); txtMeterNo.Width = 50; e.Row.Cells[i + 2].Controls.Add(txtMeterNo); } } } } protected void SaveLinewise(object sender, EventArgs e) { string t=""; TextBox m; try { for(int i=0;i<gridview3.rows[1].cells.count;i++)> { t = GridView3.Rows[1].Cells[i].Text.ToString(); if (t.ToString() == " ") { m = (TextBox)GridView3.Rows[1].Cells[i].FindControl("Meter1"); string o = m.Text.ToString(); } } } catch (Exception ee) { } TextBox Txt = (TextBox)GridView3.Rows[2].Cells[2].FindControl("Meter1"); cmncls.ShowMessage(Txt.Text, this); } protected void Refreshpopup_Click(object sender, ImageClickEventArgs e) { DataSet ds; DataTable dt1 = new DataTable(); using (SqlConnection con = new SqlConnection(strConnString)) { string strQuery = "SELECT ID,Parameter,Required FROM tbl_ParameterStandard where ProjCode = '" + ddlProjectName.SelectedItem.Text + "' And ReportName= '" + ddlreportname.SelectedItem.Text + "'"; SqlCommand cmd = new SqlCommand(strQuery); using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; con.Open(); sda.SelectCommand = cmd; sda.Fill(dt1); } } ds = null; ds = cmncls.GetSampleSize(ddlProjectName.SelectedItem.Text); //get samplesize String str = ds.Tables[0].Rows[0]["SampleSize"].ToString(); int samplesize = Convert.ToInt16(str.ToString()); if (MtrRef_flag == true) { list = new ArrayList(); if (list.Count > 0) list.Clear(); Random rdm = new Random(); int num = 0; for (int i = 0; i < samplesize; i++) { num = Convert.ToInt32(rdm.NextDouble() * diffMeterNo) + (UpperVal - diffMeterNo + 1); if (list.Contains(num)) i--; else list.Add(num); } MtrRef_flag = false; } DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add("Parameter"); dt.Columns.Add("Required"); dt.Columns.Add("MeterNo1"); for (int i = 0; i < list.Count - 1; i++) { dt.Columns.Add("MeterNo " + (i + 2), typeof(string)); dr = dt.NewRow(); } dt.Rows.Add(dr); dr = dt.NewRow(); dt.Rows[0]["Parameter"] = ""; dt.Rows[0]["Required"] = ""; for (int i = 0; i < list.Count - 1; i++) { dt.Rows[0]["MeterNo " + (i + 2)] = list[i].ToString(); } dt.Rows.Add(dr); int inc = 0; int it = 1; dr = dt.NewRow(); while (inc < dt1.Rows.Count) { dr = dt.NewRow(); dt.Rows[it]["Parameter"] = dt1.Rows[inc][1].ToString(); dt.Rows[it]["Required"] = dt1.Rows[inc][2].ToString(); dt.Rows.Add(dr); it++; inc++; } ViewState["CurrentTable"] = dt; GridView3.DataSource = dt; GridView3.DataBind(); mpePerson.Show(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)