Example #1
0
        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.GetRelationStudyCoordinatorHasDoctors(Convert.ToInt32(GridView.DataKeys[i].Value)).Count != 0) //--Var
                        {
                            _businesscode.DeleteRelationStudyCoordinatorHasDoctors(RecordID);                                            //--Var
                        }
                        _businesscode.DeleteEvaluation(-1, string.Format("OR StudyCoordinator_ID = {0}", RecordID));
                        _businesscode.DeleteStudyCoordinator(RecordID); //--Var
                    }
                }
            }
            Response.Redirect("../Site/StudyCoordinatorPage.aspx"); //--Var
        }
Example #2
0
        private void UpdateData()
        {
            List <int> ListDataIDs = GetSessionDataIDs();

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

                for (int i2 = 0; i2 <= 5; 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] = "";
                        }
                        else
                        {
                            input[i2] = (((TextBox)txtBox).Text.ToString());
                        }
                        break;

                    case 2:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            input[i2] = "";
                        }
                        else
                        {
                            if (_business.IsValidEmail(((TextBox)txtBox).Text.ToString()))
                            {
                                input[i2] = (((TextBox)txtBox).Text.ToString());
                            }
                            else
                            {
                                //error---------------------------------------
                                input[i2] = "error invalid email";
                            }
                        }

                        break;

                    case 3:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            input[i2] = "";
                        }
                        else
                        {
                            if (_business.IsValidPhone(((TextBox)txtBox).Text.ToString()))
                            {
                                input[i2] = (((TextBox)txtBox).Text.ToString());
                            }
                            else
                            {
                                //error---------------------------------------
                                input[i2] = "error invalid phone";
                            }
                        }
                        break;

                    case 4:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            input[i2] = "";
                        }
                        else
                        {
                            if (_business.IsValidPhone(((TextBox)txtBox).Text.ToString()))
                            {
                                input[i2] = (((TextBox)txtBox).Text.ToString());
                            }
                            else
                            {
                                //error---------------------------------------
                                input[i2] = "error invalid phone";
                            }
                        }
                        break;

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

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

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

                _business.UpdateStudyCoordinator(ListDataIDs[i], input[0], input[1], input[2], input[3], input[4], input[5], user.User_ID.ToString(), dateNow); //--Var

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

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

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