protected void Page_Load(object sender, EventArgs e) { int busTypeId = Convert.ToInt32(Request.QueryString["BusTypeID"].ToString()); busType = BLLBusType.getBusTypeByID(busTypeId)[0]; if (!Page.IsPostBack) { BusTypeName.Text = busType.Type; cbStatus.Checked = busType.Status; } }
protected void LoadData() { DataTable dt = BLLBusType.getAllBusType(); dv = new DataView(dt); dv.Sort = "BusTypeID ASC"; total.Text = dv.Count.ToString(); gvBusTypeList.DataSource = dv; gvBusTypeList.DataBind(); if (gvBusTypeList.HeaderRow != null) { gvBusTypeList.HeaderRow.TableSection = TableRowSection.TableHeader; } }
/// <summary> /// Fill data to dropdownlist /// </summary> private void fillData() { DataTable busType = BLLBusType.getAllBusTypeByStatus(true); ddlBusType.DataSource = busType; ddlBusType.DataTextField = "Type"; ddlBusType.DataValueField = "BusTypeID"; ddlBusType.DataBind(); DataTable category = BLLCategory.getAllDataByStatus(true); ddlCategory.DataSource = category; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryID"; ddlCategory.DataBind(); }
protected void lnkBtnSave_Click(object sender, EventArgs e) { string name = Type.Text.Trim(); if (BLLBusType.checkBusTypeExistName(name) != 0) { ClientScript.RegisterStartupScript(this.GetType(), "Notify", "alert('!!!BusType Name existed. Please try again');", true); } else { BusType busType = new BusType(); busType.Type = name; busType.Status = true; BLLBusType.InsertBusType(busType); Response.Redirect("BustypeList.aspx"); } }
protected void gvBusList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Label lblBusType = (Label)e.Row.FindControl("lblBusType"); Label lblCategory = (Label)e.Row.FindControl("lblCategory"); HiddenField hfBusType = (HiddenField)e.Row.FindControl("hfBusType"); HiddenField hfCategory = (HiddenField)e.Row.FindControl("hfCategory"); int busTypeID = Int32.Parse(hfBusType.Value); int categoryID = Int32.Parse(hfCategory.Value); BusType busType = BLLBusType.getBusTypeByID(busTypeID)[0]; Category cat = BLLCategory.getCategoryByID(categoryID)[0]; lblBusType.Text = busType.Type; lblCategory.Text = cat.CategoryName; } }
protected void lnkDelete_Click(object sender, EventArgs e) { int test = 0; foreach (GridViewRow row in gvBusTypeList.Rows) { CheckBox cb = (CheckBox)row.FindControl("chkSel"); if (cb.Checked) { ++test; int id = int.Parse(row.Cells[1].Text); int k = BLLBusType.DeleteBusType(id); } } if (test == 0) { ClientScript.RegisterStartupScript(this.GetType(), "Notify", "alert('!!!Please select a BusType from the list to delete');", true); } else { Response.Redirect("BusTypeList.aspx"); } }
protected void lnkUpdate_Click(object sender, EventArgs e) { if ((!busType.Type.Equals(BusTypeName.Text.Trim())) && (BLLBusType.checkBusTypeExistName(BusTypeName.Text) != 0)) { ClientScript.RegisterStartupScript(this.GetType(), "Notify", "alert('!!!Type Name existed. Please try again');", true); } else { BusType newBusType = new BusType(); newBusType.BusTypeID = busType.BusTypeID; newBusType.Type = BusTypeName.Text.Trim(); if (cbStatus.Checked) { newBusType.Status = true; } else { newBusType.Status = false; } int k = BLLBusType.UpdateBusType(newBusType); Response.Redirect("BustypeList.aspx"); } }
/// <summary> /// Fill data to Form /// </summary> private void FillData() { BusPlate.Text = bus.BusPlate; BusName.Text = bus.BusName; Seat.Text = bus.Seat.ToString(); cbStatus.Checked = bus.Status; DataTable busType = BLLBusType.getAllBusTypeByStatus(true); ddlBusType.DataSource = busType; ddlBusType.DataTextField = "Type"; ddlBusType.DataValueField = "BusTypeID"; ddlBusType.DataBind(); ddlBusType.SelectedValue = bus.BusTypeID.ToString(); DataTable category = BLLCategory.getAllDataByStatus(true); ddlCategory.DataSource = category; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryID"; ddlCategory.DataBind(); ddlCategory.SelectedValue = bus.CategoryID.ToString(); }