<asp:GridView ID="gv_addnglist" runat="server" ShowFooter="true" HeaderStyle-BackColor="#CCFF99" HeaderStyle-Font-Bold="True" HeaderStyle-Font-Size="Small" EmptyDataRowStyle-Font-Size="Smaller" DataKeyNames="no" OnRowCommand="commandgv1" OnRowDataBound="rowbound" AutoGenerateColumns="False"> <Columns> <asp:TemplateField HeaderText="No." Visible="false"> <ItemTemplate > <asp:Label ID="no" runat="server" > </asp:Label> </ItemTemplate> <EditItemTemplate > </EditItemTemplate> <FooterTemplate > </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText = "Part No."> <ItemTemplate > <asp:Label ID="part_no" runat="server" > </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:DropDownList ID="ddl_part" runat="server" AutoPostBack="True" AppendDataBoundItems="True" OnSelectedIndexChanged="ddl_part_sic" Font-Size="Smaller"> </asp:DropDownList> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText = "Part Name"> <ItemTemplate > <asp:Label ID="part_name" runat="server"> </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:TextBox ID="tb_partname" runat="server" ReadOnly="True" Width="150" Font-Size="Smaller"></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Q'ty"> <ItemTemplate> <asp:Label ID="qty" runat="server"> </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:TextBox ID="tb_qty" runat="server" Width="50" Font-Size="Smaller"> </asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Unit"> <ItemTemplate> <asp:Label ID="unit" runat="server" > </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate> <asp:TextBox ID="tb_unit" runat="server" Width="30" ReadOnly="true" Font-Size="Smaller"> </asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Cause"> <ItemTemplate > <asp:Label ID="cause" runat="server" > </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:DropDownList ID="ddl_cause" runat="server" Font-Size="Smaller"> </asp:DropDownList> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Remark"> <ItemTemplate > <asp:Label ID="remark" runat="server" Font-Size="Smaller"> </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:TextBox ID="tb_remark" runat="server" TextMode="MultiLine" Font-Size="Smaller"> </asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Actor"> <ItemTemplate > <asp:Label ID="actor" runat="server" > </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:DropDownList ID="ddl_actor" runat="server" Font-Size="Smaller"> </asp:DropDownList> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Vender"> <ItemTemplate > <asp:Label ID="vender" runat="server" > </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:TextBox ID="tb_vender" runat="server" ReadOnly="true" Font-Size="Smaller"> </asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Locat"> <ItemTemplate > <asp:Label ID="lc" runat ="server" > </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:TextBox ID="tb_lc" runat="server" Width="30" ReadOnly="true" Font-Size="Smaller"> </asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Cost/Unit"> <ItemTemplate > <asp:Label ID="cost" runat="server" > </asp:Label> </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:TextBox ID="tb_cost" runat="server" Width="50" Font-Size="Smaller"> </asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Add Cause"> <ItemTemplate > </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:Button ID="bt_addcause" runat="server" Text="ADD Cause" Font-Size="Smaller" Visible="False" OnClick="bt_addcause_click" CommandName="addcause"/> </FooterTemplate> </asp:TemplateField> <asp:ButtonField HeaderText = "Delete" CommandName ="del" Text="delete" ButtonType="Button" Visible="false"> </asp:ButtonField> <asp:TemplateField HeaderText="Add List"> <ItemTemplate > </ItemTemplate> <EditItemTemplate> </EditItemTemplate> <FooterTemplate > <asp:Button ID="bt_addlist" runat="server" Text="ADD List" Font-Size="Smaller" Visible="False" OnClick="bt_addlist_click" CommandName="addlist"/> </FooterTemplate> </asp:TemplateField> </Columns> </asp:GridView>
protected void bt_addcause_click(Object s, EventArgs e) { if (((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).SelectedIndex != 0) { if (((TextBox)gv_addnglist.FooterRow.Cells[0].FindControl("tb_qty")).Text != "") { System.Data.DataRow drows; System.Data.DataTable tng; tng = (System.Data.DataTable)Session["dtng"]; if (tng.Rows[0]["part_no"] == DBNull.Value) { tng.Rows.RemoveAt(0); } drows = tng.NewRow(); int num; num = gennum(tng.Rows.Count); drows["no"] = num; drows["part_no"] = ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).SelectedItem.Value; drows["part_name"] = ((TextBox)gv_addnglist.FooterRow.Cells[1].FindControl("tb_partname")).Text; drows["qty"] = ((TextBox)gv_addnglist.FooterRow.Cells[2].FindControl("tb_qty")).Text; drows["unit"] = ((TextBox)gv_addnglist.FooterRow.Cells[3].FindControl("tb_unit")).Text; drows["cause"] = ((DropDownList)gv_addnglist.FooterRow.Cells[4].FindControl("ddl_cause")).SelectedItem.Value; drows["remark"] = ((TextBox)gv_addnglist.FooterRow.Cells[5].FindControl("tb_remark")).Text; drows["actor"] = ((DropDownList)gv_addnglist.FooterRow.Cells[6].FindControl("ddl_actor")).SelectedItem.Value; drows["vender"] = ((TextBox)gv_addnglist.FooterRow.Cells[7].FindControl("tb_vender")).Text; drows["lc"] = ((TextBox)gv_addnglist.FooterRow.Cells[8].FindControl("tb_lc")).Text; drows["cost"] = ((TextBox)gv_addnglist.FooterRow.Cells[9].FindControl("tb_cost")).Text; tng.Rows.Add(drows); Session["dtng"] = tng; bindatam(); [glow=red]((Button)gv_addnglist.Rows[(num-1)].Cells[11].Controls[0]).Visible = true;[/glow] clsdb db = new clsdb(Convert.ToString(Session["sql"])); OleDbConnection dbcon; dbcon = db.connectdb(); dbcon.Open(); String sql = "select * from dt_part where line_no = '" + ddl_line.SelectedItem.Value + "'"; OleDbDataAdapter da = new OleDbDataAdapter(); System.Data.DataSet dset = new System.Data.DataSet(); System.Data.DataTable dt; da = new System.Data.OleDb.OleDbDataAdapter(sql, dbcon); da.Fill(dset); dt = dset.Tables[0]; while (((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).Items.Count != 0) { ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).Items.RemoveAt(0); } ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).Items.Add("Part NO."); ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).DataSource = dt; ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).DataTextField = "part_no"; ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).DataBind(); loadddl_case(); loaddl_actor(); while (((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).SelectedItem.Value != (String)((System.Data.DataTable)Session["dtng"]).Rows[0]["part_no"]) { ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).SelectedIndex += 1; } ((DropDownList)gv_addnglist.FooterRow.Cells[0].FindControl("ddl_part")).Enabled = false; ((TextBox)gv_addnglist.FooterRow.Cells[1].FindControl("tb_partname")).Text = (String)((System.Data.DataTable)Session["dtng"]).Rows[0]["part_name"]; ((TextBox)gv_addnglist.FooterRow.Cells[3].FindControl("tb_unit")).Text = (String)((System.Data.DataTable)Session["dtng"]).Rows[0]["unit"]; ((TextBox)gv_addnglist.FooterRow.Cells[7].FindControl("tb_vender")).Text = (String)((System.Data.DataTable)Session["dtng"]).Rows[0]["vender"]; ((TextBox)gv_addnglist.FooterRow.Cells[8].FindControl("tb_lc")).Text = (String)((System.Data.DataTable)Session["dtng"]).Rows[0]["lc"]; ((TextBox)gv_addnglist.FooterRow.Cells[9].FindControl("tb_cost")).Text = (String)((System.Data.DataTable)Session["dtng"]).Rows[0]["cost"]; ((Button)gv_addnglist.FooterRow.Cells[10].FindControl("bt_addcause")).Visible = true; ((Button)gv_addnglist.FooterRow.Cells[12].FindControl("bt_addlist")).Visible = true; } } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง