Ejemplo n.º 1
0
        public void SetListBoxContent()
        {
            if (!IsPostBack)
            {
                for (int i = 0; i <= 9; i++)
                {
                    List <List <string> > ListDropdownContent = _business.GetHospitalDropDownContent(); //--Var
                    List <string>         Names = new List <string>();

                    string lbEdit       = "lbEdit" + i.ToString() + "0";
                    var    container    = Master.FindControl("Body");
                    var    DropDownData = container.FindControl(lbEdit) as ListBox;

                    for (int i2 = 0; i2 < ListDropdownContent.Count; i2++)
                    {
                        Names.Add(ListDropdownContent[i2][1]);
                    }
                    DropDownData.DataSource = Names;
                    DropDownData.DataBind();

                    for (int i2 = 0; i2 < ListDropdownContent.Count; i2++)
                    {
                        DropDownData.Items[i2].Value = ListDropdownContent[i2][0];
                    }
                }
            }
        }
        private void SendData()
        {
            var container = Master.FindControl("Body");
            List <List <string> > ListContentHospital = _business.GetHospitalDropDownContent();

            for (int i = 0; i <= 9; i++)
            {
                string[] input = new string[10];

                for (int i2 = 0; i2 <= 9; i2++)
                {
                    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;
                    }
                }
                string ddName       = "ddEdit" + i.ToString() + "0";
                var    dropdownData = container.FindControl(ddName) as DropDownList;
                int    index        = dropdownData.SelectedIndex;

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

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

                _business.AddDepartment(input[0], input[1], input[2], Convert.ToInt16(ListContentHospital[index - 1][0]), user.User_ID.ToString(), dateNow, dateNow);
track1:
                continue;
            }
        }