<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="NGORegisterdDetailsUserControl.ascx.cs" Inherits="NGO.UIPages.NGORegisterdDetails.NGORegisterdDetailsUserControl" %>
<script type="text/javascript">
function setupLabel() {
if ($('.label_check input').length) {
$('.label_check').each(function () {
$(this).removeClass('c_on');
});
$('.label_check input:checked').each(function () {
$(this).parent('label').addClass('c_on');
});
};
if ($('.label_radio input').length) {
$('.label_radio').each(function () {
$(this).removeClass('r_on');
});
$('.label_radio input:checked').each(function () {
$(this).parent('label').addClass('r_on');
});
};
};
$(document).ready(function () {
$('.label_check, .label_radio').click(function () {
setupLabel();
});
setupLabel();
});
</script>
<script type="text/javascript" lang="javascript">
function ValidatePage() {
var pageresult = true;
var Cname = document.getElementById('<%=txtCname.ClientID %>');
var spanCname = document.getElementById('rfvCname');
var NGOType = document.getElementById('<%=ddlCompanyType.ClientID %>');
var spanNgoType = document.getElementById('rfvNgoType');
var checkEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var Email = document.getElementById('<%=txtEmail.ClientID %>');
var spanEmail = document.getElementById('rfvEmail');
var Address1 = document.getElementById('<%=txtAddressLine1.ClientID %>');
var spanAddress1 = document.getElementById('rfvAddressLine1');
var country = document.getElementById('<%=ddlCountry.ClientID %>');
var spanCountry = document.getElementById('rfvCountry');
var State = document.getElementById('<%=ddlState.ClientID %>');
var spanState = document.getElementById('rfvState');
if (jQuery.trim(Cname.value) == '') {
spanCname.style.display = 'inline';
spanCname.innerHTML = 'Required NGO Name';
pageresult = false;
}
else {
spanCname.innerHTML = '';
spanCname.style.display = 'none';
}
if (NgoType.selectedIndex == 0) {
spanNgoType.style.display = 'inline';
spanNgoType.innerHTML = 'Required NGO Type ';
pageresult = false;
}
else {
spanNgoType.innerHTML = '';
spanNgoType.style.display = 'none';
}
if (jQuery.trim(Email.value) != '') {
if (!checkEmail.test(jQuery.trim(Email.value))) {
spanEmail.style.display = 'inline';
spanEmail.innerHTML = 'Required Valid Email';
pageresult = false;
//return true;
}
else {
spanEmail.style.display = 'none';
spanEmail.innerHTML = '';
}
}
if (jQuery.trim(Address1.value) == '') {
spanAddress1.style.display = 'inline';
spanAddress1.innerHTML = 'Required Address 1';
pageresult = false;
}
else {
spanAddress1.innerHTML = '';
spanAddress1.style.display = 'none';
}
if (country.selectedIndex == 0) {
spanCountry.style.display = 'inline';
spanCountry.innerHTML = 'Required Country';
pageresult = false;
}
else {
spanCountry.innerHTML = '';
spanCountry.style.display = 'none';
}
if (countries.selectedIndex != 0) {
var result = '';
$('#' + countries.id + ' option:selected').each(function () {
result = result + $(this).val() + '|';
});
result = result.substring(0, result.length - 1);
document.getElementById('<%= hdnCountries.ClientID%>').value = result;
}
if (states.selectedIndex != 0) {
var result = '';
$('#' + states.id + ' option:selected').each(function () {
result = result + $(this).val() + '|';
});
result = result.substring(0, result.length - 1);
document.getElementById('<%= hdnStates.ClientID%>').value = result;
}
return pageresult;
}
</script>
<script type="text/javascript" lang="javascript">
function ValidateEmail() {
var checkEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var Email = document.getElementById('<%=txtEmail.ClientID %>');
var spanEmail = document.getElementById('rfvEmail');
if (jQuery.trim(Email.value) != '' && !checkEmail.test(jQuery.trim(Email.value))) {
spanEmail.style.display = 'inline';
spanEmail.innerHTML = 'Required Valid Email';
return false;
}
else {
spanEmail.innerHTML = '';
spanEmail.style.display = 'none';
return true;
}
}
function ValidateDCity() {
var City = document.getElementById('<%=ddlCity.ClientID %>');
var spanCity = document.getElementById('rfvCity');
var OtherCity = document.getElementById('<%=txtCity.ClientID %>');
var DivOtherCity = document.getElementById('<%=divOtherCity.ClientID %>');
if (City.options[City.selectedIndex].value == '0') {
DivOtherCity.style.display = 'none';
spanCity.style.display = 'inline';
spanCity.innerHTML = 'Required City';
return false;
}
else {
if (City.options[City.selectedIndex].value == 'Other') {
DivOtherCity.style.display = 'block';
}
else {
OtherCity.value = "";
DivOtherCity.style.display = 'none';
}
spanCity.innerHTML = '';
spanCity.style.display = 'none';
return true;
}
}
function ValidateTCity() {
var City = document.getElementById('<%=txtCity.ClientID %>');
var spanCity = document.getElementById('rfvCity');
if (City.value == '') {
spanCity.style.display = 'inline';
spanCity.innerHTML = 'Enter valid city';
return false;
}
else {
spanCity.innerHTML = '';
spanCity.style.display = 'none';
return true;
}
}
</script>
<div class="contentPlaceHolder">
<div class="container">
<h2 class="">NGO Details <a id="back">Back</a> </h2>
<asp:Label ID="lblMessage" EnableViewState="false" runat="server" Style="color: Red;"></asp:Label>
<section class="tab marB20">
<ul class="tabNav">
<li class="active">NGO Information</li>
<li id="liNGOMember" runat="server" style="display: none"><a id="aNGOMamber" runat="server" title="NGO Member" class=""><span>Associated Students</span></a></li>
<li id="liNGOHead" runat="server" style="display: none"><a id="aNGOHead" runat="server" title="NGO Headd" class=""><span>Associated Dealers</span></a></li>
<li id="liNGOSuperVisor" runat="server" style="display: none"><a id="aNGOSUpVir" runat="server" title="NGO Superviser" class=""><span>Chain Store Group</span></a></li>
</ul>
<div class="tabContent">
<div class="tabText active" id="certifications">
<div>
<span style="float: right"><%--<asp:HyperLink ID="hylBack" runat="server" NavigateUrl="~/admin/Pages/CompanyDetails.aspx">Back</asp:HyperLink>--%></span>
</div>
<div class="form all100 lab_BC row-">
<div class="col-sm-6">
<div class="row-">
<fieldset>
<label class="col-sm-3">NGO Name<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtCname" runat="server" MaxLength="50"></asp:TextBox><br />
<span id="rfvCname" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset id="dvCompanyType" runat="server">
<label class="col-sm-3">Company Type<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlCompanyType" runat="server" CssClass="dropdownMenu">
</asp:DropDownList>
<span id="rfvCompanyType" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Email</label>
<div class="col-sm-9">
<asp:TextBox ID="txtEmail" runat="server" MaxLength="50" onblur="return ValidateEmail();"></asp:TextBox>
<span id="rfvEmail" style="display: none; color: Red;"></span>
</div>
</fieldset>
</div>
</div>
<div class="col-sm-6">
<div class="row-">
<fieldset>
<label class="col-sm-3">Country<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlCountry" runat="server" CssClass="dropdownMenu" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>
<span id="rfvCountry" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">State<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlState" runat="server" CssClass="dropdownMenu">
</asp:DropDownList>
<span id="rfvState" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">City<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlCity" runat="server" CssClass="dropdownMenu" onchange="return ValidateDCity();">
</asp:DropDownList>
<div id="divOtherCity" style="display: none" runat="server">
<asp:TextBox ID="txtCity" runat="server" onblur="return ValidateTCity();"></asp:TextBox>
</div>
<span id="rfvCity" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Address Line 1<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtAddressLine1" runat="server" MaxLength="50"></asp:TextBox>
<span id="rfvAddressLine1" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Address Line 2<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtAddressLine2" runat="server" MaxLength="50"></asp:TextBox>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Phone<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtTelephone" runat="server" MaxLength="15"></asp:TextBox>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Fax<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtfax" runat="server" MaxLength="50"></asp:TextBox>
<span id="rfvfax" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Web Address<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtwebAddress" runat="server" MaxLength="50"></asp:TextBox>
<span id="rfvParentSAPId" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Postal Code<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtPostCode" runat="server" MaxLength="7"></asp:TextBox>
<span id="rfvPostCode" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Status<span class="mand"></span></label>
<div class="col-sm-9">
<asp:CheckBox ID="chkStatus" runat="server" Checked="true" />
</div>
</fieldset>
</div>
</div>
</div>
<div class="r cap">
<asp:Button ID="btnSubmit" runat="server" class="btn" Text="Submit" OnClientClick="javascript:return ValidatePage();" OnClick="btnSubmit_Click" />
</div>
</div>
</div>
<input id="NgoID" runat="server" type="hidden" />
<input id="hdnNgoType" runat="server" type="hidden" />
</section>
</div>
</div>
****************************************CS Code*****************************
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace NGO.UIPages.NGORegisterdDetails
{
public partial class NGORegisterdDetailsUserControl : UserControl
{
/// <summary>
/// Variable Declaration
/// </summary>
/// <returns></returns>
string CountryId = string.Empty;
public string NgoId = string.Empty;
string NgoType = string.Empty;
string region = string.Empty;
/// <summary>
/// Page Load Event
/// </summary>
/// <returns></returns>
protected void Page_Load(object sender, EventArgs e)
{
NgoType = Page.Request.QueryString["NG"] != null ? Page.Request.QueryString["NG"].ToString() : "NGO";
hdnNgoType.Value = NgoType;
NgoId = Page.Request.QueryString["NgoId"] != null ? Page.Request.QueryString["NgoId"] : string.Empty;
hdnID.Value = NgoId;
aNGOMamber.HRef = "~/admin/Pages/NgoHeads.aspx?NgoId=" + Request.QueryString["NgoId"] + "&NG=" + Request.QueryString["NG"] + "";
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(hdnID.Value))
{
GetNGODetailById();
}
else
{
BindCountry("");
BindState();
BindCity("");
}
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
/// Saving The Company Details
SaveUpadateNGODetails();
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Saving The NGo Details
/// </summary>
/// <returns></returns>
public void SaveUpadateNGODetails()
{
NGODetailsEntity objCompanyDetails = new NGODetailsEntity();
Boolean result = false;
try
{
string strMessage = string.Empty;
//objCompanyDetails.Title = txtTitle.Text;
objCompanyDetails.CompanyName = txtCname.Text.Trim();
objCompanyDetails.Email = txtEmail.Text.Trim();
objCompanyDetails.Address1 = txtAddressLine1.Text.Trim();
objCompanyDetails.Address2 = txtAddressLine2.Text.Trim();
objCompanyDetails.Country = ddlCountry.SelectedValue;
objCompanyDetails.State = ddlState.SelectedValue;
objCompanyDetails.City = ddlCity.SelectedItem.ToString();
objCompanyDetails.Phone = txtTelephone.Text.Trim();
objCompanyDetails.PostalCode = txtPostCode.Text.Trim();
objCompanyDetails.WebAddress = txtwebAddress.Text.Trim();
objCompanyDetails.Fax = txtfax.Text.Trim();
if (!string.IsNullOrEmpty(hdnID.Value))
{
result = NGOHelper.UpdateCompanyDetails(objCompanyDetails);
if (result == true)
{
Response.Redirect("/ngoadmin/Pages/NGOListing.aspx?msg=2&NG=" + NgoType, false);
}
else
{
Response.Redirect("/ngoadmin/Pages/NGOListing.aspx?msg=3&NG=" + NgoType, false);
}
}
else if (string.IsNullOrEmpty(hdnID.Value))
{
result = NGOHelper.SaveNGODetails(objCompanyDetails);
if (result == true)
{
Response.Redirect("/ngoadmin/Pages/NgoListing.aspx?msg=1&NG=" + NgoType, false);
}
else
{
Response.Redirect("/ngoadmin/Pages/NgoListing.aspx?msg=4&NG=" + NgoType, false);
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Bind The Country
/// </summary>
/// <returns></returns>
//private void BindCountry()
//{
// List<CountryEntity> LstCountry = NGOHelper.GetCountry();
// {
// ddlCountry.Items.Clear();
// LstCountry.Insert(0, new CountryEntity() { Title = "--Select--" });
// ddlCountry.DataSource = LstCountry;
// ddlCountry.DataTextField = CountryEntity.FieldsName.Title;
// ddlCountry.DataValueField = CountryEntity.FieldsName.CountryCode;
// ddlCountry.DataBind();
// }
//}
private void BindCountry(string regionIn)
{
ddlCountry.Items.Clear();
if (regionIn == "")
{
ddlCountry.Items.Insert(0, (new ListItem("--Select--")));
}
else
{
List<CountryEntity> LstCountry = NGOHelper.GetCountry(regionIn);
try
{
if (LstCountry != null && LstCountry.Count > 0)
{
LstCountry.Insert(0, new CountryEntity() { Title = "--Select--" });
ddlCountry.DataSource = LstCountry;
ddlCountry.DataTextField = CountryEntity.FieldsName.Title;
ddlCountry.DataValueField = CountryEntity.FieldsName.CountryCode;
ddlCountry.DataBind();
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
/// <summary>
/// Bind The State
/// </summary>
/// <returns></returns>
private void BindState()
{
List<StateEntity> LstState = NGOHelper.GetStates();
{
ddlState.Items.Clear();
LstState.Insert(0, new StateEntity() { Title = "--Select--" });
ddlState.DataSource = LstState;
ddlState.DataTextField = StateEntity.FieldsName.Title;
ddlState.DataValueField = StateEntity.FieldsName.StateCode;
ddlState.DataBind();
}
}
/// <summary>
/// Country Selection Change Event on Bind City
/// </summary>
/// <returns></returns>
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
CountryId = ddlCountry.SelectedValue.ToString();
BindCity(CountryId);
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Bind the City on basis of Country
/// </summary>
/// <returns></returns>
private void BindCity(string CountryId)
{
ddlCity.Items.Clear();
if (CountryId == "")
{
ddlCity.Items.Insert(0, (new ListItem("--Select--")));
}
else
{
List<CityEntity> lstCity = NGOHelper.GetCity(CountryId);
try
{
if (lstCity != null && lstCity.Count > 0)
{
ddlCity.DataSource = lstCity;
ddlCity.DataTextField = CityEntity.FieldsName.Title;
ddlCity.DataValueField = CityEntity.FieldsName.CountryId;
ddlCity.DataBind();
}
//ddlCity.Items.Insert(0, (new ListItem("--Select--")));
ddlCity.Items.Insert(ddlCity.Items.Count, (new ListItem("Other")));
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
/// <summary>
/// Get NGO Details By NgoId
/// </summary>
/// <returns></returns>
private void GetNGODetailById()
{
try
{
string CityCountryId = string.Empty;
NGODetailsEntity objNGODetailsEntity = NGOHelper.GetNGODetail(hdnID.Value);
if (objNGODetailsEntity != null)
{
//txtTitle.Text = objNGODetailsEntity.Title != null ? objNGODetailsEntity.Title : "";
//BindCountryType();
//if (objNGODetailsEntity.NgoType != null && objNGODetailsEntity.NgoType != "")
// ddlNgoType.Items.FindByValue(objNGODetailsEntity.NgoType).Selected = true;
txtCname.Text = objNGODetailsEntity.CompanyName != null ? objNGODetailsEntity.CompanyName : "";
txtEmail.Text = objNGODetailsEntity.Email != null ? objNGODetailsEntity.Email : "";
txtAddressLine1.Text = objNGODetailsEntity.Address1 != null ? objNGODetailsEntity.Address1 : "";
txtAddressLine2.Text = objNGODetailsEntity.Address2 != null ? objNGODetailsEntity.Address2 : "";
BindState();
if (objNGODetailsEntity.State != null && objNGODetailsEntity.State != "")
ddlState.Items.FindByValue(objNGODetailsEntity.State).Selected = true;
BindCity(ddlCountry.SelectedValue);
CityCountryId = ddlCountry.SelectedValue;
ddlCity.SelectedValue = CityCountryId;
ddlCity.SelectedItem.Text = objNGODetailsEntity.City;
txtTelephone.Text = objNGODetailsEntity.Phone;
//txtParentNgoId.Text = objNGODetailsEntity.ParentNgoId;
txtPostCode.Text = objNGODetailsEntity.PostalCode;
txtwebAddress.Text = objNGODetailsEntity.WebAddress;
txtfax.Text = objNGODetailsEntity.Fax;
chkStatus.Checked = Convert.ToBoolean(objNGODetailsEntity.Status);
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
}
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="NGORegisterdDetailsUserControl.ascx.cs" Inherits="NGO.UIPages.NGORegisterdDetails.NGORegisterdDetailsUserControl" %>
<script type="text/javascript">
function setupLabel() {
if ($('.label_check input').length) {
$('.label_check').each(function () {
$(this).removeClass('c_on');
});
$('.label_check input:checked').each(function () {
$(this).parent('label').addClass('c_on');
});
};
if ($('.label_radio input').length) {
$('.label_radio').each(function () {
$(this).removeClass('r_on');
});
$('.label_radio input:checked').each(function () {
$(this).parent('label').addClass('r_on');
});
};
};
$(document).ready(function () {
$('.label_check, .label_radio').click(function () {
setupLabel();
});
setupLabel();
});
</script>
<script type="text/javascript" lang="javascript">
function ValidatePage() {
var pageresult = true;
var Cname = document.getElementById('<%=txtCname.ClientID %>');
var spanCname = document.getElementById('rfvCname');
var NGOType = document.getElementById('<%=ddlCompanyType.ClientID %>');
var spanNgoType = document.getElementById('rfvNgoType');
var checkEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var Email = document.getElementById('<%=txtEmail.ClientID %>');
var spanEmail = document.getElementById('rfvEmail');
var Address1 = document.getElementById('<%=txtAddressLine1.ClientID %>');
var spanAddress1 = document.getElementById('rfvAddressLine1');
var country = document.getElementById('<%=ddlCountry.ClientID %>');
var spanCountry = document.getElementById('rfvCountry');
var State = document.getElementById('<%=ddlState.ClientID %>');
var spanState = document.getElementById('rfvState');
if (jQuery.trim(Cname.value) == '') {
spanCname.style.display = 'inline';
spanCname.innerHTML = 'Required NGO Name';
pageresult = false;
}
else {
spanCname.innerHTML = '';
spanCname.style.display = 'none';
}
if (NgoType.selectedIndex == 0) {
spanNgoType.style.display = 'inline';
spanNgoType.innerHTML = 'Required NGO Type ';
pageresult = false;
}
else {
spanNgoType.innerHTML = '';
spanNgoType.style.display = 'none';
}
if (jQuery.trim(Email.value) != '') {
if (!checkEmail.test(jQuery.trim(Email.value))) {
spanEmail.style.display = 'inline';
spanEmail.innerHTML = 'Required Valid Email';
pageresult = false;
//return true;
}
else {
spanEmail.style.display = 'none';
spanEmail.innerHTML = '';
}
}
if (jQuery.trim(Address1.value) == '') {
spanAddress1.style.display = 'inline';
spanAddress1.innerHTML = 'Required Address 1';
pageresult = false;
}
else {
spanAddress1.innerHTML = '';
spanAddress1.style.display = 'none';
}
if (country.selectedIndex == 0) {
spanCountry.style.display = 'inline';
spanCountry.innerHTML = 'Required Country';
pageresult = false;
}
else {
spanCountry.innerHTML = '';
spanCountry.style.display = 'none';
}
if (countries.selectedIndex != 0) {
var result = '';
$('#' + countries.id + ' option:selected').each(function () {
result = result + $(this).val() + '|';
});
result = result.substring(0, result.length - 1);
document.getElementById('<%= hdnCountries.ClientID%>').value = result;
}
if (states.selectedIndex != 0) {
var result = '';
$('#' + states.id + ' option:selected').each(function () {
result = result + $(this).val() + '|';
});
result = result.substring(0, result.length - 1);
document.getElementById('<%= hdnStates.ClientID%>').value = result;
}
return pageresult;
}
</script>
<script type="text/javascript" lang="javascript">
function ValidateEmail() {
var checkEmail = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var Email = document.getElementById('<%=txtEmail.ClientID %>');
var spanEmail = document.getElementById('rfvEmail');
if (jQuery.trim(Email.value) != '' && !checkEmail.test(jQuery.trim(Email.value))) {
spanEmail.style.display = 'inline';
spanEmail.innerHTML = 'Required Valid Email';
return false;
}
else {
spanEmail.innerHTML = '';
spanEmail.style.display = 'none';
return true;
}
}
function ValidateDCity() {
var City = document.getElementById('<%=ddlCity.ClientID %>');
var spanCity = document.getElementById('rfvCity');
var OtherCity = document.getElementById('<%=txtCity.ClientID %>');
var DivOtherCity = document.getElementById('<%=divOtherCity.ClientID %>');
if (City.options[City.selectedIndex].value == '0') {
DivOtherCity.style.display = 'none';
spanCity.style.display = 'inline';
spanCity.innerHTML = 'Required City';
return false;
}
else {
if (City.options[City.selectedIndex].value == 'Other') {
DivOtherCity.style.display = 'block';
}
else {
OtherCity.value = "";
DivOtherCity.style.display = 'none';
}
spanCity.innerHTML = '';
spanCity.style.display = 'none';
return true;
}
}
function ValidateTCity() {
var City = document.getElementById('<%=txtCity.ClientID %>');
var spanCity = document.getElementById('rfvCity');
if (City.value == '') {
spanCity.style.display = 'inline';
spanCity.innerHTML = 'Enter valid city';
return false;
}
else {
spanCity.innerHTML = '';
spanCity.style.display = 'none';
return true;
}
}
</script>
<div class="contentPlaceHolder">
<div class="container">
<h2 class="">NGO Details <a id="back">Back</a> </h2>
<asp:Label ID="lblMessage" EnableViewState="false" runat="server" Style="color: Red;"></asp:Label>
<section class="tab marB20">
<ul class="tabNav">
<li class="active">NGO Information</li>
<li id="liNGOMember" runat="server" style="display: none"><a id="aNGOMamber" runat="server" title="NGO Member" class=""><span>Associated Students</span></a></li>
<li id="liNGOHead" runat="server" style="display: none"><a id="aNGOHead" runat="server" title="NGO Headd" class=""><span>Associated Dealers</span></a></li>
<li id="liNGOSuperVisor" runat="server" style="display: none"><a id="aNGOSUpVir" runat="server" title="NGO Superviser" class=""><span>Chain Store Group</span></a></li>
</ul>
<div class="tabContent">
<div class="tabText active" id="certifications">
<div>
<span style="float: right"><%--<asp:HyperLink ID="hylBack" runat="server" NavigateUrl="~/admin/Pages/CompanyDetails.aspx">Back</asp:HyperLink>--%></span>
</div>
<div class="form all100 lab_BC row-">
<div class="col-sm-6">
<div class="row-">
<fieldset>
<label class="col-sm-3">NGO Name<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtCname" runat="server" MaxLength="50"></asp:TextBox><br />
<span id="rfvCname" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset id="dvCompanyType" runat="server">
<label class="col-sm-3">Company Type<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlCompanyType" runat="server" CssClass="dropdownMenu">
</asp:DropDownList>
<span id="rfvCompanyType" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Email</label>
<div class="col-sm-9">
<asp:TextBox ID="txtEmail" runat="server" MaxLength="50" onblur="return ValidateEmail();"></asp:TextBox>
<span id="rfvEmail" style="display: none; color: Red;"></span>
</div>
</fieldset>
</div>
</div>
<div class="col-sm-6">
<div class="row-">
<fieldset>
<label class="col-sm-3">Country<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlCountry" runat="server" CssClass="dropdownMenu" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" AutoPostBack="True">
</asp:DropDownList>
<span id="rfvCountry" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">State<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlState" runat="server" CssClass="dropdownMenu">
</asp:DropDownList>
<span id="rfvState" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">City<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:DropDownList ID="ddlCity" runat="server" CssClass="dropdownMenu" onchange="return ValidateDCity();">
</asp:DropDownList>
<div id="divOtherCity" style="display: none" runat="server">
<asp:TextBox ID="txtCity" runat="server" onblur="return ValidateTCity();"></asp:TextBox>
</div>
<span id="rfvCity" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Address Line 1<span class="mand">*</span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtAddressLine1" runat="server" MaxLength="50"></asp:TextBox>
<span id="rfvAddressLine1" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Address Line 2<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtAddressLine2" runat="server" MaxLength="50"></asp:TextBox>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Phone<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtTelephone" runat="server" MaxLength="15"></asp:TextBox>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Fax<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtfax" runat="server" MaxLength="50"></asp:TextBox>
<span id="rfvfax" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Web Address<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtwebAddress" runat="server" MaxLength="50"></asp:TextBox>
<span id="rfvParentSAPId" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Postal Code<span class="mand"></span></label>
<div class="col-sm-9">
<asp:TextBox ID="txtPostCode" runat="server" MaxLength="7"></asp:TextBox>
<span id="rfvPostCode" style="display: none; color: Red;"></span>
</div>
</fieldset>
<fieldset>
<label class="col-sm-3">Status<span class="mand"></span></label>
<div class="col-sm-9">
<asp:CheckBox ID="chkStatus" runat="server" Checked="true" />
</div>
</fieldset>
</div>
</div>
</div>
<div class="r cap">
<asp:Button ID="btnSubmit" runat="server" class="btn" Text="Submit" OnClientClick="javascript:return ValidatePage();" OnClick="btnSubmit_Click" />
</div>
</div>
</div>
<input id="NgoID" runat="server" type="hidden" />
<input id="hdnNgoType" runat="server" type="hidden" />
</section>
</div>
</div>
****************************************CS Code*****************************
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace NGO.UIPages.NGORegisterdDetails
{
public partial class NGORegisterdDetailsUserControl : UserControl
{
/// <summary>
/// Variable Declaration
/// </summary>
/// <returns></returns>
string CountryId = string.Empty;
public string NgoId = string.Empty;
string NgoType = string.Empty;
string region = string.Empty;
/// <summary>
/// Page Load Event
/// </summary>
/// <returns></returns>
protected void Page_Load(object sender, EventArgs e)
{
NgoType = Page.Request.QueryString["NG"] != null ? Page.Request.QueryString["NG"].ToString() : "NGO";
hdnNgoType.Value = NgoType;
NgoId = Page.Request.QueryString["NgoId"] != null ? Page.Request.QueryString["NgoId"] : string.Empty;
hdnID.Value = NgoId;
aNGOMamber.HRef = "~/admin/Pages/NgoHeads.aspx?NgoId=" + Request.QueryString["NgoId"] + "&NG=" + Request.QueryString["NG"] + "";
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(hdnID.Value))
{
GetNGODetailById();
}
else
{
BindCountry("");
BindState();
BindCity("");
}
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
/// Saving The Company Details
SaveUpadateNGODetails();
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Saving The NGo Details
/// </summary>
/// <returns></returns>
public void SaveUpadateNGODetails()
{
NGODetailsEntity objCompanyDetails = new NGODetailsEntity();
Boolean result = false;
try
{
string strMessage = string.Empty;
//objCompanyDetails.Title = txtTitle.Text;
objCompanyDetails.CompanyName = txtCname.Text.Trim();
objCompanyDetails.Email = txtEmail.Text.Trim();
objCompanyDetails.Address1 = txtAddressLine1.Text.Trim();
objCompanyDetails.Address2 = txtAddressLine2.Text.Trim();
objCompanyDetails.Country = ddlCountry.SelectedValue;
objCompanyDetails.State = ddlState.SelectedValue;
objCompanyDetails.City = ddlCity.SelectedItem.ToString();
objCompanyDetails.Phone = txtTelephone.Text.Trim();
objCompanyDetails.PostalCode = txtPostCode.Text.Trim();
objCompanyDetails.WebAddress = txtwebAddress.Text.Trim();
objCompanyDetails.Fax = txtfax.Text.Trim();
if (!string.IsNullOrEmpty(hdnID.Value))
{
result = NGOHelper.UpdateCompanyDetails(objCompanyDetails);
if (result == true)
{
Response.Redirect("/ngoadmin/Pages/NGOListing.aspx?msg=2&NG=" + NgoType, false);
}
else
{
Response.Redirect("/ngoadmin/Pages/NGOListing.aspx?msg=3&NG=" + NgoType, false);
}
}
else if (string.IsNullOrEmpty(hdnID.Value))
{
result = NGOHelper.SaveNGODetails(objCompanyDetails);
if (result == true)
{
Response.Redirect("/ngoadmin/Pages/NgoListing.aspx?msg=1&NG=" + NgoType, false);
}
else
{
Response.Redirect("/ngoadmin/Pages/NgoListing.aspx?msg=4&NG=" + NgoType, false);
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Bind The Country
/// </summary>
/// <returns></returns>
//private void BindCountry()
//{
// List<CountryEntity> LstCountry = NGOHelper.GetCountry();
// {
// ddlCountry.Items.Clear();
// LstCountry.Insert(0, new CountryEntity() { Title = "--Select--" });
// ddlCountry.DataSource = LstCountry;
// ddlCountry.DataTextField = CountryEntity.FieldsName.Title;
// ddlCountry.DataValueField = CountryEntity.FieldsName.CountryCode;
// ddlCountry.DataBind();
// }
//}
private void BindCountry(string regionIn)
{
ddlCountry.Items.Clear();
if (regionIn == "")
{
ddlCountry.Items.Insert(0, (new ListItem("--Select--")));
}
else
{
List<CountryEntity> LstCountry = NGOHelper.GetCountry(regionIn);
try
{
if (LstCountry != null && LstCountry.Count > 0)
{
LstCountry.Insert(0, new CountryEntity() { Title = "--Select--" });
ddlCountry.DataSource = LstCountry;
ddlCountry.DataTextField = CountryEntity.FieldsName.Title;
ddlCountry.DataValueField = CountryEntity.FieldsName.CountryCode;
ddlCountry.DataBind();
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
/// <summary>
/// Bind The State
/// </summary>
/// <returns></returns>
private void BindState()
{
List<StateEntity> LstState = NGOHelper.GetStates();
{
ddlState.Items.Clear();
LstState.Insert(0, new StateEntity() { Title = "--Select--" });
ddlState.DataSource = LstState;
ddlState.DataTextField = StateEntity.FieldsName.Title;
ddlState.DataValueField = StateEntity.FieldsName.StateCode;
ddlState.DataBind();
}
}
/// <summary>
/// Country Selection Change Event on Bind City
/// </summary>
/// <returns></returns>
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
CountryId = ddlCountry.SelectedValue.ToString();
BindCity(CountryId);
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Bind the City on basis of Country
/// </summary>
/// <returns></returns>
private void BindCity(string CountryId)
{
ddlCity.Items.Clear();
if (CountryId == "")
{
ddlCity.Items.Insert(0, (new ListItem("--Select--")));
}
else
{
List<CityEntity> lstCity = NGOHelper.GetCity(CountryId);
try
{
if (lstCity != null && lstCity.Count > 0)
{
ddlCity.DataSource = lstCity;
ddlCity.DataTextField = CityEntity.FieldsName.Title;
ddlCity.DataValueField = CityEntity.FieldsName.CountryId;
ddlCity.DataBind();
}
//ddlCity.Items.Insert(0, (new ListItem("--Select--")));
ddlCity.Items.Insert(ddlCity.Items.Count, (new ListItem("Other")));
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
/// <summary>
/// Get NGO Details By NgoId
/// </summary>
/// <returns></returns>
private void GetNGODetailById()
{
try
{
string CityCountryId = string.Empty;
NGODetailsEntity objNGODetailsEntity = NGOHelper.GetNGODetail(hdnID.Value);
if (objNGODetailsEntity != null)
{
//txtTitle.Text = objNGODetailsEntity.Title != null ? objNGODetailsEntity.Title : "";
//BindCountryType();
//if (objNGODetailsEntity.NgoType != null && objNGODetailsEntity.NgoType != "")
// ddlNgoType.Items.FindByValue(objNGODetailsEntity.NgoType).Selected = true;
txtCname.Text = objNGODetailsEntity.CompanyName != null ? objNGODetailsEntity.CompanyName : "";
txtEmail.Text = objNGODetailsEntity.Email != null ? objNGODetailsEntity.Email : "";
txtAddressLine1.Text = objNGODetailsEntity.Address1 != null ? objNGODetailsEntity.Address1 : "";
txtAddressLine2.Text = objNGODetailsEntity.Address2 != null ? objNGODetailsEntity.Address2 : "";
BindState();
if (objNGODetailsEntity.State != null && objNGODetailsEntity.State != "")
ddlState.Items.FindByValue(objNGODetailsEntity.State).Selected = true;
BindCity(ddlCountry.SelectedValue);
CityCountryId = ddlCountry.SelectedValue;
ddlCity.SelectedValue = CityCountryId;
ddlCity.SelectedItem.Text = objNGODetailsEntity.City;
txtTelephone.Text = objNGODetailsEntity.Phone;
//txtParentNgoId.Text = objNGODetailsEntity.ParentNgoId;
txtPostCode.Text = objNGODetailsEntity.PostalCode;
txtwebAddress.Text = objNGODetailsEntity.WebAddress;
txtfax.Text = objNGODetailsEntity.Fax;
chkStatus.Checked = Convert.ToBoolean(objNGODetailsEntity.Status);
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
}
********************************** NGO Entity Class*****************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NGO_Entity
{
public class NGODetailsEntity
{
public const string ListName = "NGODetails";
#region Constructor
public NGODetailsEntity()
{
}
#endregion
#region Properties
public string ID { get; set; }
/// <summary>
/// Gets or Sets Title
/// </summary>
public string Title { get; set; }
/// <summary>
/// Gets or Sets NGOName
/// </summary>
public string CompanyName { get; set; }
/// <summary>
/// Gets or Sets NgoType
/// </summary>
public string CompanyType { get; set; }
/// <summary>
/// Gets or Sets NgoId
/// </summary>
public string NGOId { get; set; }
public string Country { get; set; }
/// <summary>
/// Gets or Sets State
/// </summary>
public string State { get; set; }
/// <summary>
/// Gets or Sets City
/// </summary>
public string City { get; set; }
/// <summary>
/// Gets or Sets Address1
/// </summary>
public string Address1 { get; set; }
/// <summary>
/// Gets or Sets Address2
/// </summary>
public string Address2 { get; set; }
/// <summary>
/// Gets or Sets PostalCode
/// </summary>
public string PostalCode { get; set; }
public string Phone { get; set; }
/// <summary>
/// Gets or Sets Fax
/// </summary>
public string Fax { get; set; }
/// <summary>
/// Gets or Sets WebAddress
/// </summary>
public string WebAddress { get; set; }
/// <summary>
/// Gets or Sets Status
/// </summary>
public bool Status { get; set; }
/// <summary>
/// Gets or Sets Email
/// </summary>
public string Email { get; set; }
public string CreatedDate { get; set; }
#endregion
public class FieldsName
{
public const string ID = "ID";
/// <summary>
/// The name of the Title fields.
/// </summary>
public const string Title = "Title";
/// <summary>
/// The name of the NGoName fields.
/// </summary>
public const string CompanyName = "CompanyName";
/// <summary>
/// The name of the NGOType fields.
/// </summary>
public const string CompanyType = "CompanyType";
/// <summary>
/// The name of the NgoId fields.
/// </summary>
public const string NgoId = "NgoId";
/// <summary>
/// The name of the Country fields.
/// </summary>
public const string Country = "Country";
/// <summary>
/// The name of the State fields.
/// </summary>
public const string State = "State";
/// <summary>
/// The name of the City fields.
/// </summary>
public const string City = "City";
/// <summary>
/// The name of the Address1 fields.
/// </summary>
public const string Address1 = "Address1";
/// <summary>
/// The name of the Address2 fields.
/// </summary>
public const string Address2 = "Address2";
/// <summary>
/// The name of the PostalCode fields.
/// </summary>
public const string PostalCode = "PostalCode";
/// <summary>
/// The name of the Phone fields.
/// </summary>
public const string Phone = "Phone";
/// <summary>
/// The name of the Fax fields.
/// </summary>
public const string Fax = "Fax";
/// <summary>
/// The name of the WebAddress fields.
/// </summary>
public const string WebAddress = "WebAddress";
/// <summary>
/// The name of the Status fields.
/// </summary>
public const string Status = "Status";
/// <summary>
/// The name of the Email field
/// </summary>
public const string Email = "Email";
/// <summary>
///
/// </summary>
public const string CreatedDate = "Created";
}
}
}
**************************************NGO Helper (DB Layer) *****************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using NGO_Entity;
using NGO_Utility;
using System.Net;
using Microsoft.SharePoint;
using System.IO;
namespace NGO_BussinessManager
{
public class CompanyHelper
{
/// <summary>
/// this method is used to get Active NGO details from NGODetail list
/// </summary>
/// <returns></returns>
///
public static List<NGODetailsEntity> GetActiveNGODetailClient(string NgoType)
{
List<NGODetailsEntity> lstNGODetailsEntity = null;
string strUserName = Common.GetAssetsSiteUserName();
string strDomain = Common.GetAssetsSiteDomain();
string strPassword = Common.GetAssetsSitePassword();
try
{
using (ClientContext clientcontext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientcontext.Credentials = new NetworkCredential(strUserName, strPassword, strDomain);
Web web = clientcontext.Web;
///create list object
List splist = web.Lists.GetByTitle(NGODetailsEntity.ListName);
CamlQuery query = new CamlQuery();
//query.ViewXml = "<View/>";
query.ViewXml = @"<View>
<Query>
<Where>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.CompanyType + "'/><Value Type='Text'>" + NgoType + @"</Value></Eq>
</Where>
</Query>
</View>";
Microsoft.SharePoint.Client.ListItemCollection itemCollection = splist.GetItems(query);
clientcontext.Load(splist);
clientcontext.Load(itemCollection);
clientcontext.ExecuteQuery();
if (itemCollection != null && itemCollection.Count > 0)
{
lstNGODetailsEntity = new List<NGODetailsEntity>();
NGODetailsEntity objNgonew = null;
for (int i = 0; i < itemCollection.Count; i++)
{
objNgonew = new NGODetailsEntity();
objNgonew.Title = itemCollection[i][NGODetailsEntity.FieldsName.Title].GetString();
objNgonew.CompanyName = itemCollection[i][NGODetailsEntity.FieldsName.CompanyName].GetString();
objNgonew.CompanyType = itemCollection[i][NGODetailsEntity.FieldsName.CompanyType].GetString();
objNgonew.Country = itemCollection[i][NGODetailsEntity.FieldsName.Country].GetString();
objNgonew.State = itemCollection[i][NGODetailsEntity.FieldsName.State].GetString();
objNgonew.City = itemCollection[i][NGODetailsEntity.FieldsName.City].GetString();
objNgonew.Address1 = itemCollection[i][NGODetailsEntity.FieldsName.Address1].GetString();
objNgonew.Address2 = itemCollection[i][NGODetailsEntity.FieldsName.Address2].GetString();
objNgonew.PostalCode = itemCollection[i][NGODetailsEntity.FieldsName.PostalCode].GetString();
objNgonew.Email = itemCollection[i][NGODetailsEntity.FieldsName.Email].GetString();
objNgonew.Phone = itemCollection[i][NGODetailsEntity.FieldsName.Phone].GetString();
objNgonew.Fax = itemCollection[i][NGODetailsEntity.FieldsName.Fax].GetString();
objNgonew.WebAddress = itemCollection[i][NGODetailsEntity.FieldsName.WebAddress].GetString();
objNgonew.Status = itemCollection[i][NGODetailsEntity.FieldsName.Status].GetBoolean();
objNgonew.CreatedDate = String.Format("{0:MM/dd/yyyy}", itemCollection[i][NGODetailsEntity.FieldsName.CreatedDate]);
lstNGODetailsEntity.Add(objNgonew);
}
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return lstNGODetailsEntity;
}
/// <summary>
/// This Method is used to get list of NGO Details based on SAPId
/// </summary>
/// <param name="SAPId"></param>
/// <param name="Status"></param>
/// <returns></returns>
public static NGODetailsEntity GetNGODetail(string Id)
{
NGODetailsEntity objNgo = null;
//get credentials
string userName = Common.GetAssetsSiteUserName();
string password = Common.GetAssetsSitePassword();
string domain = Common.GetAssetsSiteDomain();
try
{
using (ClientContext clientContext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientContext.Credentials = new NetworkCredential(userName, password, domain);
Web web = clientContext.Web;
List oList = web.Lists.GetByTitle(NGODetailsEntity.ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>
<Query>
<Where>
<And>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.NgoId + "'/><Value Type='Text'>" + Id + @"</Value></Eq>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.Status + "'/><Value Type='bool'>" + true + @"</Value></Eq>
</And>
</Where>
</Query>
</View>";
var listItems = oList.GetItems(query);
clientContext.Load(listItems, itemcol => itemcol.Include
(
listitem => listitem[NGODetailsEntity.FieldsName.Title],
listitem => listitem[NGODetailsEntity.FieldsName.CompanyName],
listitem => listitem[NGODetailsEntity.FieldsName.CompanyType],
listitem => listitem[NGODetailsEntity.FieldsName.Country],
listitem => listitem[NGODetailsEntity.FieldsName.State],
listitem => listitem[NGODetailsEntity.FieldsName.City],
listitem => listitem[NGODetailsEntity.FieldsName.Address1],
listitem => listitem[NGODetailsEntity.FieldsName.Address2],
listitem => listitem[NGODetailsEntity.FieldsName.PostalCode],
listitem => listitem[NGODetailsEntity.FieldsName.Email],
listitem => listitem[NGODetailsEntity.FieldsName.Phone],
listitem => listitem[NGODetailsEntity.FieldsName.Fax],
listitem => listitem[NGODetailsEntity.FieldsName.WebAddress],
listitem => listitem[NGODetailsEntity.FieldsName.Status]
));
clientContext.ExecuteQuery();
if (listItems != null && listItems.Count > 0)
{
ListItem item = null;
for (int i = 0; i < listItems.Count; i++)
{
item = listItems[i];
objNgo = new NGODetailsEntity();
objNgo.Title = item[NGODetailsEntity.FieldsName.Title].GetString();
objNgo.CompanyName = item[NGODetailsEntity.FieldsName.CompanyName].GetString();
objNgo.CompanyType = item[NGODetailsEntity.FieldsName.CompanyType].GetString();
objNgo.Country = item[NGODetailsEntity.FieldsName.Country].GetString();
objNgo.State = item[NGODetailsEntity.FieldsName.State].GetString();
objNgo.City = item[NGODetailsEntity.FieldsName.City].GetString();
objNgo.Address1 = item[NGODetailsEntity.FieldsName.Address1].GetString();
objNgo.Address2 = item[NGODetailsEntity.FieldsName.Address2].GetString();
objNgo.PostalCode = item[NGODetailsEntity.FieldsName.PostalCode].GetString();
objNgo.Email = item[NGODetailsEntity.FieldsName.Email].GetString();
objNgo.Phone = item[NGODetailsEntity.FieldsName.Phone].GetString();
objNgo.Fax = item[NGODetailsEntity.FieldsName.Fax].GetString();
objNgo.WebAddress = item[NGODetailsEntity.FieldsName.WebAddress].GetString();
objNgo.Status = item[NGODetailsEntity.FieldsName.Status].GetBoolean();
}
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return objNgo;
}
/// <summary>
/// Get Details of all companies
/// </summary>
/// <returns></returns>
public static List<NGODetailsEntity> GetAllNgoDetail()
{
List<NGODetailsEntity> lstCompanyDetail = null;
NGODetailsEntity objNgo = null;
//get credentials
string userName = Common.GetAssetsSiteUserName();
string password = Common.GetAssetsSitePassword();
string domain = Common.GetAssetsSiteDomain();
try
{
using (ClientContext clientContext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientContext.Credentials = new NetworkCredential(userName, password, domain);
Web web = clientContext.Web;
List oList = web.Lists.GetByTitle(NGODetailsEntity.ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>
<Query>
<Where>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.Status + "'/><Value Type='bool'>" + true + @"</Value></Eq>
</Where>
</Query>
</View>";
var listItems = oList.GetItems(query);
clientContext.Load(listItems, itemcol => itemcol.Include
(
listitem => listitem[NGODetailsEntity.FieldsName.Title],
listitem => listitem[NGODetailsEntity.FieldsName.CompanyName],
listitem => listitem[NGODetailsEntity.FieldsName.CompanyType]
));
clientContext.ExecuteQuery();
if (listItems != null && listItems.Count > 0)
{
lstCompanyDetail = new List<NGODetailsEntity>();
ListItem item = null;
for (int i = 0; i < listItems.Count; i++)
{
item = listItems[i];
objNgo = new NGODetailsEntity();
objNgo.Title = item[NGODetailsEntity.FieldsName.Title].GetString();
objNgo.CompanyName = item[NGODetailsEntity.FieldsName.CompanyName].GetString();
objNgo.CompanyType = item[NGODetailsEntity.FieldsName.CompanyType].GetString();
lstCompanyDetail.Add(objNgo);
}
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return lstCompanyDetail;
}
/// <summary>
/// This Method is used to get list of Ngo Details based on NgoName,City,Country,PostalCode
/// </summary>
/// <param name="NGOName"></param>
/// <param name="City"></param>
/// <param name="Country"></param>
/// <param name="PostalCode"></param>
/// <returns></returns>
public static List<NGODetailsEntity> GetFilteNGODetail(NGODetailsEntity objNGODetailsEntity)
{
List<NGODetailsEntity> lstCompany = null;
string strUserName = Common.GetAssetsSiteUserName();
string strDomain = Common.GetAssetsSiteDomain();
string strPassword = Common.GetAssetsSitePassword();
try
{
using (ClientContext clientContext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientContext.Credentials = new NetworkCredential(strUserName, strPassword, strDomain);
// Create web object
Web web = clientContext.Web;
List spList = web.Lists.GetByTitle(NGODetailsEntity.ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>
<Query>
<Where>
<Or>
<Or>
<Or>
<Contains><FieldRef Name='" + NGODetailsEntity.FieldsName.CompanyName + "' /><Value Type='Text'>" + objNGODetailsEntity.CompanyName + @"</Value></Contains>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.Country + "' /><Value Type='Text'>" + objNGODetailsEntity.Country + @"</Value></Eq>
</Or>
<Or>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.City + "' /><Value Type='Text'>" + objNGODetailsEntity.City + @"</Value></Eq>
<Or>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.PostalCode + "' /><Value Type='Text'>" + objNGODetailsEntity.PostalCode + @"</Value></Eq>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.NgoId + "' /><Value Type='Text'>" + objNGODetailsEntity.NgoId + @"</Value></Eq>
</Or>
</Or>
</Or>
<And>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.Title + "' /><Value Type='Text'>" + objNGODetailsEntity.Title + @"</Value></Eq>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.CompanyType + "' /><Value Type='Text'>" + objNGODetailsEntity.CompanyType + @"</Value></Eq>
</And>
</Or>
</Where>
</Query>
</View>";
var listItems = spList.GetItems(query);
clientContext.Load(listItems, itemcol => itemcol.Include
(
listitem => listitem[NGODetailsEntity.FieldsName.Title],
listitem => listitem[NGODetailsEntity.FieldsName.CompanyName],
listitem => listitem[NGODetailsEntity.FieldsName.CompanyType],
listitem => listitem[NGODetailsEntity.FieldsName.Country],
listitem => listitem[NGODetailsEntity.FieldsName.State],
listitem => listitem[NGODetailsEntity.FieldsName.City],
listitem => listitem[NGODetailsEntity.FieldsName.Address1],
listitem => listitem[NGODetailsEntity.FieldsName.Address2],
listitem => listitem[NGODetailsEntity.FieldsName.PostalCode],
listitem => listitem[NGODetailsEntity.FieldsName.Email],
listitem => listitem[NGODetailsEntity.FieldsName.Phone],
listitem => listitem[NGODetailsEntity.FieldsName.Fax],
listitem => listitem[NGODetailsEntity.FieldsName.WebAddress],
listitem => listitem[NGODetailsEntity.FieldsName.Status],
listitem => listitem[NGODetailsEntity.FieldsName.CreatedDate]
));
clientContext.ExecuteQuery();
if (listItems != null && listItems.Count > 0)
{
lstCompany = new List<NGODetailsEntity>();
NGODetailsEntity objNgoDetails = null;
ListItem item = null;
for (int i = 0; i < listItems.Count; i++)
{
objNgoDetails = new NGODetailsEntity();
item = listItems[i];
objNgoDetails.Title = item.FieldValues[NGODetailsEntity.FieldsName.Title].GetString();
objNgoDetails.CompanyName = item.FieldValues[NGODetailsEntity.FieldsName.CompanyName].GetString();
objNgoDetails.CompanyType = item.FieldValues[NGODetailsEntity.FieldsName.CompanyType].GetString();
objNgoDetails.Country = item.FieldValues[NGODetailsEntity.FieldsName.Country].GetString();
objNgoDetails.State = item.FieldValues[NGODetailsEntity.FieldsName.State].GetString();
objNgoDetails.City = item.FieldValues[NGODetailsEntity.FieldsName.City].GetString();
objNgoDetails.Address1 = item.FieldValues[NGODetailsEntity.FieldsName.Address1].GetString();
objNgoDetails.Address2 = item.FieldValues[NGODetailsEntity.FieldsName.Address2].GetString();
objNgoDetails.PostalCode = item.FieldValues[NGODetailsEntity.FieldsName.PostalCode].GetString();
objNgoDetails.Email = item.FieldValues[NGODetailsEntity.FieldsName.Email].GetString();
objNgoDetails.Phone = item.FieldValues[NGODetailsEntity.FieldsName.Phone].GetString();
objNgoDetails.Fax = item.FieldValues[NGODetailsEntity.FieldsName.Fax].GetString();
objNgoDetails.WebAddress = item.FieldValues[NGODetailsEntity.FieldsName.WebAddress].GetString();
objNgoDetails.Status = item.FieldValues[NGODetailsEntity.FieldsName.Status].GetBoolean();
objNgoDetails.CreatedDate = String.Format("{0:MM/dd/yyyy}", item[NGODetailsEntity.FieldsName.CreatedDate]);
lstCompany.Add(objNgoDetails);
}
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return lstCompany;
}
/// <summary>
/// Add Company Details into NGODetail list
/// </summary>
///
public static bool SaveNGODetails(NGODetailsEntity objNGODetailsEntity)
{
bool result = false;
//get credentials
string userName = Common.GetAssetsSiteUserName();
string password = Common.GetAssetsSitePassword();
string domain = Common.GetAssetsSiteDomain();
try
{
using (ClientContext clientContext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientContext.Credentials = new NetworkCredential(userName, password, domain);
Web web = clientContext.Web;
List oList = web.Lists.GetByTitle(NGODetailsEntity.ListName);
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem item = oList.AddItem(itemCreateInfo);
item[NGODetailsEntity.FieldsName.Title] = objNGODetailsEntity.Title;
item[NGODetailsEntity.FieldsName.CompanyName] = objNGODetailsEntity.CompanyName;
item[NGODetailsEntity.FieldsName.CompanyType] = objNGODetailsEntity.CompanyType;
item[NGODetailsEntity.FieldsName.Country] = objNGODetailsEntity.Country;
item[NGODetailsEntity.FieldsName.State] = objNGODetailsEntity.State;
item[NGODetailsEntity.FieldsName.City] = objNGODetailsEntity.City;
item[NGODetailsEntity.FieldsName.Address1] = objNGODetailsEntity.Address1;
item[NGODetailsEntity.FieldsName.Address2] = objNGODetailsEntity.Address2;
item[NGODetailsEntity.FieldsName.PostalCode] = objNGODetailsEntity.PostalCode;
item[NGODetailsEntity.FieldsName.Phone] = objNGODetailsEntity.Phone;
item[NGODetailsEntity.FieldsName.Fax] = objNGODetailsEntity.Fax;
item[NGODetailsEntity.FieldsName.WebAddress] = objNGODetailsEntity.WebAddress;
item[NGODetailsEntity.FieldsName.Status] = objNGODetailsEntity.Status;
item[NGODetailsEntity.FieldsName.Email] = objNGODetailsEntity.Email;
item.Update();
clientContext.ExecuteQuery();
result = true;
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return result;
}
/// <summary>
/// updating NGO Details
/// /// </summary>
///
///
public static bool UpdateNGODetails(NGODetailsEntity objNGODetailsEntity)
{
bool result = false;
//get credentials
string userName = Common.GetAssetsSiteUserName();
string password = Common.GetAssetsSitePassword();
string domain = Common.GetAssetsSiteDomain();
try
{
using (ClientContext clientContext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientContext.Credentials = new NetworkCredential(userName, password, domain);
Web web = clientContext.Web;
List oList = web.Lists.GetByTitle(NGODetailsEntity.ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>
<Query>
<Where>
<Eq><FieldRef Name='" + NGODetailsEntity.FieldsName.NgoId + "'/><Value Type='Text'>" + objNGODetailsEntity.NGOId + @"</Value></Eq>
</Where>
</Query>
</View>";
ListItemCollection listItemCollection = oList.GetItems(query);
clientContext.Load(listItemCollection);
clientContext.ExecuteQuery();
if (listItemCollection != null)
{
foreach (ListItem item in listItemCollection)
{
ListItem itemToUpdate = listItemCollection.GetById(listItemCollection[0]["ID"].ToString());
itemToUpdate[NGODetailsEntity.FieldsName.Title] = objNGODetailsEntity.Title;
itemToUpdate[NGODetailsEntity.FieldsName.CompanyName] = objNGODetailsEntity.CompanyName;
itemToUpdate[NGODetailsEntity.FieldsName.CompanyType] = objNGODetailsEntity.CompanyType;
itemToUpdate[NGODetailsEntity.FieldsName.Country] = objNGODetailsEntity.Country;
itemToUpdate[NGODetailsEntity.FieldsName.State] = objNGODetailsEntity.State;
itemToUpdate[NGODetailsEntity.FieldsName.City] = objNGODetailsEntity.City;
itemToUpdate[NGODetailsEntity.FieldsName.Address1] = objNGODetailsEntity.Address1;
itemToUpdate[NGODetailsEntity.FieldsName.Address2] = objNGODetailsEntity.Address2;
itemToUpdate[NGODetailsEntity.FieldsName.PostalCode] = objNGODetailsEntity.PostalCode;
itemToUpdate[NGODetailsEntity.FieldsName.Phone] = objNGODetailsEntity.Phone;
itemToUpdate[NGODetailsEntity.FieldsName.Fax] = objNGODetailsEntity.Fax;
itemToUpdate[NGODetailsEntity.FieldsName.WebAddress] = objNGODetailsEntity.WebAddress;
itemToUpdate[NGODetailsEntity.FieldsName.Status] = objNGODetailsEntity.Status;
itemToUpdate[NGODetailsEntity.FieldsName.Email] = objNGODetailsEntity.Email;
itemToUpdate.Update();
clientContext.ExecuteQuery();
result = true;
}
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return result;
}
/// <summary>
/// This Method is used to Update The List ( UserDetails(Field-Status,SAPID) && NotifiedCompanies(Field- AssociateSAPId)) based on SAPId,UserId,notifyCompanyId
/// </summary>
/// <param name="SAPId"></param>
/// <param name="UserId"></param>
/// <param name="notifyCompanyId"></param>
/// <returns></returns>
///
public static bool UpdateUserDetailNGOMember(string NGOId, string UserId, string UnverifyNgoId)
{
bool result = false;
//get credentials
string userName = Common.GetAssetsSiteUserName();
string password = Common.GetAssetsSitePassword();
string domain = Common.GetAssetsSiteDomain();
try
{
using (ClientContext clientContext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientContext.Credentials = new NetworkCredential(userName, password, domain);
Web web = clientContext.Web;
// update UserNgoDetails info
List oList = web.Lists.GetByTitle(UserNGOEntity.ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>
<Query>
<Where>
<Eq><FieldRef Name = '" + UserNgoDetailsEntity.FieldsName.Email + "'/><Value Type='Text'>" + UserId + @"</Value></Eq>
</Where>
</Query>
</View>";
ListItemCollection listItemCollection = oList.GetItems(query);
clientContext.Load(listItemCollection);
clientContext.ExecuteQuery();
if (listItemCollection != null)
{
foreach (ListItem item in listItemCollection)
{
ListItem itemToUpdate = listItemCollection.GetById(listItemCollection[0]["ID"].ToString());
itemToUpdate[UserNgoDetailsEntity.FieldsName.SAPId] = NgoId;
itemToUpdate[UserNgoDetailsEntity.FieldsName.Status] = true;
itemToUpdate.Update();
clientContext.ExecuteQuery();
//result = true;
}
}
// update UnverifiedNGO info
List oListNotified = web.Lists.GetByTitle(UnverifiedEntity.ListName);
CamlQuery queryNotified = new CamlQuery();
queryNotified.ViewXml = @"<View>
<Query>
<Where>
<Eq><FieldRef Name = '" + UnverifiedEntity.FieldsName.ID + "'/><Value Type='Text'>" + unverifiedId + @"</Value></Eq>
</Where>
</Query>
</View>";
ListItemCollection listItemCollectionNotified = oListNotified.GetItems(queryNotified);
clientContext.Load(listItemCollectionNotified);
clientContext.ExecuteQuery();
if (listItemCollectionNotified != null)
{
foreach (ListItem item in listItemCollectionNotified)
{
ListItem itemToUpdateNotified = listItemCollectionNotified.GetById(listItemCollectionNotified[0]["ID"].ToString());
itemToUpdateNotified[UnverifiedEntity.FieldsName.AssociateSAPId] = NgoId;
itemToUpdateNotified.Update();
clientContext.ExecuteQuery();
}
}
result = true;
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return result;
}
/// <summary>
/// This Method is used to Delete Record From The List ( UserDetails, NotifiedCompanies) based on UserId,notifyCompanyId
/// </summary>
/// <param name="UserId"></param>
/// <param name="notifyCompanyId"></param>
/// <returns></returns>
///
public static bool DeleteUserDetailNGOHead(string UserId, string notifyCompanyId)
{
bool result = false;
//get credentials
string userName = Common.GetAssetsSiteUserName();
string password = Common.GetAssetsSitePassword();
string domain = Common.GetAssetsSiteDomain();
try
{
using (ClientContext clientContext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientContext.Credentials = new NetworkCredential(userName, password, domain);
Web web = clientContext.Web;
// Delete UserDetails info
List oList = web.Lists.GetByTitle(UserDetailsEntity.ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>
<Query>
<Where>
<Eq><FieldRef Name = '" + UserDetailsEntity.FieldsName.Email + "'/><Value Type='Text'>" + UserId + @"</Value></Eq>
</Where>
</Query>
</View>";
ListItemCollection listItemCollection = oList.GetItems(query);
clientContext.Load(listItemCollection);
clientContext.ExecuteQuery();
if (listItemCollection != null)
{
foreach (ListItem item in listItemCollection)
{
listItemCollection[0].DeleteObject();
clientContext.ExecuteQuery();
}
}
// Delete NotifiedCompanies info
List oListNotified = web.Lists.GetByTitle(UnverifiedNgoEntity.ListName);
CamlQuery queryNotified = new CamlQuery();
queryNotified.ViewXml = @"<View>
<Query>
<Where>
<Eq><FieldRef Name = '" + UnverifiedNgoEntity.FieldsName.ID + "'/><Value Type='Text'>" + notifyCompanyId + @"</Value></Eq>
</Where>
</Query>
</View>";
ListItemCollection listItemCollectionNotified = oListNotified.GetItems(queryNotified);
clientContext.Load(listItemCollectionNotified);
clientContext.ExecuteQuery();
if (listItemCollectionNotified != null)
{
foreach (ListItem item in listItemCollectionNotified)
{
listItemCollectionNotified[0].DeleteObject();
clientContext.ExecuteQuery();
}
}
result = true;
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return result;
}
/// <summary>
/// /// This Method is used to get Next NgOID from NGODetails List
/// </summary>
/// <returns></returns>
public static string SetNGOId()
{
string CompanyId = string.Empty;
string strUserName = Common.GetAssetsSiteUserName();
string strDomain = Common.GetAssetsSiteDomain();
string strPassword = Common.GetAssetsSitePassword();
try
{
using (ClientContext clientcontext = new ClientContext(Common.AssetsSitePath + "/ngo"))
{
clientcontext.Credentials = new NetworkCredential(strUserName, strPassword, strDomain);
Web web = clientcontext.Web;
///create list object
List splist = web.Lists.GetByTitle(NGODetailsEntity.ListName);
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>
<Query>
<OrderBy><FieldRef Name='" + NGODetailsEntity.FieldsName.CreatedDate + @"' Ascending='False' /></OrderBy>
</Query>
<RowLimit>1</RowLimit>
</View>";
Microsoft.SharePoint.Client.ListItemCollection itemCollection = splist.GetItems(query);
clientcontext.Load(splist);
clientcontext.Load(itemCollection);
clientcontext.ExecuteQuery();
if (itemCollection != null && itemCollection.Count > 0)
{
int id = itemCollection[0][NGODetailsEntity.FieldsName.ID].GetInteger();
id++;
string intID = id.ToString("1245");
CompanyId = "NGO" + intID;
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
return CompanyId;
}
}
*********************************NGO Listing Page ****************************
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="NGOListingUserControl.ascx.cs" Inherits="NGO.UIPages.NGOListing.NGOListingUserControl" %>
<div class="container">
<div class="row-">
<h2>NGO Listing
<aside><asp:HyperLink ID="hypCreateNGO" runat="server" class="floatR padT10 padB10 create">Create Ngo </asp:HyperLink></aside>
</h2>
<section class="bgWhite marB20">
<div class="form all100 lab_BC" id="divActive" runat="server" style="display: inline;">
<div class="row-">
<fieldset class="col-sm-4">
Ngo<label> Name<span class="mand">*</span></label>
<asp:TextBox ID="txtCname" runat="server" MaxLength="50"></asp:TextBox>
</fieldset>
<fieldset class="col-sm-4">
<label>NgoId<span class="mand">*</span></label>
<asp:TextBox ID="txtSapId" CssClass="dropdownMenu" runat="server" MaxLength="50"></asp:TextBox>
</fieldset>
<fieldset class="col-sm-4">
<label>Postal Code<span class="mand">*</span></label>
<asp:TextBox ID="txtPostCode" CssClass="dropdownMenu" runat="server" MaxLength="50"></asp:TextBox>
</fieldset>
</div>
<div class="r cap">
<asp:Button ID="btnExcel" runat="server" Text="Export To Excel" OnClick="btnExcel_Click1" />
<asp:Button ID="btnReset" class="btn reset bg_dGrey" runat="server" Text="Reset" OnClick="btnReset_Click" />
<asp:Button ID="btnSubmit" class="btn" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</div>
<div>
<asp:Label ID="lblRMessage" runat="server" Style="display: block; padding-bottom: 10px; font-size: 14px; color: Green; font-weight: bold;"></asp:Label>
<span class="floatL ff_75 c_blue">
<asp:Label ID="lblResultMsg" runat="server" />
</span>
<asp:GridView ID="gvCompany" OnPageIndexChanging="gvCompany_PageIndexChanging" PageSize="10" Width="100%" AllowPaging="True" AutoGenerateColumns="false"
EmptyDataText=" No record found..." CssClass="table table-striped" runat="server">
<Columns>
<asp:TemplateField HeaderText="Created Date" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("CreatedDate") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Title") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Company Name" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("CompanyName") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Email")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Company Type" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("CompanyType")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Country" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Country")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="State" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("State")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address1" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Address1")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address2" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Address2")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("City")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Postal Code" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("PostalCode")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Phone" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Phone")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fax" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Fax")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Web Address" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("WebAddress")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status" Visible="false" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Eval("Status")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:HyperLink ID="hypCM" runat="server" NavigateUrl='<%#String.Format("~/Ngoadmin/Pages/CreateNgo.aspx?NgoId={0}&Ng={1}", Eval("NGOID"),Eval("NGOType"))%>'>View</asp:HyperLink>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<span style='margin-left: 5px; color: red'>No record found... </span>
</EmptyDataTemplate>
<PagerStyle HorizontalAlign="Right" CssClass="pagination" />
<PagerSettings Position="TopAndBottom" />
</asp:GridView>
</div>
</div>
</section>
</div>
</div>
*****************************************CS Code********************* *********
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace NGO.UIPages.NGOListing
{
public partial class NGOListingUserControl : UserControl
{
/// <summary>
/// Variable Declaration
/// </summary>
/// <returns></returns>
string CountryId = string.Empty;
string companyType = string.Empty;
List<NGODetailsEntity> lstExcelNGODetailsEntity = null;
string region = string.Empty;
/// <summary>
/// Page Load Event
/// </summary>
/// <returns></returns>
protected void Page_Load(object sender, EventArgs e)
{
NgoType = Page.Request.QueryString["NG"] != null ? Page.Request.QueryString["NG"].ToString() : "NGO";
hypCreateNgo.NavigateUrl = "~/ngoadmin/pages/CreateNgo.aspx?NG=" + NgoType;
if (!IsPostBack)
{
try
{
BindCountry("");
BindCity("");
BindActiveNgoListing();
//BindInActiveCompanyListing();
string msg = Page.Request.QueryString["msg"].GetString();
if (!string.IsNullOrEmpty(msg))
{
if (msg == "1")
{
lblRMessage.Visible = true;
lblRMessage.Text = "Information Saved Successfully";
divActive.Style.Add("display", "block");
divInactive.Style.Add("display", "none");
}
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
/// <summary>
/// Selection Change Event Of Country Binding the City on basis of CountryId
/// </summary>
/// <returns></returns>
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
divActive.Style.Add("display", "block");
divInactive.Style.Add("display", "none");
CountryId = ddlCountry.SelectedValue.ToString();
BindCity(CountryId);
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Getting All Active Ngo Details
/// </summary>
/// <returns></returns>
protected void BindActiveNgoListing()
{
try
{
List<NGODetailsEntity> CompanyDetailObj = NgoHelper.GetActiveNgoDetailsClient(companyType);
if (CompanyDetailObj != null)
{
hdnCount.Value = CompanyDetailObj.Count.ToString();
lblResultMsg.Text = string.Format("Total Record : <b>{0}</b>, Search Result : <b>{1}</b>", hdnCount.Value, CompanyDetailObj.Count.ToString());
gvCompany.DataSource = CompanyDetailObj;
gvCompany.DataBind();
}
else
{
gvCompany.DataSource = CompanyDetailObj;
gvCompany.DataBind();
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Binding The City
/// </summary>
/// <returns></returns>
private void BindCity(string CountryId)
{
ddlCity.Items.Clear();
if (CountryId == "")
{
ddlCity.Items.Insert(0, (new ListItem("--Select--")));
}
else
{
List<CityEntity> lstCity = CommonHelper.GetCity(CountryId);
try
{
if (lstCity != null && lstCity.Count > 0)
{
ddlCity.DataSource = lstCity;
ddlCity.DataTextField = CityEntity.FieldsName.Title;
ddlCity.DataValueField = CityEntity.FieldsName.CountryId;
ddlCity.DataBind();
}
ddlCity.Items.Insert(0, (new ListItem("--Select--")));
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
/// <summary>
/// Binding The Country
/// </summary>
/// <returns></returns>
private void BindCountry(string regionIn)
{
ddlCountry.Items.Clear();
if (regionIn == "")
{
ddlCountry.Items.Insert(0, (new ListItem("--Select--")));
}
else
{
List<CountryEntity> LstCountry = CommonHelper.GetCountry(regionIn);
try
{
if (LstCountry != null && LstCountry.Count > 0)
{
LstCountry.Insert(0, new CountryEntity() { Title = "--Select--" });
ddlCountry.DataSource = LstCountry;
ddlCountry.DataTextField = CountryEntity.FieldsName.Title;
ddlCountry.DataValueField = CountryEntity.FieldsName.CountryCode;
ddlCountry.DataBind();
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
/// <summary>
/// Export To Excel of NGo Details
/// </summary>
/// <returns></returns>
protected void btnExcel_Click1(object sender, EventArgs e)
{
BindExcelReport();
DataTable dtable = lstExcelNGODetailsEntity.ToDataTable();
DataTable dt = new DataTable();
string[] column = { "CreatedDate","Title", "WebAddress","Status"};
dt = dtable.DefaultView.ToTable("dd", false, column);
dt.Columns[0].ColumnName = "Created Date";
dt.Columns[2].ColumnName = "NGO Name";
dt.AcceptChanges();
//Common.DownloadDealerGridToExcel(dt, "CompaniesDetails");
}
/// <summary>
/// Geting The of NGO Details for using export to Excel
/// </summary>
/// <returns></returns>
private void BindExcelReport()
{
try
{
lblRMessage.Visible = false;
gvCompany.AllowPaging = true;
lstExcelNGODetailsEntity = NGOHelper.GetActiveNGOClient(NgoType);
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Reset The All Fiter on privious position
/// </summary>
/// <returns></returns>
protected void btnReset_Click(object sender, EventArgs e)
{
try
{
divActive.Style.Add("display", "block");
divInactive.Style.Add("display", "none");
txtCname.Text = "";
txtPostCode.Text = "";
lblRMessage.Visible = false;
ddlCountry.SelectedIndex = 0;
ddlCity.SelectedIndex = 0;
BindActiveNGoListing();
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Search the Records From According the Condition Filter
/// </summary>
/// <returns></returns>
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
lblRMessage.Visible = false;
divActive.Style.Add("display", "block");
divInactive.Style.Add("display", "none");
NGODetailsEntity objNGODetails = new NGODetailsEntity();
objNGODetails.CompanyName = txtCname.Text.Trim();
objNGODetails.Country = ddlCountry.SelectedValue;
objNGODetails.City = ddlCity.SelectedItem.Text.Trim();
objNGODetails.PostalCode = txtPostCode.Text.Trim();
objNGODetails.Region = drpRegions.SelectedItem.Value;
objNGODetails.SAPId = txtSapId.Text.Trim();
objNGODetails.CompanyType = companyType;
List<NGODetailsEntity> ObjFilterCompanyDetail = NGOHelper.GetFilterNGODetail(objNGODetails);
if (ObjFilterCompanyDetail != null)
{
//hdnCount.Value = ObjFilterCompanyDetail.Count.ToString();
lblResultMsg.Text = string.Format("Total Record : <b>{0}</b>, Search Result : <b>{1}</b>", hdnCount.Value, ObjFilterNGODetail.Count.ToString());
gvCompany.DataSource = ObjFilterCompanyDetail;
gvCompany.DataBind();
}
else
{
ObjFilterCompanyDetail = new List<NGODetailsEntity>();
lblResultMsg.Text = string.Format("Total Record : <b>{0}</b>, Search Result : <b>{1}</b>", hdnCount.Value, "0");
gvCompany.DataSource = ObjFilterCompanyDetail;
gvCompany.DataBind();
}
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
/// <summary>
/// Paging in Active NGO
/// </summary>
/// <returns></returns>
protected void gvNGO_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)
{
try
{
lblRMessage.Visible = false;
divActive.Style.Add("display", "block");
divInactive.Style.Add("display", "none");
gvCompany.PageIndex = e.NewPageIndex;
BindActiveCompanyListing();
}
catch (Exception ex)
{
ErrorLog.LogError(ex);
}
}
}
}
No comments:
Post a Comment