private void SetInitialRow() { DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(new DataColumn("No.", typeof(string))); dt.Columns.Add(new DataColumn("Date", typeof(string))); dt.Columns.Add(new DataColumn("Type", typeof(string))); dt.Columns.Add(new DataColumn("Amount", typeof(string))); dt.Columns.Add(new DataColumn("Remarks", typeof(string))); dt.Columns.Add(new DataColumn("Image", typeof(string))); dr = dt.NewRow(); dr["No."] = 1; dr["Date"] = string.Empty; dr["Type"] = string.Empty; dr["Amount"] = string.Empty; dr["Remarks"] = string.Empty; dr["Image"] = string.Empty; dt.Rows.Add(dr); ViewState["CurrentTable"] = dt; Gridview3.DataSource = dt; Gridview3.Columns[6].Visible = false; Gridview3.DataBind(); MultiView1.ActiveViewIndex = 2; }
protected void bt_Delete_Click(object sender, ImageClickEventArgs e) { try { ImageButton lb = (ImageButton)sender; GridViewRow gvRow = (GridViewRow)lb.NamingContainer; if (gvRow != null) { int RowIndex = gvRow.RowIndex; DropDownList ddl_ItemList = gvRow.FindControl("ddl_ItemList") as DropDownList; if (ViewState["CurrentTable"] != null && ((DataTable)ViewState["CurrentTable"]).Rows.Count > 0) { ((DataTable)ViewState["CurrentTable"]).Rows.RemoveAt(RowIndex); DataTable dt = new DataTable(); dt = (DataTable)ViewState["CurrentTable"]; Gridview3.DataSource = dt; Gridview3.DataBind(); EnableTextBoxGird3(); SetPreviousData(); } } } catch (Exception ex) { var message = new JavaScriptSerializer().Serialize(ex.Message.ToString()); var script = string.Format("alert({0});", message); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true); } }
protected void LinkButton2_Click(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; GridViewRow gvRow = (GridViewRow)lb.NamingContainer; Label box1 = (Label)gvRow.FindControl("Label16"); string box = box1.Text; int rowID = gvRow.RowIndex + 1; if (ViewState["CurrentTable"] != null) { DataTable dt = (DataTable)ViewState["CurrentTable"]; if (dt.Rows.Count > 1) { if (gvRow.RowIndex < dt.Rows.Count - 1) { dt.Rows.Remove(dt.Rows[rowID]); if (box != "") { File.Delete(Server.MapPath(@"" + box + "")); } } if (dt.Rows.Count <= 1) { Gridview3.Columns[6].Visible = false; } } ViewState["CurrentTable"] = dt; Gridview3.DataSource = dt; Gridview3.DataBind(); MultiView1.ActiveViewIndex = 2; } SetPreviousData(); }
protected void BCancelar_Click(object sender, EventArgs e) { // listarTablapersonalizada(); Gridview3.Visible = true; DataSet ds = new DataSet(); // EscondeControl(); ds = objNeNombreApellidoProf.negListadoNombreApellido(); if (ds.Tables[0].Rows.Count > 0) { Gridview3.DataSource = ds.Tables[0]; Gridview3.DataBind(); //PListadoEstudiante.Visible = true; } else { Response.Write("<script>window.alert('AVISO: No existen registros.')</script>"); } // Gridview3.Visible = false; }
protected void Gridview3_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView theGrid = sender as GridView; // refer to the GridView int newPageIndex = 0; if (-2 == e.NewPageIndex) { TextBox txtNewPageIndex = null; GridViewRow pagerRow = Gridview3.BottomPagerRow; if (null != pagerRow) { txtNewPageIndex = (TextBox)pagerRow.FindControl("textbox"); // refer to the TextBox with the NewPageIndex value } if (null != txtNewPageIndex && txtNewPageIndex.Text != "") { newPageIndex = int.Parse(txtNewPageIndex.Text) - 1; // get the NewPageIndex } } else { newPageIndex = e.NewPageIndex; } string condition = GetCondition(); BindGridview3(condition); Gridview3.DataBind(); newPageIndex = newPageIndex < 0 ? 0 : newPageIndex; newPageIndex = newPageIndex >= Gridview3.PageCount ? Gridview3.PageCount - 1 : newPageIndex; Gridview3.PageIndex = newPageIndex; Gridview3.DataBind(); }
//绑定订单 protected void BindOrder() { string temp = " and PMPO_PurchaseOrderID like'%" + Label6.Text.ToString().Trim() + "%'"; Gridview3.DataSource = pp.Select_Order_Main(temp); Gridview3.DataBind(); UpdatePanel_PMPurchaseOrder.Update(); }
private void AddNewRowToGrid() { int rowIndex = 0; if (ViewState["CurrentTable"] != null) { DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"]; DataRow drCurrentRow = null; if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { TextBox box1 = (TextBox)Gridview3.Rows[rowIndex].Cells[2].FindControl("TextBox5"); DropDownList box2 = (DropDownList)Gridview3.Rows[rowIndex].Cells[3].FindControl("DropDownList3"); TextBox box4 = (TextBox)Gridview3.Rows[rowIndex].Cells[4].FindControl("TextBox6"); TextBox box6 = (TextBox)Gridview3.Rows[rowIndex].Cells[5].FindControl("TextBox7"); FileUpload box7 = (FileUpload)Gridview3.Rows[rowIndex].Cells[6].FindControl("FileUpload1"); Label box8 = (Label)Gridview3.Rows[rowIndex].Cells[6].FindControl("Label16"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["No."] = i + 1; drCurrentRow["Date"] = box1.Text; drCurrentRow["Type"] = box2.Text; drCurrentRow["Amount"] = box4.Text; drCurrentRow["Remarks"] = box6.Text; string image = box7.FileName; string path = Server.MapPath("claimimage"); string apath = path + "\\" + image; box7.SaveAs(apath); string sqlpath = "claimimage\\" + image; if (sqlpath != "claimimage\\") { drCurrentRow["Image"] = sqlpath; } else { drCurrentRow["Image"] = ""; } rowIndex++; } dtCurrentTable.Rows.Add(drCurrentRow); ViewState["CurrentTable"] = dtCurrentTable; Gridview3.DataSource = dtCurrentTable; Gridview3.Columns[6].Visible = true; Gridview3.DataBind(); MultiView1.ActiveViewIndex = 2; } } else { Response.Write("ViewState is null"); } SetPreviousData(); }
//protected void CurrentYearMonthBound() //{ // try // { // DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance(null); // for (int i = 0; i < Gridview3.Rows.Count; i++) // { // DropDownList lb_Date = (DropDownList)Gridview3.Rows[i].Cells[7].FindControl("lb_Date"); // for (int j = 1; j < 13; j++) // { // lb_Date.Items.Add(new ListItem(info.GetMonthName(j) + " - " + DateTime.Now.Year.ToString(), j.ToString())); // } // lb_Date.Items.Insert(0, new ListItem("-Select-", "0")); // } // } // catch (Exception ex) // { // throw ex; // } //} private void SetInitialRow() { try { DataTable dt = new DataTable(); DataRow dr = null; for (int i = 0; i < Convert.ToInt16(ConfigurationManager.AppSettings["SecondarySalesLine"]); i++) { if (i == 0) { dt.Columns.Add(new DataColumn("No", typeof(string))); dt.Columns.Add(new DataColumn("CustomerName", typeof(string))); dt.Columns.Add(new DataColumn("Location", typeof(string))); dt.Columns.Add(new DataColumn("Code", typeof(string))); dt.Columns.Add(new DataColumn("ItemList", typeof(string))); dt.Columns.Add(new DataColumn("ProductCategory", typeof(string))); dt.Columns.Add(new DataColumn("Range", typeof(string))); dt.Columns.Add(new DataColumn("Quantity", typeof(string))); // dt.Columns.Add(new DataColumn("Date", typeof(string))); dt.Columns.Add(new DataColumn("Month", typeof(string))); } dr = dt.NewRow(); dr["No"] = i + 1; dr["CustomerName"] = string.Empty; dr["Location"] = string.Empty; dr["Code"] = string.Empty; dr["ItemList"] = string.Empty; dr["ProductCategory"] = string.Empty; dr["Range"] = string.Empty; dr["Quantity"] = string.Empty; // dr["Date"] = string.Empty; dr["Month"] = string.Empty; dt.Rows.Add(dr); } ViewState["CurrentTable"] = dt; //Store the DataTable in ViewState Gridview3.DataSource = dt; Gridview3.DataBind(); } catch (Exception ex) { var message = new JavaScriptSerializer().Serialize(ex.Message.ToString()); var script = string.Format("alert({0});", message); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true); } }
protected void BindTheData() { //Response.Write("<script>alert('Binding...')</script>"); // Gridview1.DataSource = SqlDataSource1; //Gridview1.DataBind(); Gridview2.DataSource = SqlDataSource2; Gridview2.DataBind(); Gridview3.DataSource = SqlDataSource3; Gridview3.DataBind(); Gridview4.DataSource = SqlDataSource4; Gridview4.DataBind(); }
protected void BindTheData() { //Response.Write("<script>alert('Binding...')</script>"); // Gridview1.DataSource = SqlDataSource1; //Gridview1.DataBind(); lblStaffName.Text = DropDownList1.SelectedItem.Text; Gridview2.DataSource = SqlDataSource2; Gridview2.DataBind(); Gridview3.DataSource = SqlDataSource3; Gridview3.DataBind(); Gridview4.DataSource = SqlDataSource4; Gridview4.DataBind(); }
//绑定采购订单表 private void BindGridview3(string condition) { Gridview3.DataSource = pl.SelectPMPurchaseOrderMain(condition); Gridview3.DataBind(); }
protected void odswiez() { string idDzialu = (string)Session["id_dzialu"]; string txt = string.Empty; DataTable tabelkaGW1 = new DataTable(); DataTable tabelkaGW2 = new DataTable(); DataTable tabelkaGW3 = new DataTable(); DataTable tabelkaGW4 = new DataTable(); DataTable tabelkaGW5 = new DataTable(); DataTable tabelkaGW6 = new DataTable(); DataTable tabelkaGW7 = new DataTable(); DataTable tabelkaGW8 = new DataTable(); try { //cm.log.Info("OGLR2: wczytywanie danych do tabeli 1"); tabelkaGW1 = dr.generuj_dane_do_tabeli_sedziowskiej_2019(int.Parse((string)Session["id_dzialu"]), 1, Date1.Date, Date2.Date, 30, tenPlik); Session["tabelka001"] = tabelkaGW1; Tabela1.DataSource = null; Tabela1.DataSourceID = null; Tabela1.DataSource = tabelkaGW1; Tabela1.DataBind(); //cm.log.Info("OGLR2: wczytywanie danych do tabeli 2"); tabelkaGW2 = dr.generuj_dane_do_tabeli_sedziowskiej_2019(int.Parse((string)Session["id_dzialu"]), 2, Date1.Date, Date2.Date, 30, tenPlik); Session["tabelka002"] = tabelkaGW2; Gridview2.DataSource = null; Gridview2.DataSourceID = null; Gridview2.DataSource = tabelkaGW2; Gridview2.DataBind(); //cm.log.Info("OGLR2: wczytywanie danych do tabeli 3"); tabelkaGW3 = dr.generuj_dane_do_tabeli_sedziowskiej_2019(int.Parse((string)Session["id_dzialu"]), 3, Date1.Date, Date2.Date, 30, tenPlik); Session["tabelka003"] = tabelkaGW3; Gridview3.DataSource = null; Gridview3.DataSourceID = null; Gridview3.DataSource = tabelkaGW3; Gridview3.DataBind(); try { //cm.log.Info("OGLR2: wczytywanie danych do tabeli 4"); tabelkaGW4 = dr.generuj_dane_do_tabeli_wierszy2018(Date1.Date, Date2.Date, (string)Session["id_dzialu"], 4, 1, 8, tenPlik); Session["tabelka004"] = tabelkaGW4; //pisz("tab_05_", 10, 9, tabela02); tab_05_w01_c1.Text = tabelkaGW4.Rows[0][1].ToString().Trim(); tab_05_w01_c2.Text = tabelkaGW4.Rows[0][2].ToString().Trim(); tab_05_w01_c3.Text = tabelkaGW4.Rows[0][3].ToString().Trim(); tab_05_w01_c4.Text = tabelkaGW4.Rows[0][4].ToString().Trim(); tab_05_w01_c5.Text = tabelkaGW4.Rows[0][5].ToString().Trim(); tab_05_w01_c6.Text = tabelkaGW4.Rows[0][6].ToString().Trim(); tab_05_w01_c7.Text = tabelkaGW4.Rows[0][7].ToString().Trim(); } catch (Exception ex) { cm.log.Error(tenPlik + " tabela 4 " + ex.Message); } try { //cm.log.Info("OGLR2: wczytywanie danych do tabeli 5"); tabelkaGW5 = dr.generuj_dane_do_tabeli_wierszy2018(Date1.Date, Date2.Date, (string)Session["id_dzialu"], 5, 8, 2, tenPlik); Session["tabelka005"] = tabelkaGW5; tab_06_w01_c01.Text = tabelkaGW5.Rows[0][1].ToString().Trim(); tab_06_w02_c01.Text = tabelkaGW5.Rows[1][1].ToString().Trim(); tab_06_w03_c01.Text = tabelkaGW5.Rows[2][1].ToString().Trim(); tab_06_w04_c01.Text = tabelkaGW5.Rows[3][1].ToString().Trim(); tab_06_w05_c01.Text = tabelkaGW5.Rows[4][1].ToString().Trim(); tab_06_w06_c01.Text = tabelkaGW5.Rows[5][1].ToString().Trim(); tab_06_w07_c01.Text = tabelkaGW5.Rows[6][1].ToString().Trim(); } catch (Exception ex) { cm.log.Error("OGLR2: " + ex.Message); } try { Session["tabelka006"] = dr.tworzTabele(int.Parse((string)Session["id_dzialu"]), 6, Date1.Date, Date2.Date, 30, Gridview6, tenPlik); Gridview6.DataBind(); } catch (Exception ex) { cm.log.Error("OGLR2: " + ex.Message); } //cm.log.Info("OGLR2: wczytywanie danych do tabeli 7"); Session["tabelka007"] = dr.tworzTabele(int.Parse((string)Session["id_dzialu"]), 7, Date1.Date, Date2.Date, 9, Gridview7, tenPlik); Gridview7.DataBind(); } catch (Exception ex) { cm.log.Error("OGLR2: " + ex.Message); } // dopasowanie opisów makeLabels(); try { Label11.Visible = cl.debug(int.Parse(idDzialu)); infoLabel2.Visible = cl.debug(int.Parse(idDzialu)); infoLabel3.Visible = cl.debug(int.Parse(idDzialu)); infoLabel4.Visible = cl.debug(int.Parse(idDzialu)); infoLabel5.Visible = cl.debug(int.Parse(idDzialu)); infoLabel5.Visible = cl.debug(int.Parse(idDzialu)); infoLabel7.Visible = cl.debug(int.Parse(idDzialu)); infoLabel8.Visible = cl.debug(int.Parse(idDzialu)); } catch { Label11.Visible = false; infoLabel2.Visible = false; infoLabel3.Visible = false; infoLabel4.Visible = false; infoLabel5.Visible = false; infoLabel6.Visible = false; infoLabel7.Visible = false; infoLabel8.Visible = false; } Label11.Text = txt; Label3.Text = cl.nazwaSadu((string)Session["id_dzialu"]); }
}// end of Page_Load protected void odswiez() { string idDzialu = (string)Session["id_dzialu"]; string txt = string.Empty; DataTable tabelkaGW1 = new DataTable(); DataTable tabelkaGW2 = new DataTable(); DataTable tabelkaGW3 = new DataTable(); try { //cm.log.Info("OGLR2: wczytywanie danych do tabeli 2"); tabelkaGW2 = dr.generuj_dane_do_tabeli_wierszy2018(Date1.Date, Date2.Date, (string)Session["id_dzialu"], 2, 17, 17, tenPlik); Session["tabelkaGW002"] = tabelkaGW2; } catch (Exception ex) { cm.log.Error(tenPlik + " " + ex.Message); } try { //cm.log.Info(tenPlik + ": wczytywanie danych do tabeli 1"); tabelkaGW1 = dr.generuj_dane_do_tabeli_sedziowskiej_2019(int.Parse((string)Session["id_dzialu"]), 1, Date1.Date, Date2.Date, 16, tenPlik); Session["tabelkaGW001"] = tabelkaGW1; Tabela1.DataSource = null; Tabela1.DataSourceID = null; Tabela1.DataSource = tabelkaGW1; Tabela1.DataBind(); } catch (Exception ex) { cm.log.Error(tenPlik + " " + ex.Message); } try { cm.log.Info(tenPlik + ": wczytywanie danych do tabeli 3"); tabelkaGW3 = dr.generuj_dane_do_tabeli_sedziowskiej_2019(int.Parse((string)Session["id_dzialu"]), 3, Date1.Date, Date2.Date, 30, tenPlik); Session["tabelkaGW003"] = tabelkaGW3; Gridview3.DataSource = null; Gridview3.DataSourceID = null; Gridview3.DataSource = tabelkaGW3; Gridview3.DataBind(); } catch (Exception ex) { cm.log.Error(tenPlik + " : " + ex.Message); } // dopasowanie opisów makeLabels(); try { Label11.Visible = cl.debug(int.Parse(idDzialu)); infoLabel2.Visible = cl.debug(int.Parse(idDzialu)); } catch { Label11.Visible = false; infoLabel2.Visible = false; } Label11.Text = txt; Label3.Text = cl.nazwaSadu((string)Session["id_dzialu"]); }
protected void SaveGridLineData() { try { int rowIndex = 0; if (ViewState["CurrentTable"] != null) { DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"]; DataRow drCurrentRow = null; DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance(null); if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { //extract the TextBox values TextBox box1 = (TextBox)Gridview3.Rows[rowIndex].Cells[1].FindControl("lb_CustomerName"); TextBox box2 = (TextBox)Gridview3.Rows[rowIndex].Cells[2].FindControl("lb_Location"); DropDownList box3 = (DropDownList)Gridview3.Rows[rowIndex].Cells[4].FindControl("ddl_ItemList"); TextBox box4 = (TextBox)Gridview3.Rows[rowIndex].Cells[5].FindControl("lb_ProductCategory"); TextBox box5 = (TextBox)Gridview3.Rows[rowIndex].Cells[6].FindControl("lb_Range"); TextBox box6 = (TextBox)Gridview3.Rows[rowIndex].Cells[7].FindControl("lb_Quantity"); //TextBox box7 = (TextBox)Gridview3.Rows[rowIndex].Cells[7].FindControl("lb_Date"); DropDownList box8 = (DropDownList)Gridview3.Rows[rowIndex].Cells[8].FindControl("ddlMonth"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["No"] = i; dtCurrentTable.Rows[i - 1]["CustomerName"] = box1.Text; dtCurrentTable.Rows[i - 1]["Location"] = box2.Text; dtCurrentTable.Rows[i - 1]["ItemList"] = box3.Text; dtCurrentTable.Rows[i - 1]["ProductCategory"] = box4.Text; dtCurrentTable.Rows[i - 1]["Range"] = box5.Text; dtCurrentTable.Rows[i - 1]["Quantity"] = box6.Text; // dtCurrentTable.Rows[i - 1]["Date"] = box7.Text; dtCurrentTable.Rows[i - 1]["Month"] = box8.SelectedValue; rowIndex++; } ViewState["CurrentTable"] = dtCurrentTable; Gridview3.DataSource = dtCurrentTable; Gridview3.DataBind(); if (dtCurrentTable.Rows.Count > 0) { for (int i = 0; i < dtCurrentTable.Rows.Count; i++) { DropDownList ddl_ItemList1 = (DropDownList)Gridview3.Rows[i].Cells[0].FindControl("ddl_ItemList"); DropDownList ddlMonth = (DropDownList)Gridview3.Rows[i].Cells[0].FindControl("ddlMonth"); ddl_ItemList1.SelectedValue = dtCurrentTable.Rows[i]["ItemList"].ToString(); ddlMonth.SelectedValue = dtCurrentTable.Rows[i]["Month"].ToString(); } } } } } catch (Exception ex) { var message = new JavaScriptSerializer().Serialize(ex.Message.ToString()); var script = string.Format("alert({0});", message); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true); } }
private void AddNewRowToGrid() { try { int rowIndex = 0; if (ViewState["CurrentTable"] != null) { DateTimeFormatInfo info = DateTimeFormatInfo.GetInstance(null); DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"]; DataRow drCurrentRow = null; if (dtCurrentTable.Rows.Count > 0) { for (int i = 1; i <= dtCurrentTable.Rows.Count; i++) { //extract the TextBox values TextBox box1 = (TextBox)Gridview3.Rows[rowIndex].Cells[1].FindControl("lb_CustomerName"); TextBox box2 = (TextBox)Gridview3.Rows[rowIndex].Cells[2].FindControl("lb_Location"); DropDownList box3 = (DropDownList)Gridview3.Rows[rowIndex].Cells[4].FindControl("ddl_ItemList"); TextBox box4 = (TextBox)Gridview3.Rows[rowIndex].Cells[5].FindControl("lb_ProductCategory"); TextBox box5 = (TextBox)Gridview3.Rows[rowIndex].Cells[6].FindControl("lb_Range"); TextBox box6 = (TextBox)Gridview3.Rows[rowIndex].Cells[7].FindControl("lb_Quantity"); // TextBox box7 = (TextBox)Gridview3.Rows[rowIndex].Cells[7].FindControl("lb_Date"); DropDownList box8 = (DropDownList)Gridview3.Rows[rowIndex].Cells[8].FindControl("ddlMonth"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["No"] = i + 1; dtCurrentTable.Rows[i - 1]["CustomerName"] = box1.Text; dtCurrentTable.Rows[i - 1]["Location"] = box2.Text; dtCurrentTable.Rows[i - 1]["ItemList"] = box3.SelectedValue; dtCurrentTable.Rows[i - 1]["ProductCategory"] = box4.Text; dtCurrentTable.Rows[i - 1]["Range"] = box5.Text; dtCurrentTable.Rows[i - 1]["Quantity"] = box6.Text; // dtCurrentTable.Rows[i - 1]["Date"] = box7.Text; dtCurrentTable.Rows[i - 1]["Month"] = box8.Text; rowIndex++; } dtCurrentTable.Rows.Add(drCurrentRow); ViewState["CurrentTable"] = dtCurrentTable; Gridview3.DataSource = dtCurrentTable; Gridview3.DataBind(); } else { SetInitialRow(); } } else { Response.Write("Records are not available."); } //Set Previous Data on Postbacks SetPreviousData(); } catch (Exception ex) { var message = new JavaScriptSerializer().Serialize(ex.Message.ToString()); var script = string.Format("alert({0});", message); ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true); } }
//退料表绑定 private void BindGridview3(PMCopperFoundryinfo PMCopperFoundryinfo) { Gridview3.DataSource = pf.SelectPMCopperReturn(PMCopperFoundryinfo); Gridview3.DataBind(); }
//部门查询 private void BindGridview3(string condition) { Gridview3.DataSource = pc.SelectPMSCAC_Organization(condition); Gridview3.DataBind(); }