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 getagentsbydistributors() { try { ClsBAL obj = new ClsBAL(); DataSet ds = (DataSet)obj.GetAgentsbyDistributorID(Convert.ToInt32(Session["UserID"].ToString())); if (ds != null) if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { if (Session["Role"].ToString() == "BSD") { gvAgents.DataSource = ds.Tables[1]; ViewState["Users1"] = ds.Tables[1]; gvAgents.DataBind(); } else { gvAgents.DataSource = ds.Tables[0]; ViewState["Users1"] = ds.Tables[0]; gvAgents.DataBind(); } } } } catch (Exception ex) { } }
protected void lbtnDeposits_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 = ""; if (Session["Role"].ToString() == "Admin") { Session["Deposits"] = "AgentDeposits"; DataSet ds = GetAgents(); ddlAgents.DataSource = ds; ddlAgents.DataTextField = "Username"; ddlAgents.DataValueField = "AgentId"; ddlAgents.DataBind(); ddlAgents.Items.Insert(0, "Please Select"); gvDeposits.DataSource = null; gvDeposits.DataBind(); } else if (Session["Role"].ToString() == "Distributor") { ClsBAL objbal = new ClsBAL(); Session["Deposits"] = "DistributorAgentDeposits"; DataSet ds = objbal.GetAgentsbyDistributorID(Convert.ToInt32(Session["UserID"].ToString())); ddlAgents.DataSource = ds; ddlAgents.DataTextField = "Username"; ddlAgents.DataValueField = "AgentId"; ddlAgents.DataBind(); ddlAgents.Items.Insert(0, "Please Select"); gvDeposits.DataSource = null; gvDeposits.DataBind(); } BindDepositRequests(); txtTransactionNo.Text = ""; rbtnType.SelectedIndex = -1; } catch (Exception ex) { lblMsg.InnerHtml = ex.Message; throw; } }