Beispiel #1
0
        private void SendData()
        {
            for (int i = 0; i < 10; i++)
            {
                var      container = Master.FindControl("Body");
                string[] input     = new string[10];

                for (int i2 = 0; i2 <= 9; 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
                        {
                            if (_business.IsValidEmail(((TextBox)txtBox).Text.ToString()))
                            {
                                input[i2] = (((TextBox)txtBox).Text.ToString());
                            }
                            else
                            {
                                //error---------------------------------------
                                input[i2] = "error invalid email";
                            }
                        }

                        break;

                    case 2:
                        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 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
                        {
                            input[i2] = _business.BeginUpperCase((((TextBox)txtBox).Text.ToString()));
                        }
                        break;

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

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

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

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

                    case 9:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            input[i2] = "";
                        }
                        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.AddDoctor(new DoctorCode(0, input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7], input[8], input[9], user.ID, Convert.ToDateTime(dateNow), Convert.ToDateTime(dateNow))); //--Var

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

                if (listboxData.SelectedIndex.ToString().Count() != 0)
                {
                    foreach (ListItem l in listboxData.Items)
                    {
                        if (l.Selected == true)
                        {
                            DoctorCode doctor = _business.GetDoctors(sortingPar).Last();                   //--Var
                            _business.AddHospitalToDoctor(Convert.ToInt32(l.Value.ToString()), doctor.ID); //--Var
                        }
                    }
                }
track1:
                continue;
            }
        }