protected void btnMapAll_Click(object sender, EventArgs e) { List <MDMSVC.DC_CountryMapping> RQ = new List <MDMSVC.DC_CountryMapping>(); Guid myRow_Id; Guid mySupplier_Id; Guid myCountry_Id; bool res = false; foreach (GridViewRow row in grdCountryMaps.Rows) { myRow_Id = Guid.Empty; mySupplier_Id = Guid.Empty; myCountry_Id = Guid.Empty; int index = row.RowIndex; DropDownList ddl = row.Cells[6].Controls[1] as DropDownList; MDMSVC.DC_CountryMapping param = new MDMSVC.DC_CountryMapping(); myRow_Id = Guid.Parse(grdCountryMaps.DataKeys[index].Values[0].ToString()); mySupplier_Id = Guid.Parse(grdCountryMaps.DataKeys[index].Values[1].ToString()); HiddenField hdnCountryId = row.Cells[10].Controls[1] as HiddenField; if (ddlStatus.SelectedItem.Text.Trim().ToUpper() == "UNMAPPED") { if (ddl.SelectedItem.Value != "0" || !string.IsNullOrWhiteSpace(hdnCountryId.Value)) { if (!string.IsNullOrWhiteSpace(hdnCountryId.Value)) { if (hdnCountryId.Value == "0") { continue; } if (hdnCountryId != null) { myCountry_Id = Guid.Parse(hdnCountryId.Value); } } else if (ddl.SelectedItem.Value != "0") { if (ddl != null) { myCountry_Id = Guid.Parse(ddl.SelectedItem.Value); } } } else { myCountry_Id = Guid.Empty; } } else { myCountry_Id = Guid.Parse(grdCountryMaps.DataKeys[index].Values[2].ToString()); } 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 = "MAPPED"; param.Edit_Date = DateTime.Now; param.Edit_User = System.Web.HttpContext.Current.User.Identity.Name; if (myCountry_Id != Guid.Empty) { RQ.Add(param); } res = mapperSVc.UpdateCountryMappingDatat(RQ); } BootstrapAlert.BootstrapAlertMessage(dvMsg1, "Record has been updated successfully", BootstrapAlertType.Success); fillmappingdata(); }
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); }