コード例 #1
0
ファイル: route.ascx.cs プロジェクト: dilip07156/TLGXWebApp
        protected void frmRouote_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            DropDownList ddlFrom                 = (DropDownList)frmRouote.FindControl("ddlFrom");
            DropDownList ddlModeOfTransport      = (DropDownList)frmRouote.FindControl("ddlModeOfTransport");
            DropDownList ddlNameOfPlace          = (DropDownList)frmRouote.FindControl("ddlNameOfPlace");
            DropDownList ddlTransportType        = (DropDownList)frmRouote.FindControl("ddlTransportType");
            TextBox      txtDistanceFromProperty = (TextBox)frmRouote.FindControl("txtDistanceFromProperty");
            TextBox      txtDescription          = (TextBox)frmRouote.FindControl("txtDescription");
            TextBox      txtApproximateDuration  = (TextBox)frmRouote.FindControl("txtApproximateDuration");
            TextBox      txtValidFrom            = (TextBox)frmRouote.FindControl("txtValidFrom");
            TextBox      txtValidTo              = (TextBox)frmRouote.FindControl("txtValidTo");
            TextBox      txtDrivingDirection     = (TextBox)frmRouote.FindControl("txtDrivingDirection");



            if (e.CommandName.ToString() == "Add")
            {
                TLGX_Consumer.MDMSVC.DC_Accommodation_RouteInfo newObj = new MDMSVC.DC_Accommodation_RouteInfo
                {
                    Accommodation_Id       = Guid.Parse(Request.QueryString["Hotel_Id"]),
                    Accommodation_Route_Id = Guid.NewGuid(),
                    Create_Date            = DateTime.Now,
                    Create_User            = System.Web.HttpContext.Current.User.Identity.Name,
                    Description            = txtDescription.Text.Trim(),
                    ApproximateDuration    = txtApproximateDuration.Text.Trim(),
                    DistanceFromProperty   = txtDistanceFromProperty.Text.Trim(),
                    DrivingDirection       = txtDrivingDirection.Text.Trim(),
                    FromPlace       = ddlFrom.SelectedItem.ToString(),
                    ModeOfTransport = ddlModeOfTransport.SelectedItem.ToString(),
                    TransportType   = ddlTransportType.SelectedItem.ToString(),
                    ValidFrom       = DateTime.ParseExact(txtValidFrom.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture),
                    ValidTo         = DateTime.ParseExact(txtValidTo.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture),
                    NameOfPlace     = ddlNameOfPlace.SelectedItem.Text.Trim(),
                    IsActive        = true
                };

                if (AccSvc.AddHowToReach(newObj))
                {
                    frmRouote.DataBind();
                    BindRoutes();
                    GetLookupData();
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "Route Data has been added successfully", BootstrapAlertType.Success);
                }
                else
                {
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning);
                }
            }

            else if (e.CommandName.ToString() == "Save")
            {
                Accommodation_Id = new Guid(Request.QueryString["Hotel_Id"]);
                Guid myRow_Id = Guid.Parse(grdRoutes.SelectedDataKey.Value.ToString());

                var result = AccSvc.GetHowToReachDetails(Accommodation_Id, myRow_Id);


                if (result.Count > 0)
                {
                    TLGX_Consumer.MDMSVC.DC_Accommodation_RouteInfo newObj = new MDMSVC.DC_Accommodation_RouteInfo

                    {
                        Accommodation_Id       = Guid.Parse(Request.QueryString["Hotel_Id"]),
                        Accommodation_Route_Id = myRow_Id,
                        Create_Date            = DateTime.Now,
                        Create_User            = System.Web.HttpContext.Current.User.Identity.Name,
                        Description            = txtDescription.Text.Trim(),
                        ApproximateDuration    = txtApproximateDuration.Text.Trim(),
                        DistanceFromProperty   = txtDistanceFromProperty.Text.Trim(),
                        DrivingDirection       = txtDrivingDirection.Text.Trim(),
                        FromPlace       = ddlFrom.SelectedItem.ToString(),
                        ModeOfTransport = ddlModeOfTransport.SelectedItem.ToString(),
                        TransportType   = ddlTransportType.SelectedItem.ToString(),
                        ValidFrom       = DateTime.ParseExact(txtValidFrom.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture),
                        ValidTo         = DateTime.ParseExact(txtValidTo.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture),
                        NameOfPlace     = ddlNameOfPlace.SelectedItem.Text.Trim(),
                        IsActive        = true
                    };

                    if (AccSvc.UpdateHowToReach(newObj))
                    {
                        Accommodation_Id = new Guid(Request.QueryString["Hotel_Id"]);
                        frmRouote.ChangeMode(FormViewMode.Insert);
                        frmRouote.DataBind();
                        BindRoutes();
                        GetLookupData();
                        BootstrapAlert.BootstrapAlertMessage(dvMsg, "Route Data has been updated successfully", BootstrapAlertType.Success);
                    }
                    else
                    {
                        BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning);
                    }
                }
            }
        }