Пример #1
0
        protected void TextBox2_Click(object sender, EventArgs e)
        {
            string date = default_datetimepicker.Text;
            if (String.IsNullOrEmpty(date))
            {
                date = "10/10/2010";
            }
            string[] words = date.Split('/');
            DateTime dateRequestedFor = new DateTime(Convert.ToInt32(words[2]), Convert.ToInt32(words[1]), Convert.ToInt32(words[0]));
            DateTime dateRequestedOn = DateTime.Today;

            try
            {
                clientVehicleNumber = Convert.ToInt32(VehicleDDL.SelectedItem.Value);
            }
            catch(Exception)
            {
                Lbl.Text = "Please select a vehicle";
            }

            if(CheckBox1.Checked)
            {
                if(CheckBox2.Checked)
                {
                    if(Minor.Checked)
                    {
                        modtype = "Modification and Minor Service";
                    }
                    else
                    {
                        modtype = "Modification and Major Service";
                    }
                }
                else
                {
                    modtype = "Modification";
                }
            }
            else
            {
                if (CheckBox2.Checked)
                {
                    if (Minor.Checked)
                    {
                        modtype = "Minor Service";
                    }
                    else
                    {
                        modtype = "Major Service";
                    }
                }
            }

            string projectDescription = txtProjectDescription.Text;

            if (CheckBox1.Checked == false && Major.Checked == false && Minor.Checked == false)
            {
                Lbl.Text = "Please select whether you would like to modify your vehicle and/or service it";
            }
            else if (CheckBox1.Checked == true && string.IsNullOrWhiteSpace(projectDescription))
            {
                Lbl.Text = "You have selected to Modify Your Vehicle - Please enter a description of what you would like Tweek performance to do";
            }
            else if (string.IsNullOrWhiteSpace(default_datetimepicker.Text)|| dateRequestedFor < dateRequestedOn)
            {
                Lbl.Text = "You have selected a valid date for the project";
            }
            else
            {
                ProjectRequest newPR = new ProjectRequest(0, usernumber, clientVehicleNumber, dateRequestedFor, dateRequestedOn, 1, projectDescription, modtype);
                try
                {
                    Label lblMasterStatus = (Label)Master.FindControl("message");
                    lblMasterStatus.Visible = true;
                    lblMasterStatus.Text = newPR.InsertNewProjectRequest(newPR);
                }
                catch(Exception)
                {
                    Label lblMasterStatus = (Label)Master.FindControl("message");
                    lblMasterStatus.Visible = true;
                    lblMasterStatus.Text = newPR.InsertNewProjectRequest(newPR);
                }
                Response.Redirect("/");
            }
        }