Exemplo n.º 1
0
        protected void GdVwSrchProjects_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Edit")
                {
                    GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                    int rowIndex = gvr.RowIndex;
                    int ProjectId = Convert.ToInt32(GdVwSrchProjects.Rows[rowIndex].Cells[3].Text);
                    Session["ProjectId"] = ProjectId.ToString();
                    Response.Redirect("~/Admin/Project/AddEditWork.aspx?ProjectId=" + ProjectId);
                }

                if (e.CommandName == "Delete")
                {
                    GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                    int rowIndex = gvr.RowIndex;
                    int ProjectId = Convert.ToInt32(GdVwSrchProjects.Rows[rowIndex].Cells[3].Text);
                    BLProject objBLProject = new BLProject();
                    objBLProject.deleteProject(ProjectId);
                    lblmsg.Text = "Project(s) Deleted.";
                }
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }
Exemplo n.º 2
0
 protected void btnDeleteSelectedProject_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (GridViewRow gvrow in GdVwSrchProjects.Rows)
         {
             if (gvrow.RowType == DataControlRowType.DataRow)
             {
                 //finding the checkbox in the gridview
                 CheckBox ChkBxSelProject = (gvrow.Cells[0].FindControl("ChkBxSelProject") as CheckBox);
                 // checking which checkbox are selected
                 if (ChkBxSelProject.Checked)
                 {
                     int ProjectID = int.Parse(gvrow.Cells[3].Text);
                     BLProject objBLProject = new BLProject();
                     objBLProject.deleteProject(ProjectID);
                     lblmsg.Text = "Project(s) Deleted.";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         lblCatchError.Text = ex.Message.ToString();
     }
 }
Exemplo n.º 3
0
        protected void GdVwSrchProjects_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "Edit")
                {
                    GridViewRow gvr = (GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer;
                    int rowIndex = gvr.RowIndex;
                    System.Web.UI.WebControls.Label lblProjectID = (gvr.Cells[0].FindControl("lblProjectID") as System.Web.UI.WebControls.Label);
                    int ProjectId = Convert.ToInt32(lblProjectID.Text);
                    Session["ProjectId"] = ProjectId.ToString();
                    Response.Redirect("~/Emp/Project/AddEditWork.aspx?ProjectId=" + ProjectId);
                }

                if (e.CommandName == "Delete")
                {
                    GridViewRow gvr = (GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer;
                    int rowIndex = gvr.RowIndex;
                    System.Web.UI.WebControls.Label lblProjectID = (gvr.Cells[0].FindControl("lblProjectID") as System.Web.UI.WebControls.Label);
                    int ProjectId = Convert.ToInt32(lblProjectID.Text);
                    BLProject objBLProject = new BLProject();
                    objBLProject.deleteProject(ProjectId);
                    lblUPDelete.Text = "Project(s) Deleted.";
                    lblViewProjectDelete.Text = "Project(s) Deleted.";

                    string message = "Hello! Mudassar.";
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append("<script type = 'text/javascript'>");
                    sb.Append("window.onload=function(){");
                    sb.Append("alert('");
                    sb.Append(message);
                    sb.Append("')};");
                    sb.Append("</script>");
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());

                    string strmsg = "<SCRIPT LANGUAGE="+"JavaScript"+">alert("+"Project Deleted"+")</SCRIPT>";
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=" + "JavaScript" + ">alert(" + "Project Deleted" + ")</SCRIPT>");
                    //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Project Deleted Successfully')", true);
                    //ClientScript.RegisterStartupScript(typeof(string), "s", "alert(Project(s) Deleted);", true);
                  //  MessageBox.Show("Project(s) Deleted.");
                    GdVwSrchProjects.DataSource = null;
                    GdVwSrchProjects.DataBind();
                }
            }
            catch (Exception ex)
            {
                lblCatchError.Text = ex.Message.ToString();
            }
        }