protected void frmEditCountryMap_ItemCommand(object sender, FormViewCommandEventArgs e) { Label lblSupplierName = (Label)frmEditCountryMap.FindControl("lblSupplierName"); Label lblSupplierCode = (Label)frmEditCountryMap.FindControl("lblSupplierCode"); Label lblSupCountryName = (Label)frmEditCountryMap.FindControl("lblSupCountryName"); Label lblSupCountryCode = (Label)frmEditCountryMap.FindControl("lblSupCountryCode"); DropDownList ddlSystemCountryName = (DropDownList)frmEditCountryMap.FindControl("ddlSystemCountryName"); TextBox txtSystemCountryCode = (TextBox)frmEditCountryMap.FindControl("txtSystemCountryCode"); DropDownList ddlStatus = (DropDownList)frmEditCountryMap.FindControl("ddlStatus"); TextBox txtSystemRemark = (TextBox)frmEditCountryMap.FindControl("txtSystemRemark"); TextBox txtISO2CHAR = (TextBox)frmEditCountryMap.FindControl("txtISO2CHAR"); TextBox txtISO3CHAR = (TextBox)frmEditCountryMap.FindControl("txtISO3CHAR"); Button btnMatchedMapSelected = (Button)frmEditCountryMap.FindControl("btnMatchedMapSelected"); Button btnMatchedMapAll = (Button)frmEditCountryMap.FindControl("btnMatchedMapAll"); if (e.CommandName == "Add") { Guid? countryid = null; string code = string.Empty; string name = string.Empty; Guid myRow_Id = Guid.Parse(grdCountryMaps.SelectedDataKey.Value.ToString()); //SupplierMasters sData = new SupplierMasters(); //sData = masters.GetSupplierDataByMapping_Id("country", myRow_Id); MDMSVC.DC_Supplier_DDL sData = new MDMSVC.DC_Supplier_DDL(); sData = _objMasterSVC.GetSupplierDataByMapping_Id("COUNTRY", Convert.ToString(myRow_Id)); if (!(ddlSystemCountryName.SelectedIndex == 0)) { countryid = new Guid(ddlSystemCountryName.SelectedItem.Value); code = masters.GetCodeById("country", new Guid(ddlSystemCountryName.SelectedItem.Value)); name = ddlSystemCountryName.SelectedItem.Text; } MDMSVC.DC_CountryMapping newObj = new MDMSVC.DC_CountryMapping { CountryMapping_Id = myRow_Id, Country_Id = countryid, Supplier_Id = sData.Supplier_Id, SupplierName = sData.Name, Code = code, Status = ddlStatus.SelectedItem.Text, Name = name, Remarks = txtSystemRemark.Text, Edit_Date = DateTime.Now, Edit_User = System.Web.HttpContext.Current.User.Identity.Name, }; List <MDMSVC.DC_CountryMapping> RQUpCountry = new List <MDMSVC.DC_CountryMapping>(); RQUpCountry.Add(newObj); if (mapperSVc.UpdateCountryMappingDatat(RQUpCountry)) { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Record has been updated successfully", BootstrapAlertType.Success); //frmEditCountryMap.Visible = false; MatchedPageIndex = 0; MappedCountry_ID = countryid; MatchedSupplierName = lblSupCountryName.Text; MatchedStatus = ddlStatus.SelectedItem.Text; //if (ddlStatus.SelectedItem.Text == "MAPPED") if (!(ddlStatus.SelectedItem.Text == "DELETE")) { fillmatchingdata(); fillmappingdata(); dvMatchingRecords.Visible = true; btnMatchedMapSelected.Visible = true; btnMatchedMapAll.Visible = true; } else if (ddlStatus.SelectedItem.Text == "DELETE") { dvMsgForDelete.Visible = true; BootstrapAlert.BootstrapAlertMessage(dvMsgForDelete, "Record has been updated successfully", BootstrapAlertType.Success); dvMatchingRecords.Visible = false; btnMatchedMapSelected.Visible = false; btnMatchedMapAll.Visible = false; } } hdnFlag.Value = "false"; } else if (e.CommandName == "Cancel") { dvMsg.Style.Add("display", "none"); frmEditCountryMap.ChangeMode(FormViewMode.Edit); frmEditCountryMap.DataSource = null; frmEditCountryMap.DataBind(); frmEditCountryMap.Visible = false; dvMatchingRecords.Visible = false; btnMatchedMapSelected.Visible = false; btnMatchedMapAll.Visible = false; fillmappingdata(); hdnFlag.Value = "false"; } else if (e.CommandName == "MapSelected") { List <MDMSVC.DC_CountryMapping> RQ = new List <MDMSVC.DC_CountryMapping>(); Guid myRow_Id = Guid.Empty; Guid mySupplier_Id = Guid.Empty; Guid?myCountry_Id = Guid.Empty; foreach (GridViewRow row in grdMatchingCountry.Rows) { //CheckBox chk = row.Cells[7].Controls[1] as CheckBox; HtmlInputCheckBox chk = row.Cells[7].Controls[1] as HtmlInputCheckBox; if (chk != null && chk.Checked) { myRow_Id = Guid.Empty; mySupplier_Id = Guid.Empty; myCountry_Id = Guid.Empty; int index = row.RowIndex; myRow_Id = Guid.Parse(grdMatchingCountry.DataKeys[index].Values[0].ToString()); mySupplier_Id = Guid.Parse(grdMatchingCountry.DataKeys[index].Values[1].ToString()); myCountry_Id = MappedCountry_ID; } if (myRow_Id != Guid.Empty) { MDMSVC.DC_CountryMapping param = new MDMSVC.DC_CountryMapping(); param.CountryMapping_Id = myRow_Id; if (mySupplier_Id != null) { param.Supplier_Id = mySupplier_Id; } if (myCountry_Id != null) { param.Country_Id = myCountry_Id; } param.Status = MatchedStatus; param.Edit_Date = DateTime.Now; param.Edit_User = System.Web.HttpContext.Current.User.Identity.Name; RQ.Add(param); //res = mapperSVc.UpdateCountryMappingDatat(RQ); myRow_Id = Guid.Empty; mySupplier_Id = Guid.Empty; myCountry_Id = Guid.Empty; } } if (mapperSVc.UpdateCountryMappingDatat(RQ)) { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Matching Records are mapped successfully", BootstrapAlertType.Success); fillmatchingdata(); fillmappingdata(); hdnFlag.Value = "false"; } } else if (e.CommandName == "MapAll") { List <MDMSVC.DC_CountryMapping> RQ = new List <MDMSVC.DC_CountryMapping>(); Guid myRow_Id = Guid.Empty; Guid mySupplier_Id = Guid.Empty; Guid?myCountry_Id = Guid.Empty; foreach (GridViewRow row in grdMatchingCountry.Rows) { myRow_Id = Guid.Empty; mySupplier_Id = Guid.Empty; myCountry_Id = Guid.Empty; int index = row.RowIndex; myRow_Id = Guid.Parse(grdMatchingCountry.DataKeys[index].Values[0].ToString()); mySupplier_Id = Guid.Parse(grdMatchingCountry.DataKeys[index].Values[1].ToString()); myCountry_Id = MappedCountry_ID; if (myRow_Id != Guid.Empty) { MDMSVC.DC_CountryMapping param = new MDMSVC.DC_CountryMapping(); param.CountryMapping_Id = myRow_Id; if (mySupplier_Id != null) { param.Supplier_Id = mySupplier_Id; } if (myCountry_Id != null) { param.Country_Id = myCountry_Id; } param.Status = MatchedStatus; param.Edit_Date = DateTime.Now; param.Edit_User = System.Web.HttpContext.Current.User.Identity.Name; RQ.Add(param); myRow_Id = Guid.Empty; mySupplier_Id = Guid.Empty; myCountry_Id = Guid.Empty; } } if (mapperSVc.UpdateCountryMappingDatat(RQ)) { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Matching Records are mapped successfully", BootstrapAlertType.Success); fillmatchingdata(); fillmappingdata(); } hdnFlag.Value = "false"; } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop2" + DateTime.Today.Ticks.ToString(), "javascript:closeCountryMappingModal();", true); }
protected void gvGridExist_RowCommand(object sender, GridViewCommandEventArgs e) { try { GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); int index = row.RowIndex; string myHotelName = ""; string myCountryName = ""; string myCityName = ""; Guid myRow_Id = Guid.Parse(gvGridExist.DataKeys[index].Values[0].ToString()); if (e.CommandName == "Select") { myCountryName = gvGridExist.Rows[index].Cells[1].Text; myCityName = gvGridExist.Rows[index].Cells[2].Text; myHotelName = gvGridExist.Rows[index].Cells[3].Text; MDMSVC.DC_Accomodation OverviewData = new MDMSVC.DC_Accomodation(); OverviewData.Accommodation_Id = myRow_Id; OverviewData.ProductCategory = "Accommodation"; if (!string.IsNullOrEmpty(txtAddCityPlaceId.Text)) { OverviewData.Google_Place_Id = txtAddCityPlaceId.Text.ToString(); } if (!string.IsNullOrEmpty(hdnLat.Value)) { OverviewData.Latitude = hdnLat.Value.ToString(); } if (!string.IsNullOrEmpty(hdnLng.Value)) { OverviewData.Longitude = hdnLng.Value.ToString(); } OverviewData.Edit_Date = DateTime.Now; OverviewData.Edit_User = System.Web.HttpContext.Current.User.Identity.Name; OverviewData.IsActive = true; if (AccSvc.UpdateHotelGeoDetail(OverviewData)) { FormView frmEditProductMap = (FormView)((TLGX_Consumer.controls.staticdata.UpdateSupplierProductMapping) this.Parent.NamingContainer).FindControl("frmEditProductMap"); DropDownList ddlSystemCountryName = (DropDownList)frmEditProductMap.FindControl("ddlSystemCountryName"); DropDownList ddlSystemCityName = (DropDownList)frmEditProductMap.FindControl("ddlSystemCityName"); DropDownList ddlSystemProductName = (DropDownList)frmEditProductMap.FindControl("ddlSystemProductName"); TextBox txtSystemProductCode = (TextBox)frmEditProductMap.FindControl("txtSystemProductCode"); Button btnAddProduct = (Button)frmEditProductMap.FindControl("btnAddProduct"); ddlSystemCountryName.SelectedIndex = ddlSystemCountryName.Items.IndexOf(ddlSystemCountryName.Items.FindByText(myCountryName)); ((TLGX_Consumer.controls.staticdata.UpdateSupplierProductMapping) this.Parent.NamingContainer).fillcities(ddlSystemCityName, ddlSystemCountryName); //ddlSystemCityName.SelectedIndex = ddlSystemCityName.Items.IndexOf(ddlSystemCityName.Items.FindByText(myCityName)); ddlSystemCityName.SelectedIndex = ddlSystemCityName.Items.IndexOf(ddlSystemCityName.Items.Cast <ListItem>().FirstOrDefault(i => i.Text.Equals(myCityName, StringComparison.InvariantCultureIgnoreCase))); ((TLGX_Consumer.controls.staticdata.UpdateSupplierProductMapping) this.Parent.NamingContainer).fillproducts(ddlSystemProductName, ddlSystemCityName, ddlSystemCountryName); ddlSystemProductName.SelectedIndex = ddlSystemProductName.Items.IndexOf(ddlSystemProductName.Items.FindByText(myHotelName)); txtSystemProductCode.Text = masterdata.GetCodeById("product", Guid.Parse(ddlSystemProductName.SelectedItem.Value)); btnAddProduct.Visible = false; this.Parent.Visible = false; gvGridExist.DataSource = null; gvGridExist.DataBind(); } } else if (e.CommandName == "OpenDeactivate") { LinkButton btnDeactivate = (LinkButton)row.Cells[7].Controls[1]; DropDownList ddlExistingHotels = (DropDownList)row.Cells[7].Controls[3]; TextBox txtDeactiveRemark = (TextBox)row.Cells[7].Controls[5]; LinkButton btnProceedDeactivate = (LinkButton)row.Cells[7].Controls[7]; LinkButton btnCancel = (LinkButton)row.Cells[7].Controls[9]; if (btnDeactivate != null) { btnDeactivate.Visible = false; } if (ddlExistingHotels != null) { ddlExistingHotels.Visible = true; } if (txtDeactiveRemark != null) { txtDeactiveRemark.Visible = true; } if (btnProceedDeactivate != null) { btnProceedDeactivate.Visible = true; } if (btnCancel != null) { btnCancel.Visible = true; } } else if (e.CommandName == "CancelDeactivate") { LinkButton btnDeactivate = (LinkButton)row.Cells[7].Controls[1]; DropDownList ddlExistingHotels = (DropDownList)row.Cells[7].Controls[3]; TextBox txtDeactiveRemark = (TextBox)row.Cells[7].Controls[5]; LinkButton btnProceedDeactivate = (LinkButton)row.Cells[7].Controls[7]; LinkButton btnCancel = (LinkButton)row.Cells[7].Controls[9]; if (btnDeactivate != null) { btnDeactivate.Visible = true; } if (ddlExistingHotels != null) { ddlExistingHotels.Visible = false; } if (txtDeactiveRemark != null) { txtDeactiveRemark.Visible = false; } if (btnProceedDeactivate != null) { btnProceedDeactivate.Visible = false; } if (btnCancel != null) { btnCancel.Visible = false; } } else if (e.CommandName == "ProceedDeactivate") { LinkButton btnDeactivate = (LinkButton)row.Cells[7].Controls[1]; DropDownList ddlExistingHotels = (DropDownList)row.Cells[7].Controls[3]; TextBox txtDeactiveRemark = (TextBox)row.Cells[7].Controls[5]; LinkButton btnProceedDeactivate = (LinkButton)row.Cells[7].Controls[7]; LinkButton btnCancel = (LinkButton)row.Cells[7].Controls[9]; if (ddlExistingHotels.SelectedItem.Value == "0") { Guid NewHotel_Id = Guid.NewGuid(); ShiftMapping(myRow_Id, NewHotel_Id, txtDeactiveRemark.Text); if (AddHotel(NewHotel_Id)) { if (DeactivateHotel(myRow_Id, txtDeactiveRemark.Text.Trim())) { } } } else { ShiftMapping(myRow_Id, Guid.Parse(ddlExistingHotels.SelectedItem.Value), txtDeactiveRemark.Text.Trim()); if (DeactivateHotel(myRow_Id, txtDeactiveRemark.Text.Trim())) { loadExistingProductGrid(); } } } } catch { //throw ex; } }