<asp:Table runat="server" ID="Table3" BorderColor="Black" BorderWidth="1"> </asp:Table>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { clsdb db = new clsdb(Convert.ToString(Session["sql"])); OleDbConnection dbcon; dbcon = db.connectdb(); dbcon.Open(); String sql = "select username from account"; OleDbDataAdapter da; System.Data.DataSet dset = new System.Data.DataSet(); System.Data.DataTable dt,dtng; da = new System.Data.OleDb.OleDbDataAdapter(sql, dbcon); da.Fill(dset); dt = dset.Tables[0]; loadddl_line(); Label1.Text = (String)dt.Rows[0]["username"]; dtng = new System.Data.DataTable(); dtng.Columns.Add("no"); dtng.Columns.Add("part_no"); dtng.Columns.Add("part_name"); dtng.Columns.Add("qty"); dtng.Columns.Add("cause"); dtng.Columns.Add("remark"); dtng.Columns.Add("actor"); dtng.Columns.Add("cost"); Session["dtng"] = dtng; bindata(); genheadtable(); genaddtable(); loadddl_case(); loaddl_actor(); } } protected void genheadtable() { //--create row table TableRow tbrowh = new TableRow(); tbrowh.ID = "r_h"; tbrowh.Font.Bold = true; Table3.Rows.Add(tbrowh); //--create cell header part no TableCell tbcellpn = new TableCell(); tbcellpn.ID = "h_pn"; tbcellpn.Text = "Part No."; tbcellpn.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellpn.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellpn); //--create cell header part name TableCell tbcellpna = new TableCell(); tbcellpna.ID = "h_pna"; tbcellpna.Text = "Part Name"; tbcellpna.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellpna.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellpna); //--create cell header qty TableCell tbcellqty = new TableCell(); tbcellqty.ID = "h_qty"; tbcellqty.Text = "Q'Ty"; tbcellqty.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellqty.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellqty); //--create cell header unit TableCell tbcellu = new TableCell(); tbcellu.ID = "h_unit"; tbcellu.Text = "Unit"; tbcellu.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellu.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellu); //--Create cell header cause TableCell tbcellca = new TableCell(); tbcellca.ID = "h_ca"; tbcellca.Text = "Cause"; tbcellca.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellca.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellca); //--Create cell header remark TableCell tbcellrm = new TableCell(); tbcellrm.ID = "h_rm"; tbcellrm.Text = "Remark"; tbcellrm.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellrm.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellrm); //--Create cell header actor TableCell tbcellact = new TableCell(); tbcellact.ID = "h_act"; tbcellact.Text = "Actor"; tbcellact.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellact.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellact); //--create cell header vender TableCell tbcellven = new TableCell(); tbcellven.ID = "h_ven"; tbcellven.Text = "Vender"; tbcellven.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellven.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellven); //--create cell header location TableCell tbcelllc = new TableCell(); tbcelllc.ID = "h_lc"; tbcelllc.Text = "L/C"; tbcelllc.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcelllc.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcelllc); //--create cell header cost TableCell tbcellcos = new TableCell(); tbcellcos.ID = "h_cost"; tbcellcos.Text = "Cost"; tbcellcos.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellcos.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellcos); //--create cell header add cause TableCell tbcellac = new TableCell(); tbcellac.ID = "h_ac"; tbcellac.Text = "Add Cause"; tbcellac.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellac.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellac); //--create cell header del cause TableCell tbcelldc = new TableCell(); tbcelldc.ID = "h_dc"; tbcelldc.Text = "Del Cause"; tbcelldc.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcelldc.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcelldc); //--create cell header add list TableCell tbcellal = new TableCell(); tbcellal.ID = "h_al"; tbcellal.Text = "ADD List"; tbcellal.BackColor = System.Drawing.Color.FromName("#CCFF99"); tbcellal.HorizontalAlign = HorizontalAlign.Center; tbrowh.Cells.Add(tbcellal); } protected void genaddtable() { //--create row table TableRow tbrowadd = new TableRow(); tbrowadd.ID = "r_add"; tbrowadd.Font.Bold = true; Table3.Rows.Add(tbrowadd); //--create cell add part no DropDownList ddl_part = new DropDownList(); ddl_part.ID = "ddl_part"; ddl_part.AutoPostBack = true; ddl_part.AppendDataBoundItems = true; TableCell tbcellapn = new TableCell(); tbcellapn.ID = "addpn"; tbcellapn.Controls.Add(ddl_part); tbrowadd.Cells.Add(tbcellapn); //--create cell add part name TextBox tb_partname = new TextBox(); tb_partname.ID = "tb_partname"; tb_partname.ReadOnly = true; tb_partname.Width = 200; TableCell tbcellapna = new TableCell(); tbcellapna.ID = "addpna"; tbcellapna.Controls.Add(tb_partname); tbrowadd.Cells.Add(tbcellapna); //--create cell add qty TextBox tb_qty = new TextBox(); tb_qty.ID = "tb_qty"; tb_qty.Width = 50; TableCell tbcellaq = new TableCell(); tbcellaq.ID = "addqty"; tbcellaq.Controls.Add(tb_qty); tbrowadd.Cells.Add(tbcellaq); //--create cell add unit TextBox tb_unit = new TextBox(); tb_unit.ID = "tb_unit"; tb_unit.Width = 30; tb_unit.ReadOnly = true; TableCell tbcellau = new TableCell(); tbcellau.ID = "addunit"; tbcellau.Controls.Add(tb_unit); tbrowadd.Cells.Add(tbcellau); //--create cell add cause DropDownList ddl_cause = new DropDownList(); ddl_cause.ID = "ddl_cause"; ddl_cause.SelectedIndex = 0; ddl_cause.AppendDataBoundItems = true; TableCell tbcellacause = new TableCell(); tbcellacause.ID = "addcause"; tbcellacause.Controls.Add(ddl_cause); tbrowadd.Cells.Add(tbcellacause); //--create cell add remark TextBox tb_remark = new TextBox(); tb_remark.ID = "tb_remark"; tb_remark.TextMode = TextBoxMode.MultiLine; TableCell tbcellar = new TableCell(); tbcellar.ID = "addremark"; tbcellar.Controls.Add(tb_remark); tbrowadd.Cells.Add(tbcellar); //--create cell add actor DropDownList ddl_actor = new DropDownList(); ddl_actor.ID = "ddl_actor"; ddl_actor.SelectedIndex = 0; ddl_actor.AppendDataBoundItems = true; TableCell tbcellaact = new TableCell(); tbcellaact.ID = "addactor"; tbcellaact.Controls.Add(ddl_actor); tbrowadd.Cells.Add(tbcellaact); //--create cell add vender TextBox tb_ven = new TextBox(); tb_ven.ID = "tb_ven"; tb_ven.ReadOnly = true; TableCell tbcellav = new TableCell(); tbcellav.ID = "addvender"; tbcellav.Controls.Add(tb_ven); tbrowadd.Cells.Add(tbcellav); //--create cell add L/C TextBox tb_lc = new TextBox(); tb_lc.ID = "tb_lc"; tb_lc.ReadOnly = true; tb_lc.Width = 30; TableCell tbcellalc = new TableCell(); tbcellalc.ID = "addlc"; tbcellalc.Controls.Add(tb_lc); tbrowadd.Cells.Add(tbcellalc); //--create add cost TextBox tb_cost = new TextBox(); tb_cost.ID = "tb_cost"; tb_cost.Width = 50; TableCell tbcellacos = new TableCell(); tbcellacos.ID = "addcost"; tbcellacos.Controls.Add(tb_cost); tbrowadd.Cells.Add(tbcellacos); //--create add button add cause Button add_cause = new Button(); add_cause.ID = "bt_addc"; add_cause.Text = "ADD Cause"; TableCell tbcelladdc = new TableCell(); tbcelladdc.ID = "addc"; tbcelladdc.Controls.Add(add_cause); tbrowadd.Cells.Add(tbcelladdc); //--create add button del cause Button del_cause = new Button(); del_cause.ID = "bt_delc"; del_cause.Text = "DEL Cause"; TableCell tbcelldelc = new TableCell(); tbcelldelc.ID = "delc"; tbcelldelc.Controls.Add(del_cause); tbrowadd.Cells.Add(tbcelldelc); //--create add button add list Button add_list = new Button(); add_list.ID = "bt_addl"; add_list.Text = "Add List"; TableCell tbcellal = new TableCell(); tbcellal.ID = "addl"; tbcellal.Controls.Add(add_list); tbrowadd.Cells.Add(tbcellal); } protected void loadddl_line() { clsdb db = new clsdb(Convert.ToString(Session["sql"])); OleDbConnection dbcon; dbcon = db.connectdb(); dbcon.Open(); String sql = "select line_no from dt_line"; OleDbDataAdapter da; 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]; this.ddl_line.Items.Add("Select Model"); this.ddl_line.DataSource = dt; this.ddl_line.DataTextField = "line_no"; this.ddl_line.DataBind(); db.closedb(); } protected void loadddl_case() { clsdb db = new clsdb(Convert.ToString(Session["sql"])); OleDbConnection dbcon; dbcon = db.connectdb(); dbcon.Open(); String sql = "select cause_name from dt_cause"; OleDbDataAdapter da; 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]; ((DropDownList)Table3.Rows[1].Cells[4].FindControl("ddl_cause")).DataSource = dt; ((DropDownList)Table3.Rows[1].Cells[4].FindControl("ddl_cause")).DataTextField = "cause_name"; ((DropDownList)Table3.Rows[1].Cells[4].FindControl("ddl_cause")).DataBind(); db.closedb(); } protected void loaddl_actor() { clsdb db = new clsdb(Convert.ToString(Session["sql"])); OleDbConnection dbcon; dbcon = db.connectdb(); dbcon.Open(); String sql = "select actor_name from dt_actor"; OleDbDataAdapter da; 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]; ((DropDownList)Table3.Rows[1].Cells[6].FindControl("ddl_actor")).DataSource = dt; ((DropDownList)Table3.Rows[1].Cells[6].FindControl("ddl_actor")).DataTextField = "actor_name"; ((DropDownList)Table3.Rows[1].Cells[6].FindControl("ddl_actor")).DataBind(); db.closedb(); } protected void ddl_line_sic(Object sender, EventArgs e) { clsdb db = new clsdb(Convert.ToString(Session["sql"])); OleDbConnection dbcon; dbcon = db.connectdb(); dbcon.Open(); Label2.Visible = true; L_linename.Visible = true; String sql = "select line_name from dt_line where line_no ='" + ddl_line.SelectedItem.Value + "'"; System.Data.OleDb.OleDbDataAdapter da = new OleDbDataAdapter(sql, dbcon); System.Data.DataSet dset = new System.Data.DataSet(); da.Fill(dset); L_linename.Text = " " + (String)dset.Tables[0].Rows[0]["line_name"]; da = null; dset = null; sql = "select * from dt_part where line_no = '" + ddl_line.SelectedItem.Value + "'"; da = new OleDbDataAdapter(); 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)Table3.Rows[1].Cells[0].FindControl("ddl_part")).Items.Count != 0) { ((DropDownList)Table3.Rows[1].Cells[0].FindControl("ddl_part")).Items.RemoveAt(0); } ((DropDownList)Table3.Rows[1].Cells[0].FindControl("ddl_part")).Items.Add("Part NO."); ((DropDownList)Table3.Rows[1].Cells[0].FindControl("ddl_part")).DataSource = dt; ((DropDownList)Table3.Rows[1].Cells[0].FindControl("ddl_part")).DataTextField = "part_no"; ((DropDownList)Table3.Rows[1].Cells[0].FindControl("ddl_part")).DataBind(); da = null; dset = null; dt = null; da = new OleDbDataAdapter(); dset = new System.Data.DataSet(); dt = new System.Data.DataTable(); if (((DropDownList)Table3.Rows[1].Cells[0].FindControl("ddl_part")).SelectedIndex == 0) { } else { sql = "select * from dt_part where part_no = '" + ((DropDownList)Table3.Rows[1].Cells[0].FindControl("ddl_part")).SelectedItem.Value + "'"; da = new System.Data.OleDb.OleDbDataAdapter(sql, dbcon); da.Fill(dset); dt = dset.Tables[0]; ((TextBox)Table3.Rows[1].Cells[1].FindControl("tb_partname")).Text = (String)dt.Rows[0]["part_name"]; db.closedb(); } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง