public static string RegisterUser(string UserId) { UserDetailsReq objUserDetails = new UserDetailsReq(); UserDetailsRes objUserDetailsRes = new UserDetailsRes(); objUserDetails.Type = "delete"; objUserDetails.UserId = UserId; string result = ""; WebClient client = new WebClient(); client.Headers[HttpRequestHeader.ContentType] = "text/json"; DataContractJsonSerializer objJsonSerSend = new DataContractJsonSerializer(typeof(UserDetailsReq)); MemoryStream memStrToSend = new MemoryStream(); objJsonSerSend.WriteObject(memStrToSend, objUserDetails); string data = Encoding.Default.GetString(memStrToSend.ToArray()); string result1 = client.UploadString(URL + "/EditUser", "POST", data); string res = JsonConvert.DeserializeObject <string>(result1); if (res == "true") { result = "Project Type Delete Successfully !"; } else { result = "Project Type Delete Failed !"; } return(result); }
protected void GV_UserList_RowCommand(object sender, GridViewCommandEventArgs e) { try { UserDetailsReq objUserDetails = new UserDetailsReq(); UserDetailsRes objUserDetailsRes = new UserDetailsRes(); if (e.CommandName == "EditPassword") { int rowIndex = Convert.ToInt32(e.CommandArgument); GridViewRow row = GV_UserList.Rows[rowIndex]; objUserDetails.Type = "ResetPassword"; objUserDetails.UserId = row.Cells[5].Text; string randompassword = ""; Random random = new Random(); randompassword = random.Next(1001, 9999).ToString(); objUserDetails.Password = "******" + randompassword; WebClient client = new WebClient(); client.Headers[HttpRequestHeader.ContentType] = "Application/Json"; DataContractJsonSerializer objJsonSerSend = new DataContractJsonSerializer(typeof(UserDetailsReq)); MemoryStream memStrToSend = new MemoryStream(); objJsonSerSend.WriteObject(memStrToSend, objUserDetails); string data = Encoding.Default.GetString(memStrToSend.ToArray()); string result1 = client.UploadString(URL + "/EditUser", "POST", data); string obj = JsonConvert.DeserializeObject <string>(result1); if (obj == "true") { add = "Password Reset Successfully New Password = @" + randompassword + " "; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Success('" + add + "');", true); } else { add = "Password Reset Failed !"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Failed('" + add + "');", true); } } else if (e.CommandName == "Delete_User") { int rowIndex = Convert.ToInt32(e.CommandArgument); GridViewRow row = GV_UserList.Rows[rowIndex]; string UserId = row.Cells[5].Text; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Delete('" + UserId + "');", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, GetType(), "alertmsg", ex.ToString(), true); } }
protected void GV_TerminalList_RowCommand(object sender, GridViewCommandEventArgs e) { try { UserDetailsReq objUserDetails = new UserDetailsReq(); UserDetailsRes objUserDetailsRes = new UserDetailsRes(); if (e.CommandName == "ChangeStatus") { int rowIndex = Convert.ToInt32(e.CommandArgument); GridViewRow row = GV_TerminalList.Rows[rowIndex]; string status = row.Cells[3].Text; if (status == "Active") { status = "Inactive"; } else { status = "Active"; } WebClient client = new WebClient(); client.Headers[HttpRequestHeader.ContentType] = "Application/Json"; var data = JsonConvert.SerializeObject(row.Cells[5].Text + "#" + status); string result1 = client.UploadString(URL + "/GetTerminalList", "POST", data); MemoryStream memstrToReceive = new MemoryStream(Encoding.UTF8.GetBytes(result1)); DataContractJsonSerializer objJsonSerRecv = new DataContractJsonSerializer(typeof(Reply)); Reply objReply = (Reply)objJsonSerRecv.ReadObject(memstrToReceive); if (objReply.Result) { add = "Status Change Successfully !"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Success('" + add + "');", true); } else { add = "Status Change Failed !"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Failed('" + add + "');", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, GetType(), "alertmsg", ex.ToString(), true); } }
protected void btnsubmit_Click(object sender, EventArgs e) { try { if (txtPwd.Text == "") { add = "Please Enter Password"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Warning('" + add + "');", true); txtPwd.Focus(); return; } else if (txtConfirmPwd.Text == "") { add = "Please Enter Confirm Password"; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Warning('" + add + "');", true); txtConfirmPwd.Focus(); return; } if (txtPwd.Text.ToString() != txtConfirmPwd.Text.ToString()) { add = "Password and Confirm Password Is Diffrent Please Enter Same ! "; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Warning('" + add + "');", true); txtConfirmPwd.Focus(); return; } UserDetailsReq objUserDetailsReq = new UserDetailsReq(); objUserDetailsReq.UserId = UID; objUserDetailsReq.Password = txtPwd.Text; objUserDetailsReq.Type = "ResetPassword"; if (objds == null) { objds = new DataSet(); } RespAddUser objRes = new RespAddUser(); using (WebClient client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "text/json"; DataContractJsonSerializer objJsonSerSend = new DataContractJsonSerializer(typeof(UserDetailsReq)); MemoryStream memStrToSend = new MemoryStream(); objJsonSerSend.WriteObject(memStrToSend, objUserDetailsReq); string data = Encoding.Default.GetString(memStrToSend.ToArray()); string result = client.UploadString(URL + "/EditUser", "POST", data); string obj = JsonConvert.DeserializeObject <string>(result); if (obj == "true") { var page1 = HttpContext.Current.CurrentHandler as Page; add = "Password Reset Successfully ! "; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Success('" + add + "');", true); Log.Write("Password Reset Successfully", ""); } else { add = "Password Reset Failed ! "; Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "Failed('" + add + "');", true); Log.Write("Password Reset Failed", ""); } } } catch (Exception excp) { Log.Write("Exception in Creat User :- " + excp, ""); } }