コード例 #1
0
        protected void frmLandmark_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            DropDownList ddlPlaceCategory = (DropDownList)frmLandmark.FindControl("ddlPlaceCategory");
            DropDownList ddlUnitOfMeasure = (DropDownList)frmLandmark.FindControl("ddlUnitOfMeasure");

            TextBox txtDescription = (TextBox)frmLandmark.FindControl("txtDescription");
            TextBox txtPlaceName   = (TextBox)frmLandmark.FindControl("txtPlaceName");
            TextBox txtDistance    = (TextBox)frmLandmark.FindControl("txtDistance");

            if (e.CommandName.ToString() == "Add")
            {
                TLGX_Consumer.MDMSVC.DC_Accommodation_NearbyPlaces newObj = new MDMSVC.DC_Accommodation_NearbyPlaces
                {
                    Accommodation_NearbyPlace_Id = Guid.NewGuid(),
                    Accomodation_Id      = Guid.Parse(Request.QueryString["Hotel_Id"]),
                    Description          = txtDescription.Text.Trim(),
                    DistanceFromProperty = txtDistance.Text.Trim(),
                    DistanceUnit         = ddlUnitOfMeasure.SelectedItem.Text,
                    PlaceCategory        = ddlPlaceCategory.SelectedItem.Text,
                    PlaceName            = txtPlaceName.Text.Trim(),

                    Create_Date = DateTime.Now,
                    Create_User = System.Web.HttpContext.Current.User.Identity.Name,

                    IsActive = true
                };
                if (AccSvc.AddNearbyPlaces(newObj))
                {
                    BindNearbyPlaces();

                    frmLandmark.DataBind();
                    frmLandmark.ChangeMode(FormViewMode.Insert);

                    GetLookupValues();
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "In and Around has been added successfully", BootstrapAlertType.Success);
                }
                else
                {
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning);
                }
            }


            if (e.CommandName.ToString() == "Modify")
            {
                Accomodation_ID = new Guid(Request.QueryString["Hotel_Id"]);
                Guid myRow_Id = Guid.Parse(grdInAndAround.SelectedDataKey.Value.ToString());

                var result = AccSvc.GetNearbyPlacesDetails(Accomodation_ID, myRow_Id);

                if (result.Count > 0)
                {
                    TLGX_Consumer.MDMSVC.DC_Accommodation_NearbyPlaces newObj = new MDMSVC.DC_Accommodation_NearbyPlaces
                    {
                        Accommodation_NearbyPlace_Id = myRow_Id,
                        Accomodation_Id      = Guid.Parse(Request.QueryString["Hotel_Id"]),
                        Description          = txtDescription.Text.Trim(),
                        DistanceFromProperty = txtDistance.Text.Trim(),
                        DistanceUnit         = ddlUnitOfMeasure.SelectedItem.Text,
                        PlaceCategory        = ddlPlaceCategory.SelectedItem.Text,
                        PlaceName            = txtPlaceName.Text.Trim(),
                        Edit_Date            = DateTime.Now,
                        Edit_User            = System.Web.HttpContext.Current.User.Identity.Name,
                        IsActive             = true
                    };

                    if (AccSvc.UpdateNearbyPlaces(newObj))
                    {
                        BindNearbyPlaces();
                        frmLandmark.ChangeMode(FormViewMode.Insert);
                        frmLandmark.DataBind();

                        GetLookupValues();
                        BootstrapAlert.BootstrapAlertMessage(dvMsg, "In and Around has been updated successfully", BootstrapAlertType.Success);
                    }
                    else
                    {
                        BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning);
                    }
                }
            }
            ;
        }