protected void grdCategory_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView row = (DataRowView)e.Row.DataItem;
DataRowView rowStatus = (DataRowView)e.Row.DataItem;
LinkButton lnkStatus = (LinkButton)e.Row.FindControl("lnkStatus");
lnkStatus.Attributes["CompanyId"] = row["CompanyId"].ToString();
LinkButton lnkbtnDelete = (LinkButton)e.Row.FindControl("lnkbtnDelete");
lnkbtnDelete.Attributes["CompanyId"] = row["CompanyId"].ToString();
if (rowStatus["Status"].ToString() == "Y")
{
lnkStatus.Text = "Active";
}
else if (rowStatus["Status"].ToString() == "N")
{
lnkStatus.Text = "InActive";
}
}
}
protected void lnkStatus_Click(object sender, EventArgs e)
{
string strCategoryId = ((LinkButton)sender).Attributes["CompanyId"];
string intStatus;
if (((LinkButton)sender).Text == "Active")
{
intStatus = "N";
}
else
{
intStatus = "Y";
}
SqlCommand cmd = new SqlCommand("UpdateUserLoginStatus", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p1;
p1 = new SqlParameter("@CompanyId", SqlDbType.Int);
p1.Value = Convert.ToInt32(strCategoryId.ToString());
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@Status", SqlDbType.VarChar);
p1.Value = intStatus.ToString();
cmd.Parameters.Add(p1);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
//(new R_Admin()).UpdateStatus(intStatus, "R_Categories", int.Parse(strCategoryId));
getUserDetails();
}
protected void lnkbtnDelete_Click(object sender, EventArgs e)
{
string strSId = ((LinkButton)sender).Attributes["CompanyId"];
//int intSId = (new R_Admin()).Deleting("R_Categories", Int32.Parse(strSId.ToString()));
string s = "select * from CompanyLoginDetails where CompanyId=" + Convert.ToInt32(strSId.ToString());
SqlCommand cmd1 = new SqlCommand(s, con);
con.Open();
cmd1.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = cmd1;
da.Fill(ds, "get");
if (ds.Tables[0].Rows.Count > 0)
{
Session["companyid"] = Convert.ToInt32(ds.Tables[0].Rows[0]["CompanyMainId"].ToString());
}
SqlCommand cmd = new SqlCommand("DeleteUserLoginDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter p1;
p1 = new SqlParameter("@CompanyId", SqlDbType.Int);
p1.Value = Convert.ToInt32(strSId.ToString());
cmd.Parameters.Add(p1);
cmd.ExecuteNonQuery();
SqlCommand cmd2 = new SqlCommand("ChnageapproveStatus", con);
cmd2.CommandType = CommandType.StoredProcedure;
SqlParameter p2;
p2 = new SqlParameter("@Cid", SqlDbType.Int);
p2.Value = Convert.ToInt32(Session["companyid"].ToString());
cmd2.Parameters.Add(p2);
p2 = new SqlParameter("@Approved", SqlDbType.Char);
p2.Value = "N";
cmd2.Parameters.Add(p2);
cmd2.ExecuteNonQuery();
SqlCommand cmd3 = new SqlCommand("UpdateDirectoryStatus", con);
cmd3.CommandType = CommandType.StoredProcedure;
SqlParameter p3;
p3 = new SqlParameter("@Cid", SqlDbType.Int);
p3.Value = Convert.ToInt32(Session["companyid"].ToString());
cmd3.Parameters.Add(p3);
p3 = new SqlParameter("@Status", SqlDbType.VarChar);
p3.Value = "N";
cmd3.Parameters.Add(p3);
cmd3.ExecuteNonQuery();
con.Close();
getUserDetails();
pnlCommettee.Visible = true;
lblMessageCommettee.Text = "<script>" + Environment.NewLine + "alert('Record Deleted successfully')</script>";
pnlCommettee.Controls.Add(lblMessageCommettee);
}
------------------------------------sriraj-----------------------------------------