/// <summary> /// This method use for user login to system. Server response the result is success or failed. /// </summary> /// <param name="username">Username user use to login</param> /// <param name="password">Password user use to login</param> /// <param name="callback">Call when completed.</param> public void Login(string username, string password, string otp, GrdEventHandler callback) { Dictionary <string, string> pars = new Dictionary <string, string>(); pars.Add("username", username); pars.Add("password", Md5Sum(password)); pars.Add("otp", otp); StartCoroutine(Post((data) => { object r = null; Dictionary <string, object> result = GetObjectData((string)data); if (result["error"].ToString() == "0") { user = new GrdUser(); user.username = username; user.address = result["address"].ToString(); user.email = result["email"].ToString(); user.balance = decimal.Parse(result["balance"].ToString()); user.isRequiredOtp = result["isRequiredOtp"].ToString() == "1"; token = result["token"].ToString(); r = user; } else { r = result["message"]; } if (callback != null) { callback(int.Parse(result["error"].ToString()), r); } }, "login", pars)); }
/* Use to bind all admin users to grid GetAllUser() use to get all users from database */ public void Bind() { try { User ObjUser = new User(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); DataView dv = new DataView(); ds = ObjUser.GetAllUser(Request.QueryString["SearchFor"].ToString(), Request.QueryString["SearchText"].ToString()); ddlSearch.SelectedValue = Request.QueryString["SearchFor"].ToString(); txtSearch.Text = Request.QueryString["SearchText"].ToString(); if (ds.Tables[0].Rows.Count > 0) { GrdUser.Visible = true; dt = ds.Tables[0]; dv = dt.DefaultView; if ((SortExpression != string.Empty) && (SortDirection != string.Empty)) { dv.Sort = SortExpression + " " + SortDirection; } GrdUser.DataSource = dv; GrdUser.DataBind(); CheckAll(); check(); Utility.Setserial(GrdUser, "srno"); divsearch.Visible = true; } else { if ((Convert.ToInt32(ddlSearch.SelectedIndex) > 0) && (txtSearch.Text != "")) { txtSearch.Text = ""; ddlSearch.SelectedIndex = 0; lnkNorec.Visible = true; ErrorMessage("Sorry no records found."); } divsearch.Visible = false; GrdUser.Visible = false; ErrorMessage("Sorry no records found."); } } catch { } }