Beispiel #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string selectedservices = GetSelectedServicesId(gvInterior); //+ GetSelectedServicesId(gv_exterior);

            if (txtCFname.Text.ToString().Trim() == string.Empty)
            {
                throw new Exception("Opps! First Name is required.");
            }
            else if (txtCLname.Text.ToString().Trim() == string.Empty)
            {
                throw new Exception("Opps! Lame Name is required.");
            }
            else if (txtCphoneNumber.Text.ToString().Trim() == string.Empty)
            {
                throw new Exception("Opps! Mobile is required.");
            }
            else if (txtCus_Email.Text.ToString().Trim() == string.Empty)
            {
                throw new Exception("Opps! Email is required.");
            }
            else if (ddlCcartype.SelectedValue.ToString() == "0")
            {
                throw new Exception("Opps! Car model is required.");
            }
            else if (txtscheduleddate.Text == string.Empty)
            {
                throw new Exception("Opps! Date is required.");
            }
            else if (selectedservices == "")
            {
                throw new Exception("Please atleast 1(one) of our service");
            }
            else
            {
                //  string selectedservices = GetSelectedServicesId(gvInterior) + GetSelectedServicesId(gv_exterior);
                //insert here the validation code or on javascript
                //add update panel to avoid postback
                myAppointment.CustomerId      = 0;
                myAppointment.Lname           = txtCLname.Text.ToString();
                myAppointment.Fname           = txtCFname.Text.ToString();
                myAppointment.Address         = txtCAddress.Text.ToString();
                myAppointment.Mobile          = txtCphoneNumber.Text.ToString().Trim();
                myAppointment.Email           = txtCus_Email.Text.ToString().Trim();
                myAppointment.Carmodel        = Convert.ToInt32(ddlCcartype.SelectedValue.ToString());
                myAppointment.ServiceProvider = txtServiceProvider.Text.ToString().Trim();
                myAppointment.ScheduledDate   = Convert.ToDateTime(txtscheduleddate.Text.ToString());
                myAppointment.ScheduledTime   = ddlCTime.SelectedValue.ToString();
                myAppointment.VehicleType     = ddlvehicletype.SelectedValue.ToString();
                myAppointment.VehicleColor    = txtcolor.Text.ToString();
                myAppointment.VehicleModel    = txtcarmodel.Text.ToString();
                int result = myAppointment.AccessAppointment(selectedservices.Trim());
                if (result > 0)
                {
                    div_error.Visible = false;
                    //if not card payment is selected
                    if (ddlpaymenttype.SelectedValue.ToString() == "CASH")
                    {
                        Response.Redirect("~/successful.aspx");
                    }
                    else//CREDIT CARD
                    {
                        //get customer id by mobile number
                        string custreservationid = myAppointment.GetCustomerId(txtCphoneNumber.Text.ToString());
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Openwindow", string.Format("window.open('payment.aspx?id={0}');", custreservationid), true);//this will open new tab for payment checkout.
                    }
                }
                else
                {
                    lblerror.Text     = "Ooopps! Something went wrong!" + result.ToString();
                    div_error.Visible = true;
                }
            }
        }
        catch (Exception error)
        {
            lblerror.Text     = error.Message.ToString();
            div_error.Visible = true;
        }
    }