protected void btnAddTerritory_Click(object sender, EventArgs e) { try { Page.Validate("valAddTerritoryGroup"); if (!Page.IsValid) { mpeAddTerritoryCode.Show(); } else { string userCode = Convert.ToString(Session["UserCode"]); territorySearchBL = new TerritorySearchBL(); DataSet dtTerritoryList = territorySearchBL.InsertUpdateTerritoryGroup("I", txtTerritoryCode.Text.ToUpper(), txtTerritoryName.Text.ToUpper(), txtTerritoryLocation.Text.ToUpper(), txtCountryCode.Text.ToUpper(), ddlTerritoryType.SelectedValue, userCode, out errorId); territorySearchBL = null; if (dtTerritoryList.Tables.Count > 0 && errorId == 0) { Session["FuzzyTerritorySearchSellerGrpList"] = dtTerritoryList.Tables[0]; msgView.SetMessage("Territory code added successfully.", MessageType.Warning, PositionType.Auto); mpeAddTerritoryCode.Hide(); txtTerritoryCode.Text = ""; txtTerritoryName.Text = ""; txtTerritoryLocation.Text = ""; txtCountryCode.Text = ""; ddlTerritoryType.SelectedIndex = 0; } else if (errorId == 1) { msgView.SetMessage("Territory code already exists.", MessageType.Warning, PositionType.Auto); mpeAddTerritoryCode.Show(); } else { ExceptionHandler("Error in adding the new territory code.", ""); } } } catch (Exception ex) { ExceptionHandler("Error in adding the new territory code.", ex.Message); } }
protected void imgBtnTerritoryUpdate_Click(object sender, EventArgs e) { try { string userCode = Convert.ToString(Session["UserCode"]); Page.Validate("valUpdateTerritoryGroup"); if (!Page.IsValid) { return; } territorySearchBL = new TerritorySearchBL(); DataSet dtTerritoryList = territorySearchBL.InsertUpdateTerritoryGroup("U", lblTerritoryCode.Text.ToUpper(), txtGridTerritoryName.Text.ToUpper(), txtGridTerritoryLocation.Text.ToUpper(), txtGridCountryCode.Text.ToUpper(), ddlGridTerritoryType.SelectedValue, userCode, out errorId); territorySearchBL = null; if (dtTerritoryList.Tables.Count != 0 && errorId != 2) { Session["FuzzyTerritorySearchSellerGrpList"] = dtTerritoryList.Tables[0]; DataTable dtTerritoryDtls = dtTerritoryList.Tables[1]; lblTerritoryCode.Text = dtTerritoryDtls.Rows[0]["seller_code"].ToString(); hdnGridTerritoryName.Value = txtGridTerritoryName.Text = dtTerritoryDtls.Rows[0]["seller_name"].ToString(); hdnGridTerritoryLocation.Value = txtGridTerritoryLocation.Text = dtTerritoryDtls.Rows[0]["seller_location"].ToString(); hdnGridCountryCode.Value = txtGridCountryCode.Text = dtTerritoryDtls.Rows[0]["country_code"].ToString(); hdnGridTerritoryType.Value = ddlGridTerritoryType.SelectedValue = dtTerritoryDtls.Rows[0]["territory_type"].ToString(); msgView.SetMessage("Territory code updated successfully.", MessageType.Warning, PositionType.Auto); } else { msgView.SetMessage("Failed to update territory code.", MessageType.Warning, PositionType.Auto); } } catch (Exception ex) { ExceptionHandler("Error in updating territory code.", ex.Message); } }