protected void PageDropDownList_SelectedIndexChanged(object sender, EventArgs e) { // Retrieve the pager row. GridViewRow pagerRow = GridViewCycle.BottomPagerRow; // Retrieve the PageDropDownList DropDownList from the bottom pager row. DropDownList pageList = (DropDownList)pagerRow.Cells[0].FindControl("PageDropDownList"); // Set the PageIndex property to display that page selected by the user. GridViewCycle.PageIndex = pageList.SelectedIndex; List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); if (item.Count > 0) { GridViewCycle.DataSource = item;//item.OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); GridViewCycle.Visible = true; pnlNoRec.Visible = false; } else { GridViewCycle.Visible = false; pnlNoRec.Visible = true; } System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); }
protected void GridViewCycle_RowDeleting(object sender, GridViewDeleteEventArgs e) { logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name); try { int index = e.RowIndex; Label _lblOrder_Cycle_ID = (Label)GridViewCycle.Rows[e.RowIndex].FindControl("lblOrder_Cycle_ID"); dbo_OrderAndDeliveryCycleClass order = dbo_OrderAndDeliveryCycleDataClass.Select_Record(_lblOrder_Cycle_ID.Text); List <dbo_OrderAndDeliveryCycleValueClass> value = dbo_OrderAndDeliveryCycleValueDataClass.Search(_lblOrder_Cycle_ID.Text); foreach (dbo_OrderAndDeliveryCycleValueClass _value in value) { dbo_OrderAndDeliveryCycleValueDataClass.Delete(_value.OrderAndDeliveryCycleValue_ID); } dbo_OrderAndDeliveryCycleDataClass.Delete(order); System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); Show("ลบข้อมูลสำเร็จ"); List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID);; GridViewCycle.DataBind(); } catch (Exception) { } }
protected void btnSearchCancel_Click(object sender, EventArgs e) { List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); if (item.Count > 0) { GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); GridViewCycle.Visible = true; pnlNoRec.Visible = false; } else { GridViewCycle.Visible = false; pnlNoRec.Visible = true; } item.Insert(0, new dbo_OrderAndDeliveryCycleClass() { Order_Cycle_ID = string.Empty, Order_Cycle_Name = "==ระบุ==" }); ddlOrderCycle.DataSource = item; ddlOrderCycle.DataBind(); System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); }
protected void ButtonCreateNew_Click(object sender, EventArgs e) { GridViewCycle.ShowFooter = true; GridViewCycle.EditIndex = -1; GridViewCycle.DataSource = dbo_OrderAndDeliveryCycleDataClass.SelectAll().OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); }
protected void GridViewCycle_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name); GridViewCycle.EditIndex = -1; GridViewCycle.ShowFooter = false; List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID);; GridViewCycle.DataBind(); }
protected void GridViewCycle_RowEditing(object sender, GridViewEditEventArgs e) { logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name); GridViewCycle.EditIndex = e.NewEditIndex; GridViewCycle.ShowFooter = false; List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); LinkButton currbtn = (LinkButton)GridViewCycle.Rows[e.NewEditIndex].FindControl("lnkB_SetOrder_Cycle_Name"); currbtn.Visible = false; }
protected void btnShowGrid_Click(object sender, EventArgs e) { isChangedCycle = false; List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); pnlForm.Visible = false; pnlGrid.Visible = true; System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); }
protected void GridViewCycle_RowUpdating(object sender, GridViewUpdateEventArgs e) { logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name); try { int RowIndex = Convert.ToInt32((e.RowIndex).ToString()); Label _Order_Cycle_ID = (Label)GridViewCycle.Rows[RowIndex].FindControl("lblOrder_Cycle_ID"); TextBox _Order_Cycle_Name = (TextBox)GridViewCycle.Rows[RowIndex].FindControl("txtEditOrder_Cycle_Name"); dbo_OrderAndDeliveryCycleClass cycle = new dbo_OrderAndDeliveryCycleClass() { Order_Cycle_ID = _Order_Cycle_ID.Text, Order_Cycle_Name = _Order_Cycle_Name.Text }; bool success = false; success = dbo_OrderAndDeliveryCycleDataClass.Update(cycle); if (success) { System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); //string script = @"swal(""บันทึกสำเร็จ!"", """", ""success"")"; //ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAM", script, true); Show("บันทึกสำเร็จ!"); GridViewCycle.EditIndex = -1; GridViewCycle.ShowFooter = false; GridViewCycle.DataSource = dbo_OrderAndDeliveryCycleDataClass.SelectAll().OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); } System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); } catch (Exception ex) { logger.Error(ex.Message); } }
protected void btnSearchOK_Click(object sender, EventArgs e) { if (ddlOrderCycle.SelectedIndex > 0) { List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.Search(ddlOrderCycle.Text); if (item.Count > 0) { GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); GridViewCycle.Visible = true; pnlNoRec.Visible = false; } else { GridViewCycle.Visible = false; pnlNoRec.Visible = true; } } else { List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); if (item.Count > 0) { GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); GridViewCycle.Visible = true; pnlNoRec.Visible = false; } else { GridViewCycle.Visible = false; pnlNoRec.Visible = true; } } System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); }
//public static int CurrentPreviousIndex; #endregion #region Control Events protected void Page_Load(object sender, EventArgs e) { logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name); if (!IsPostBack) { List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); if (item.Count > 0) { GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID); GridViewCycle.DataBind(); GridViewCycle.Visible = true; pnlNoRec.Visible = false; } else { GridViewCycle.Visible = false; pnlNoRec.Visible = true; } item.Insert(0, new dbo_OrderAndDeliveryCycleClass() { Order_Cycle_ID = string.Empty, Order_Cycle_Name = "==ระบุ==" }); ddlOrderCycle.DataSource = item; ddlOrderCycle.DataBind(); } else { if (isChangedCycle == false) { ViewState["CurrentIndex"] = ddlCurrent.SelectedValue; ViewState["NewIndex"] = ddlNew.SelectedValue; } } }
protected void GridViewCycle_RowCommand(object sender, GridViewCommandEventArgs e) { logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name); if (e.CommandName == "EditCycle") { int RowIndex = Convert.ToInt32((e.CommandArgument).ToString()); List <dbo_OrderAndDeliveryCycleClass> item1 = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); if (item1.Count < GridViewCycle.Rows.Count && RowIndex > int.Parse(ViewState["current_index"].ToString())) { RowIndex--; } current_index = RowIndex; ViewState["current_index"] = current_index; LinkButton currbtn = (LinkButton)GridViewCycle.Rows[RowIndex].FindControl("lnkB_SetOrder_Cycle_Name"); //Label cycle_id = (Label)GridViewCycle.Rows[RowIndex].FindControl("lblOrder_Cycle_ID"); string orderCycleID = item1[RowIndex].Order_Cycle_ID; if (currbtn.Text == "แก้ไขรอบสั่งรอบส่ง") { dbo_OrderAndDeliveryCycleClass cycle = new dbo_OrderAndDeliveryCycleClass() { }; List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); item.Insert(RowIndex + 1, new dbo_OrderAndDeliveryCycleClass() { }); GridViewCycle.DataSource = item; GridViewCycle.DataBind(); currbtn = (LinkButton)GridViewCycle.Rows[RowIndex].FindControl("lnkB_SetOrder_Cycle_Name"); currbtn.Text = "ปิด"; //List<dbo_OrderAndDeliveryCycleValueClass> item_value = dbo_OrderAndDeliveryCycleValueDataClass.Search(cycle_id.Text); List <dbo_OrderAndDeliveryCycleValueClass> item_value = dbo_OrderAndDeliveryCycleValueDataClass.Search(orderCycleID); GridView gv = (GridView)GridViewCycle.Rows[RowIndex + 1].FindControl("grdNewValue"); Button newbutton1 = (Button)GridViewCycle.Rows[RowIndex + 1].FindControl("btnNewValue"); LinkButton Cycle_Name = (LinkButton)GridViewCycle.Rows[RowIndex + 1].FindControl("lnkB_SetOrder_Cycle_Name"); gv.DataSource = item_value; gv.DataBind(); gv.Visible = true; newbutton1.Visible = true; Cycle_Name.Visible = false; GridViewCycle.Rows[RowIndex + 1].Cells[2].ColumnSpan = 5; GridViewCycle.Rows[RowIndex + 1].Cells[0].Visible = false; GridViewCycle.Rows[RowIndex + 1].Cells[1].Visible = false; GridViewCycle.Rows[RowIndex + 1].Cells[3].Visible = false; GridViewCycle.Rows[RowIndex + 1].Cells[4].Visible = false; GridViewCycle.Rows[RowIndex + 1].Cells[5].Visible = false; Label currlbl = (Label)GridViewCycle.Rows[RowIndex + 1].FindControl("lblOrder"); currlbl.Visible = false; // currbtn.Visible = true; for (int i = RowIndex + 1; i < GridViewCycle.Rows.Count; i++) { Label lbl_Amount = (Label)GridViewCycle.Rows[i].FindControl("lblOrder"); lbl_Amount.Text = i.ToString(); } } else { List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID);; GridViewCycle.DataBind(); } } else if (e.CommandName == "AddNew") { string _Order_Cycle_ID = GenerateID.Order_Cycle_ID(); TextBox _Order_Cycle_Name = (TextBox)GridViewCycle.FooterRow.FindControl("txtNewOrder_Cycle_Name"); if (_Order_Cycle_Name.Text.Trim() != string.Empty) { dbo_OrderAndDeliveryCycleClass cycle = new dbo_OrderAndDeliveryCycleClass() { Order_Cycle_ID = _Order_Cycle_ID, Order_Cycle_Name = _Order_Cycle_Name.Text }; bool success = false; string User_ID = HttpContext.Current.Request.Cookies["User_ID"].Value; success = dbo_OrderAndDeliveryCycleDataClass.Add(cycle, User_ID); if (success) { //string script = @"swal(""บันทึกสำเร็จ!"", """", ""success"")"; //ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAM", script, true); // Show("บันทึกสำเร็จ"); GridViewCycle.ShowFooter = false; List <dbo_OrderAndDeliveryCycleClass> item = dbo_OrderAndDeliveryCycleDataClass.SelectAll(); GridViewCycle.DataSource = item.OrderBy(f => f.Order_Cycle_ID);; GridViewCycle.DataBind(); } System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); } else { System.Threading.Thread.Sleep(500); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true); Show("กรุณากรอกข้อมูลที่จำเป็นให้ครบถ้วน"); } } }