Beispiel #1
0
        private void SendData()
        {
            List <List <string> > ListContentProject = _business.GetProjectDropDownContent();
            List <List <string> > ListContentClient  = _business.GetClientDropDownContent();
            var container = Master.FindControl("Body");

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

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

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

                    case 1:
                        if (String.IsNullOrWhiteSpace(((TextBox)txtBox).Text.ToString()))
                        {
                            input[i2] = 0.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;

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

                string ddNameProject       = "ddEdit" + i.ToString() + "0";
                var    dropdownDataProject = container.FindControl(ddNameProject) as DropDownList;
                int    indexProject        = dropdownDataProject.SelectedIndex;

                string ddNameClient       = "ddEdit" + i.ToString() + "1";
                var    dropdownDataClient = container.FindControl(ddNameClient) as DropDownList;
                int    indexClient        = dropdownDataClient.SelectedIndex;

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

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

                if (indexClient < 1 || indexProject < 1)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('Make sure you have selected a relation.')", true);
                }
                else
                {
                    _business.AddContract(new ContractCode(0, input[0], Convert.ToDouble(input[1]), Convert.ToDateTime(input[2]), Convert.ToDateTime(input[3]), Convert.ToInt16(ListContentClient[indexClient - 1][0]), Convert.ToInt16(ListContentProject[indexProject - 1][0]), user.ID, Convert.ToDateTime(dateNow), Convert.ToDateTime(dateNow)));
                }
track1:
                continue;
            }
        }