protected void gvAgents_Sorting(object sender, GridViewSortEventArgs e) { try { string strExpression = e.SortExpression; string strDirection = ViewState["SortDirection"].ToString(); if (Session["Role"].ToString() == "Admin") { if (ViewState["Link"].ToString() == "View Distributors") { ClsBAL obj = new ClsBAL(); DataSet ds = (DataSet)obj.GetAllTYpes("Distributor"); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { DataTable dt = ds.Tables[0]; DataView dv = new DataView(dt); dv.Sort = strExpression + strDirection; gvAgents.DataSource = dv; gvAgents.DataBind(); } } } } else { DataTable dt = GetAgents().Tables[0]; DataView dv = new DataView(dt); dv.Sort = strExpression + strDirection; gvAgents.DataSource = dv; gvAgents.DataBind(); } } else { ClsBAL obj = new ClsBAL(); DataSet ds = (DataSet)obj.GetAgentsbyDistributorID(Convert.ToInt32(Session["UserID"].ToString())); DataTable dt = ds.Tables[0]; DataView dv = new DataView(dt); dv.Sort = strExpression + strDirection; gvAgents.DataSource = dv; gvAgents.DataBind(); } if (strDirection == " ASC") { ViewState["SortDirection"] = " DESC"; } else { ViewState["SortDirection"] = " ASC"; } } catch (Exception ex) { lblMsg.InnerHtml = ex.Message; } }
public static string[] GetAgentNames(string prefixText) { try { DataSet ds = new DataSet(); ClsBAL objBal = new ClsBAL(); if (HttpContext.Current.Session["Deposits"].ToString() == "AgentDeposits") { ds = objBal.GetAgents(); string filteringquery = "Username LIKE '" + prefixText + "%'"; //Select always return array,thats why we store it into array of Datarow DataRow[] dr = ds.Tables[0].Select(filteringquery); //create new table DataTable dtNew = new DataTable(); //create a clone of datatable dt and store it into new datatable dtNew = ds.Tables[0].Clone(); //fetching all filtered rows add add into new datatable foreach (DataRow drNew in dr) { dtNew.ImportRow(drNew); } //return dtAirportCodes; List<string> airports = new List<string>(); for (int i = 0; i < dtNew.Rows.Count; i++) { airports.Add(dtNew.Rows[i]["Username"].ToString().Trim()); } return airports.ToArray(); } else if (HttpContext.Current.Session["Deposits"].ToString() == "DisDeposits") { ds = objBal.GetAllTYpes("Distributor"); string filteringquery = "Username LIKE '" + prefixText + "%'"; //Select always return array,thats why we store it into array of Datarow DataRow[] dr = ds.Tables[0].Select(filteringquery); //create new table DataTable dtNew = new DataTable(); //create a clone of datatable dt and store it into new datatable dtNew = ds.Tables[0].Clone(); //fetching all filtered rows add add into new datatable foreach (DataRow drNew in dr) { dtNew.ImportRow(drNew); } //return dtAirportCodes; List<string> airports = new List<string>(); for (int i = 0; i < dtNew.Rows.Count; i++) { airports.Add(dtNew.Rows[i]["Username"].ToString().Trim()); } return airports.ToArray(); } else { ds = objBal.GetAgentsbyDistributorID(Convert.ToInt32(HttpContext.Current.Session["UserID"].ToString())); string filteringquery = "Username LIKE '" + prefixText + "%'"; //Select always return array,thats why we store it into array of Datarow DataRow[] dr = ds.Tables[0].Select(filteringquery); //create new table DataTable dtNew = new DataTable(); //create a clone of datatable dt and store it into new datatable dtNew = ds.Tables[0].Clone(); //fetching all filtered rows add add into new datatable foreach (DataRow drNew in dr) { dtNew.ImportRow(drNew); } //return dtAirportCodes; List<string> airports = new List<string>(); for (int i = 0; i < dtNew.Rows.Count; i++) { airports.Add(dtNew.Rows[i]["Username"].ToString().Trim()); } return airports.ToArray(); } } catch (Exception) { throw; } }
protected void getdistributors() { try { ClsBAL obj = new ClsBAL(); DataSet ds = (DataSet)obj.GetAllTYpes("Distributor"); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { gvAgents.DataSource = ds.Tables[0]; gvAgents.DataBind(); } } } } catch (Exception ex) { } }
protected void lnkViewBSD_Click(object sender, EventArgs e) { try { ViewState["Link"] = "View Distributors"; divAgents.Visible = true; divAgentRegistration.Visible = false; divDeposits.Visible = false; lbtnViewAgents.Font.Bold = true; lbtnRegisterAgent.Font.Bold = false; lbtnDeposits.Font.Bold = false; ClsBAL obj = new ClsBAL(); DataSet ds = (DataSet)obj.GetAllTYpes("BSD"); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { gvAgents.DataSource = ds.Tables[0]; gvAgents.DataBind(); } } } } catch (Exception ex) { lblMsg.InnerHtml = ex.Message; } }
protected void lnkbtnEmployee_Click(object sender, EventArgs e) { if (Session["Role"].ToString() == "Admin") { try { ViewState["Link"] = "View Distributors"; divAgents.Visible = true; divAgentRegistration.Visible = false; divDeposits.Visible = false; lbtnViewAgents.Font.Bold = true; lbtnRegisterAgent.Font.Bold = false; lbtnDeposits.Font.Bold = false; ClsBAL obj = new ClsBAL(); DataSet ds = (DataSet)obj.GetAllTYpes("Employee"); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { gvAgents.DataSource = ds.Tables[0]; gvAgents.DataBind(); } } } } catch (Exception ex) { lblMsg.InnerHtml = ex.Message; } } else { divAgents.Visible = true; getempsbybsd(); } }
protected void lbtnDistributorsDeposits_Click(object sender, EventArgs e) { try { txtAgents.Text = ""; lbtnViewAgents.Font.Bold = false; lbtnRegisterAgent.Font.Bold = false; lbtnDeposits.Font.Bold = true; divAgents.Visible = false; divAgentRegistration.Visible = false; divDeposits.Visible = true; txtAmount.Text = txtDepositDetails.Text = ""; ClsBAL obj = new ClsBAL(); DataSet ds = (DataSet)obj.GetAllTYpes("Distributor"); if (ds != null) { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { Session["Deposits"] = "DisDeposits"; ddlAgents.DataSource = ds; ddlAgents.DataTextField = "Username"; ddlAgents.DataValueField = "AgentId"; ddlAgents.DataBind(); ddlAgents.Items.Insert(0, "Please Select"); gvDeposits.DataSource = null; gvDeposits.DataBind(); } } } txtTransactionNo.Text = ""; rbtnType.SelectedIndex = -1; } catch (Exception ex) { lblMsg.InnerHtml = ex.Message; // throw; } }
DataSet GetAgents() { try { objBal = new ClsBAL(); return objBal.GetAllTYpes(ddltype.SelectedValue); } catch (Exception ex) { // lblMsg.InnerHtml = ex.Message; throw; } }
protected void getusers() { try { objBal = new ClsBAL(); DataSet ds = objBal.GetAllTYpes("User"); if (ds != null) { if (ds.Tables.Count > 0) { gvAgents.DataSource = ds.Tables[0]; ViewState["Users"] = ds.Tables[0]; gvAgents.DataBind(); } } else { lblMsg.InnerHtml = "No Data Found"; } } catch (Exception) { throw; } }