Ejemplo n.º 1
0
    protected void GrdCrew_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        UserAccess UA = new UserAccess();

        try
        {
            if (e.CommandName == "AddPax")
            {
                BLL_TRV_TravelRequest Req = new BLL_TRV_TravelRequest();

                Req.AddPaxToTravelRequest(RequestID, Convert.ToInt32(e.CommandArgument.ToString()), Convert.ToInt32(Session["USERID"].ToString()), 0, 0);

                string js = "alert('Pax has been added successfully.');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ALR", js, true);

                //Response.Write("<script type='text/javascript'>alert('Pax has been added successfully.');</script>");
                Req = null;
            }
        }
        catch { }
        finally { UA = null; }
    }
Ejemplo n.º 2
0
    protected void cmdSaveRequest_Click(object sender, EventArgs e)
    {
        if (UDFLib.ConvertToInteger(Vessel_List.SelectedValue) > 0)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["Request_ID"]))
            {
                CheckForChangesInRequest();
            }
            string isReturn;
            int    CreatedBy, isSeaman;
            int    VoyageID = UDFLib.ConvertToInteger(Request.QueryString["VoyageID"]);
            int    EventID  = UDFLib.ConvertToInteger(Request.QueryString["EventID"]);


            if (chkSeaman.Checked)
            {
                isSeaman = 1;
            }
            else
            {
                isSeaman = 0;
            }

            if (chkReturn.Checked)
            {
                isReturn = "RETURN";
            }
            else
            {
                isReturn = "ONEWAY";
            }

            DataTable dtPax = (DataTable)ViewState["DataTable"];

            if (dtPax.Rows.Count > 0)
            {
                BLL_TRV_TravelRequest TReq          = new BLL_TRV_TravelRequest();
                TRV_Request           ReqProperties = new TRV_Request();
                try
                {
                    int i, requestid = 0; Boolean Issavingpax = true;
                    CreatedBy = Convert.ToInt32(Session["USERID"].ToString());


                    foreach (GridViewRow gr in GrdFlight.Rows)
                    {
                        UserControl_ctlAirPortList txtFrom1 = (gr.FindControl("txtFrom1") as UserControl_ctlAirPortList);
                        UserControl_ctlAirPortList txtTo1   = (gr.FindControl("txtTo1") as UserControl_ctlAirPortList);
                        TextBox      txtDepDate1            = (gr.FindControl("txtDepDate1") as TextBox);
                        DropDownList cmbDepHours1           = (gr.FindControl("cmbDepHours1") as DropDownList);
                        DropDownList cmbDepMins1            = (gr.FindControl("cmbDepMins1") as DropDownList);

                        if (string.IsNullOrEmpty(txtFrom1.Text))
                        {
                            string js = "alert('Please select from !');";
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "txtFrom1", js, true);

                            return;
                        }


                        if (string.IsNullOrEmpty(txtTo1.Text))
                        {
                            string js = "alert('Please select To !');";
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "txtTo1", js, true);

                            return;
                        }



                        if (txtFrom1.Text.Trim() != "" && txtTo1.Text.Trim() != "" && Issavingpax)  // save pax and first segment
                        {
                            Issavingpax = false;

                            for (i = 0; i < dtPax.Rows.Count; i++)
                            {
                                //to add all pax to the request after the default one, i.e. first / lead pax
                                if (i == 0)
                                {
                                    StringBuilder sbMainChanges_Remark = new StringBuilder("");
                                    if (Changes_Remark.ToString() != "")
                                    {
                                        sbMainChanges_Remark.Append("<div style='font-size:11px;font-family:Tahoma'>");
                                        sbMainChanges_Remark.Append(Changes_Remark.ToString());
                                        sbMainChanges_Remark.Append("</div>");
                                    }

                                    ReqProperties.StaffID = Convert.ToInt32(dtPax.Rows[i]["id"].ToString());

                                    ReqProperties.Travel_Class     = cmbTravelClass.SelectedValue;
                                    ReqProperties.Is_Seaman_Ticket = isSeaman;
                                    ReqProperties.Travel_Type      = isReturn;


                                    ReqProperties.isPersonal_Ticket = 0;

                                    ReqProperties.Travel_Origin      = txtFrom1.Text;
                                    ReqProperties.Departure_Date     = txtDepDate1.Text;
                                    ReqProperties.Travel_Destination = txtTo1.Text;
                                    //ReqProperties.Return_Date = txtArrDate1.Text;
                                    //ReqProperties.Preferred_Airline = txtPrefAirline1.Text;
                                    //ReqProperties.Preferred_Departure_Time = txtPrefTime1.Text;
                                    ReqProperties.Created_By = CreatedBy;
                                    ReqProperties.Remarks    = txtRequestRemarks.Text;

                                    ReqProperties.PrefDepMin = cmbDepMins1.SelectedItem.Text;
                                    ReqProperties.PrefDepHrs = cmbDepHours1.SelectedItem.Text;

                                    requestid = TReq.CreateTravelRequest(ReqProperties, UDFLib.ConvertToInteger(Vessel_List.SelectedValue), UDFLib.ConvertToInteger(Request.QueryString["Request_ID"])
                                                                         , sbMainChanges_Remark.ToString());
                                }
                                else
                                {
                                    TReq.AddPaxToTravelRequest(requestid, Convert.ToInt32(dtPax.Rows[i]["id"].ToString()), CreatedBy, VoyageID, EventID);
                                }
                            }
                        }

                        else if (txtFrom1.Text.Trim() != "" && txtTo1.Text.Trim() != "")  //ADDING from  SECOND segment  DETAIL IF VALID
                        {
                            ReqProperties.Travel_Class     = cmbTravelClass.SelectedValue;
                            ReqProperties.Is_Seaman_Ticket = isSeaman;
                            ReqProperties.Travel_Type      = isReturn;

                            ReqProperties.isPersonal_Ticket = 0;

                            ReqProperties.Travel_Origin      = txtFrom1.Text;
                            ReqProperties.Departure_Date     = txtDepDate1.Text;
                            ReqProperties.Travel_Destination = txtTo1.Text;
                            //ReqProperties.Return_Date = txtArrDate2.Text;
                            //ReqProperties.Preferred_Airline = txtPrefAirline2.Text;
                            //ReqProperties.Preferred_Departure_Time = txtPrefTime2.Text;
                            ReqProperties.Created_By = CreatedBy;
                            ReqProperties.Remarks    = txtRequestRemarks.Text;
                            ReqProperties.PrefDepMin = cmbDepMins1.SelectedItem.Text;
                            ReqProperties.PrefDepHrs = cmbDepHours1.SelectedItem.Text;


                            //ONLY LEADPAX DETAIL HAS TO BE SAVED
                            ReqProperties.StaffID = Convert.ToInt32(dtPax.Rows[0]["id"].ToString());

                            TReq.AddFlightToTravelRequest(requestid, ReqProperties);
                        }
                    }


                    if (!string.IsNullOrEmpty(Request.QueryString["Request_ID"]))
                    {
                        string js = "window.opener.location.href='RequestList.aspx';window.open('','_self');window.close();";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "msg2", js, true);
                    }
                    else
                    {
                        Response.Redirect("RequestList.aspx");
                    }
                }
                catch { throw; }
                finally { TReq = null; ReqProperties = null; }
            }

            else
            {
                string msgPax = "alert('Add at least 1 Pax !');";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "msgPax", msgPax, true);
            }
        }
        else
        {
            string js = "alert('Please select vessel !');";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "msgvsl", js, true);
        }
    }