Friday, June 17, 2011

Change Status Function

<asp:TemplateField HeaderText="Change Status">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnIsactive" runat="server"
OnClick="change_status"
CommandArgument='<%#Eval("ID")+","+Eval("ProjectID") %>'
ToolTip='<%#Eval("UserName")%>'
Text='<%#get(Convert.ToBoolean((Eval("IsActive"))))%>'
></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
------------------------------------------
public string get(bool act)
{
if (act == true)
{
return "Deactivate";
}
else
{
return "Activate";
}
}
protected void change_status(object sender, EventArgs e)
{
if (Convert.ToInt32(Session["AccessRight"]) == 1)
{

lnk = ((LinkButton)(sender));
string[] array = lnk.CommandArgument.ToString().Split(',');
prjID = Convert.ToInt32(array[1].ToString());
Int32 bid = Convert.ToInt32(array[0].ToString());
Hashtable ht = new Hashtable();
ht.Clear();
userN = Convert.ToString(lnk.ToolTip);
ViewState["logincheck"] = userN;
string mal = getUserMail(userN);
string prtit = getProjectTitle(prjID);
ViewState["eMail"] = mal;
accountType = "bid on " + prtit;
ht.Add("@bid", bid);
ht.Add("@prjID", prjID);
if (lnk.Text == "Deactivate")
{
chk = "Activated";
ht.Add("@isactive", Convert.ToBoolean("False"));
NSBuilder.DataAccess.ExecuteNonQuery("sp_activeBidStatus", ht);
lnk.Text = "Activate";
mailStatus = "DeActivated";
lblmsg.Visible = true;
lblmsg.Text = userN + " bid is DeActivated.";
//sendMail();
chk = "";
string javaScript =
"<script language=JavaScript>\n" +
"alert('" + userN + " bid has been DeActivated. !!');\n" +
"</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", javaScript);
}
else
{
chk = "DeActivated";
ht.Add("@isactive", Convert.ToBoolean("True"));
NSBuilder.DataAccess.ExecuteNonQuery("sp_activeBidStatus", ht);
lnk.Text = "Deactivate";
mailStatus = "Activated";
lblmsg.Visible = true;

lblmsg.Text = userN + " bid is Activated.";
// sendMail();
chk = "";
string javaScript =
"<script language=JavaScript>\n" +
"alert('" + userN + " bid has been Activated. !!');\n" +
"</script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", javaScript);
}
// searchMethod();
}





-----------------------------------------------------------------
***
  <ItemTemplate>
      <asp:Label ID="lblStatus" runat="server"
Text='<%# Convert.ToString(Eval("isActive")).ToLower()=="true"?"Activated":"DeActivated" %>'></asp:Label>
     </ItemTemplate>
------------------------------------------------------------------

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More