protected void btnSubmitUsr_Click(object sender, EventArgs e) { try { string Usrname = txtUNm.Text; string password = txtPass.Text; string MailID = txtUMailID.Text; string type = drpDwnlstType.SelectedItem.Text; int isdel = 0; if (ChkbxIsDelUsr.Checked == true) isdel = 1; else isdel = 0; BLAddSearchUser bladdusr = new BLAddSearchUser(); if (HttpContext.Current.Session["UserId"] != null) { int Userid = int.Parse(Session["UserId"].ToString()); drpDwnlstType.Enabled = false; string result = bladdusr.UpdateUser(Userid, Usrname, password, MailID, isdel); if (result == "1") lblMsg.Text = "Record Updated Sucessfully"; else lblMsg.Text = "Username already exists"; Session["UserId"] = null; txtUNm.Enabled = true; drpDwnlstType.Enabled = true; FillUser(); } else { string result = bladdusr.addSearchUser(Usrname, password, type, MailID, isdel); if (result == "1") lblMsg.Text = "Record Added Sucessfully"; else lblMsg.Text = "Username already exists"; FillUser(); Session["UserId"] = null; } txtUNm.Text = ""; txtPass.Text = ""; txtUMailID.Text = ""; } catch (Exception ex) { lblCatchError.Text = ex.Message.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { BLLogin blLogin = new BLLogin(); BLAddSearchUser blObjAddAdmin = new BLAddSearchUser(); int dateCount = DateCount(); DataSet ds_chekTrail = null; if (dateCount != 0) { ds_chekTrail = CheckTrail(); } else { ds_chekTrail = CheckTrail(); } if (ds_chekTrail.Tables[0].Rows[0]["Status"].ToString() == "Valid") { DataSet ds = blObjAddAdmin.getAdminCount(); if (ds.Tables[0].Rows[0]["Count"].ToString() == "0") { Response.Redirect("~/AdminRegistration.aspx"); } else { Response.Redirect("~/Login.aspx"); } Session["LoginId"] = null; } else { lblExpire.Text = ds_chekTrail.Tables[0].Rows[0]["Status"].ToString(); } //if (drGetCnt.HasRows) //{ // drGetCnt.Read(); // int cnt = int.Parse(drGetCnt["Count"].ToString()); // drGetCnt.Close(); // if (cnt == 0) // { // Response.Redirect("~/AdminRegistration.aspx"); // } //} }
protected void chkbxSrchIsDel_CheckedChanged(object sender, EventArgs e) { try { DataTable dt = new DataTable(); int isdel = 0; if (chkbxSrchIsDel.Checked == true) isdel = 1; else isdel = 0; string unm = txtUNmSrch.Text; string type = drpdwnlstTypSrch.SelectedItem.Text; BLAddSearchUser blAddUser = new BLAddSearchUser(); if (txtUNmSrch.Text != "" && chkbxSrchIsDel.Checked == true) { SqlDataReader dr = blAddUser.userisdeleted(unm, isdel); if (dr.HasRows) { grdvwSerchUser.DataSource = dr; } grdvwSerchUser.DataBind(); } if (txtUNmSrch.Text == "" && (chkbxSrchIsDel.Checked == true || chkbxSrchIsDel.Checked == false) && drpdwnlstTypSrch.SelectedItem.Text == "--Select--") { SqlDataReader dr = blAddUser.userisdeleted(unm, isdel); if (dr.HasRows) { grdvwSerchUser.DataSource = dr; } grdvwSerchUser.DataBind(); } if (txtUNmSrch.Text != "" && (drpdwnlstTypSrch.SelectedItem.Text == "Both" || drpdwnlstTypSrch.SelectedItem.Text == "admin" || drpdwnlstTypSrch.SelectedItem.Text == "employee")) { SqlDataReader dr = blAddUser.FillUsrNmTypeIsDel1(unm, type, isdel); if (dr.HasRows) { grdvwSerchUser.DataSource = dr; grdvwSerchUser.DataBind(); } } if ((drpdwnlstTypSrch.SelectedItem.Text == "Both" || drpdwnlstTypSrch.SelectedItem.Text == "admin" || drpdwnlstTypSrch.SelectedItem.Text == "employee") && (chkbxSrchIsDel.Checked == true || chkbxSrchIsDel.Checked == false)) { SqlDataReader dr = blAddUser.FillTypeIsDel1(type, isdel); if (dr.HasRows) { grdvwSerchUser.DataSource = dr; } grdvwSerchUser.DataBind(); } } catch (Exception ex) { lblCatchError.Text = ex.Message.ToString(); } }
protected void grdvwSerchUser_RowCommand(object sender, GridViewCommandEventArgs e) { try { BLAddSearchUser blEditUsr = new BLAddSearchUser(); if (e.CommandName == "UpdateThis") { GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer; int rowindex = row.RowIndex; int UserId = int.Parse(grdvwSerchUser.Rows[rowindex].Cells[1].Text); Session["UserId"] = UserId; SqlDataReader dr = blEditUsr.GetUserById(UserId); if (dr.HasRows) { dr.Read(); txtUNm.Text = dr.GetString(1); txtUNm.Enabled = false; txtPass.TextMode = TextBoxMode.SingleLine; txtPass.Text = dr.GetString(2); string type = dr.GetString(3); if (dr["MailID"] != DBNull.Value) { txtUMailID.Text = dr.GetString(5); } else { txtUMailID.Text = ""; } drpDwnlstType.Enabled = false; drpDwnlstType.SelectedValue = type; bool isdel = dr.GetBoolean(4); if (isdel == true) ChkbxIsDelUsr.Checked = true; else ChkbxIsDelUsr.Checked = false; dr.Close(); } } } catch (Exception ex) { lblCatchError.Text = ex.Message.ToString(); } }
protected void drpdwnlstTypSrch_SelectedIndexChanged(object sender, EventArgs e) { try { string unm = txtUNmSrch.Text; string type = drpdwnlstTypSrch.SelectedItem.Text; BLAddSearchUser blAddUser = new BLAddSearchUser(); SqlDataReader dr = blAddUser.FillUsrNmType1(unm, type); DataTable dt = new DataTable(); if (dr.HasRows) { dt.Load(dr); } grdvwSerchUser.DataSource = dt; grdvwSerchUser.DataBind(); } catch (Exception ex) { lblCatchError.Text = ex.Message.ToString(); } }