protected void btnDelete_Click(object sender, EventArgs e)
        {
            ProjectsDataSet ds1 = new ProjectsDataSet();

            ProjectsDataSetTableAdapters.ProjectsTableTableAdapter taProjects = new ProjectsDataSetTableAdapters.ProjectsTableTableAdapter();

            taProjects.Fill(ds1.ProjectsTable);

            int selected = Convert.ToInt32(Session["projectid"]);

            DataRow[] dr = ds1.ProjectsTable.Select("projectid=" + selected);



            dr[0].Delete();


            taProjects.Update(ds1.ProjectsTable);
            taProjects.Fill(ds1.ProjectsTable);
            Label1.Text = "Deleted This Project Successfully";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user"] == null)
            {
                Server.Transfer("StartHereTest.aspx");
            }
            else
            {
                Users user = (Users)Session["user"];


                int projectid = Convert.ToInt32(Session["projectid"]);
                pid.Text = " " + projectid;
                ProjectsDataSet ds = new ProjectsDataSet();
                ProjectsDataSetTableAdapters.ProjectsTableTableAdapter taProjects =
                    new ProjectsDataSetTableAdapters.ProjectsTableTableAdapter();
                taProjects.Fill(ds.ProjectsTable);

                DataTable table      = ds.Tables["ProjectsTable"];
                string    expression = "projectid = " + projectid;
                DataRow[] foundRows;
                foundRows = table.Select(expression);
                for (int i = 0; i < foundRows.Length; i++)
                {
                    pid.Text     = "" + foundRows[i][0];
                    ptitle.Text  = "" + foundRows[i][1];
                    pmn.Text     = "" + foundRows[i][2];
                    porg.Text    = "" + foundRows[i][3];
                    pDate.Text   = "" + foundRows[i][4];
                    pdesc.Text   = "" + foundRows[i][5];
                    ploc.Text    = "" + foundRows[i][6];
                    papps.Text   = "" + foundRows[i][7];
                    pweb.Text    = "" + foundRows[i][8];
                    pskills.Text = "" + foundRows[i][9];
                    pdur.Text    = "" + foundRows[i][10];
                    pAssets.Text = "" + foundRows[i][12];
                }
            }
        }
        protected void btnUpdateProject_Click(object sender, EventArgs e)
        {
            string projName = tbPName.Text;
            string projMngr = tbPMngr.Text;
            string orgName  = tbOrgName.Text;
            string desc     = tbDesc.Text;
            string loc      = tbLoc.Text;

            string web    = tbWeb.Text;
            string dur    = tbDuration.Text;
            string skills = "";

            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    skills += CheckBoxList1.Items[i].Text + " ";
                }
            }
            skills += tbSkills.Text;



            string compensateAssets = "";

            if (cbAssets.Checked)
            {
                compensateAssets += tbAsset.Text;
            }
            if (cbBudget.Checked)
            {
                compensateAssets += tbBudget.Text;
            }


            ProjectsDataSet ds1 = new ProjectsDataSet();

            ProjectsDataSetTableAdapters.ProjectsTableTableAdapter taProjects = new ProjectsDataSetTableAdapters.ProjectsTableTableAdapter();

            taProjects.Fill(ds1.ProjectsTable);

            int selected = project.projectid;

            DataRow[] dr = ds1.ProjectsTable.Select("projectid=" + selected);


            dr[0]["ProjectName"]    = projName;
            dr[0]["ProjectManager"] = projMngr;
            dr[0]["OrgName"]        = orgName;
            dr[0]["Description"]    = desc;
            dr[0]["Location"]       = loc;

            dr[0]["Website"]  = web;
            dr[0]["Skills"]   = skills;
            dr[0]["Duration"] = dur;

            taProjects.Update(ds1.ProjectsTable);

            //string userid = user.userid.ToString();
            //SqlConnection cn = new SqlConnection();
            //try
            //{
            //    cn.ConnectionString = "Server=(local);Database=CommunityESwap;Integrated Security = SSPI;";
            //    cn.Open();
            //    SqlDataAdapter da = new SqlDataAdapter("select * from ProjectsTable", cn);

            //    SqlCommand update = new SqlCommand();
            //    update.Connection = cn;
            //    update.CommandType = System.Data.CommandType.Text;
            //    update.CommandText = "UPDATE ProjectsTable SET ProjectName=@ProjName, ProjectManager=@ProjMgr, OrgName=@OrgName, Description=@Desc, Location=@Loc, Website=@Web, Skills=@Skills, Duration=@Duration, CompensateAssets=@CompensateAssets WHERE projectid=@projectid";

            //    update.Parameters.AddWithValue("@ProjName", projName);
            //    update.Parameters.AddWithValue("@ProjMgr", projMngr);
            //    update.Parameters.AddWithValue("@OrgName", orgName);
            //    update.Parameters.AddWithValue("@Desc", desc);
            //    update.Parameters.AddWithValue("@Loc", loc);
            //    update.Parameters.AddWithValue("@Web", web);
            //    update.Parameters.AddWithValue("@Skills", skills);
            //    update.Parameters.AddWithValue("@Duration", dur);
            //    update.Parameters.AddWithValue("@CompensateAssets", compensateAssets);
            //    update.Parameters.AddWithValue("@projectid", project.projectid.ToString());

            //    da.UpdateCommand = update;

            //    ProjectsDataSet ds = new ProjectsDataSet();
            //    da.Fill(ds, "ProjectsTable");


            //    ds.Tables[0].Rows[0]["ProjectName"] = projName;
            //    ds.Tables[0].Rows[0]["ProjectManager"] = projMngr;
            //    ds.Tables[0].Rows[0]["OrgName"] = orgName;
            //    ds.Tables[0].Rows[0]["Description"] = desc;
            //    ds.Tables[0].Rows[0]["Location"] = loc;

            //    ds.Tables[0].Rows[0]["Website"] = web;
            //    ds.Tables[0].Rows[0]["Skills"] = skills;
            //    ds.Tables[0].Rows[0]["Duration"] = dur;

            //    ds.Tables[0].Rows[0]["CompensateAssets"] = compensateAssets;

            //    da.Update(ds.Tables[0]);

            //    Label3.Visible = true;
            //    Label3.Text = "Successfully Updated!";

            //}
            //catch (SqlException ex)
            //{
            //    Label3.Visible = true;
            //    Label3.Text = ex.Message;
            //}
            //finally
            //{
            //    cn.Close();
            //}
        }