protected void Delete(object sender, EventArgs e)
        {
            for (int i = 0; i < GridView.Rows.Count; i++)
            {
                if (GridView.Rows[i].RowType == DataControlRowType.DataRow)
                {
                    CheckBox chk = (CheckBox)GridView.Rows[i].Cells[0].FindControl("CheckBox") as CheckBox;
                    if (chk.Checked)
                    {
                        int RecordID = (int)GridView.DataKeys[i].Value;

                        if (_businesscode.GetRelationProjectHasCRAs(Convert.ToInt32(GridView.DataKeys[i].Value)).Count != 0)            //--Var
                        {
                            _businesscode.DeleteRelationProjectHasCRAs(RecordID);                                                       //--Var
                        }
                        if (_businesscode.GetRelationProjectHasDoctors(Convert.ToInt32(GridView.DataKeys[i].Value)).Count != 0)         //--Var
                        {
                            _businesscode.DeleteRelationProjectHasDoctors(RecordID);                                                    //--Var
                        }
                        if (_businesscode.GetRelationProjectHasHospitals(Convert.ToInt32(GridView.DataKeys[i].Value)).Count != 0)       //--Var
                        {
                            _businesscode.DeleteRelationProjectHasHospitals(RecordID);                                                  //--Var
                        }
                        if (_businesscode.GetRelationProjectHasProjectManagers(Convert.ToInt32(GridView.DataKeys[i].Value)).Count != 0) //--Var
                        {
                            _businesscode.DeleteRelationProjectHasProjectManagers(RecordID);                                            //--Var
                        }
                        _businesscode.DeleteContract(-1, string.Format("OR Project_ID = {0}", RecordID));
                        _businesscode.DeleteProject(RecordID); //--Var
                    }
                }
            }
            Response.Redirect("../Site/ProjectPage.aspx");
        }
Beispiel #2
0
        private void UpdateData()
        {
            string lbName;
            var    listboxData = new ListBox();

            List <int> ListDataIDs = GetDataIDs();

            for (int i = 0; i < ListDataIDs.Count; i++)
            {
                var      container = Master.FindControl("Body");
                string[] input     = new string[10];

                for (int i2 = 0; i2 <= 2; i2++) //--Var
                {
                    string tbName = "tbEdit" + i.ToString() + i2.ToString();
                    var    txtBox = container.FindControl(tbName);

                    switch (i2)
                    {
                    case 0:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            goto track1;
                        }
                        else
                        {
                            input[i2] = _business.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        }
                        break;

                    case 1:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            input[i2] = DateTime.Today.ToString();
                        }
                        else
                        {
                            input[i2] = (((TextBox)txtBox).Text.ToString());
                        }
                        break;

                    case 2:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            input[i2] = DateTime.Today.ToString();
                        }
                        else
                        {
                            input[i2] = (((TextBox)txtBox).Text.ToString());
                        }
                        break;
                    }
                }

                UserCode LoginUser = (UserCode)Session["authenticatedUser"];
                UserCode user      = GetCurrentUser(LoginUser.ID);

                DateTime dt      = DateTime.Now;
                string   dateNow = dt.ToString("yyyy-MM-dd");

                _business.UpdateProject(new ProjectCode(ListDataIDs[i], input[0], Convert.ToDateTime(input[1]), Convert.ToDateTime(input[2]), user.ID, Convert.ToDateTime(dateNow), Convert.ToDateTime(dateNow))); //--Var

                lbName      = "lbEdit" + i.ToString() + "0";
                listboxData = container.FindControl(lbName) as ListBox;

                _business.DeleteRelationProjectHasCRAs(ListDataIDs[i]); //--Var

                if (listboxData.SelectedIndex.ToString().Count() != 0)
                {
                    foreach (ListItem l in listboxData.Items)
                    {
                        if (l.Selected == true)
                        {
                            _business.AddCRAToProject(Convert.ToInt32(l.Value), ListDataIDs[i]); //--Var
                        }
                    }
                }

                lbName      = "lbEdit" + i.ToString() + "1";
                listboxData = container.FindControl(lbName) as ListBox;

                _business.DeleteRelationProjectHasDoctors(ListDataIDs[i]); //--Var

                if (listboxData.SelectedIndex.ToString().Count() != 0)
                {
                    foreach (ListItem l in listboxData.Items)
                    {
                        if (l.Selected == true)
                        {
                            _business.AddDoctorToProject(Convert.ToInt32(l.Value), ListDataIDs[i]); //--Var
                        }
                    }
                }

                lbName      = "lbEdit" + i.ToString() + "2";
                listboxData = container.FindControl(lbName) as ListBox;

                _business.DeleteRelationProjectHasHospitals(ListDataIDs[i]); //--Var

                if (listboxData.SelectedIndex.ToString().Count() != 0)
                {
                    foreach (ListItem l in listboxData.Items)
                    {
                        if (l.Selected == true)
                        {
                            _business.AddHospitalToProject(Convert.ToInt32(l.Value), ListDataIDs[i]); //--Var
                        }
                    }
                }

                lbName      = "lbEdit" + i.ToString() + "3";
                listboxData = container.FindControl(lbName) as ListBox;

                _business.DeleteRelationProjectHasProjectManagers(ListDataIDs[i]); //--Var

                if (listboxData.SelectedIndex.ToString().Count() != 0)
                {
                    foreach (ListItem l in listboxData.Items)
                    {
                        if (l.Selected == true)
                        {
                            _business.AddProjectManagerToProject(Convert.ToInt32(l.Value), ListDataIDs[i]); //--Var
                        }
                    }
                }
track1:
                continue;
            }
        }