set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author : Sumit
-- Optimised By : Ashutosh Yadav
-- Create date : 26 April 2007
-- Description : This procedure selects all merchants by status(0 = All, 1 = Active)
-- =============================================
ALTER PROCEDURE [dbo].[usp_GetAllMerchants]
@Status smallint
AS
BEGIN TRY
SET NOCOUNT ON;
IF @Status = 0
BEGIN
SELECT mm.*,am.AffNetworkName,(CASE MerchantStatus WHEN 1 THEN 'Active' WHEN 0 THEN 'InActive' when -1 then 'Recover' END) as MStatus,
(Case MerchantStatus when 1 then 'Deactivate' when 0 then 'Activate' when -1 then 'Recover' end) as Act,
(Case MerchantStatus when 1 then 'Delete' when 0 then 'Delete' end) as Del
FROM tblMerchantMaster mm INNER JOIN tblAffiliateNetworkMaster am ON am.AffiliateId = mm.AffiliateId Where mm.MerchantStatus = 0
END
ELSE IF @Status = 1
BEGIN
SELECT mm.*,am.AffNetworkName,(CASE MerchantStatus WHEN 1 THEN 'Active' WHEN 0 THEN 'InActive' when -1 then 'Recover' END) as MStatus,
(Case MerchantStatus when 1 then 'Deactivate' when 0 then 'Activate' when -1 then 'Recover' end) as Act,
(Case MerchantStatus when 1 then 'Delete' when 0 then 'Delete' end) as Del
FROM tblMerchantMaster mm INNER JOIN tblAffiliateNetworkMaster am ON am.AffiliateId = mm.AffiliateId
WHERE mm.MerchantStatus = 1
END
ELSE IF @Status = 2
BEGIN
SELECT mm.MerchantId,mm.MerchantName,am.AffNetworkName
FROM tblMerchantMaster mm INNER JOIN tblAffiliateNetworkMaster am ON am.AffiliateId = mm.AffiliateId
WHERE mm.MerchantStatus = 1
END
END TRY
BEGIN CATCH
insert into tbldberrorlog Values (ERROR_NUMBER(), ERROR_MESSAGE(), GETDATE(), 'usp_GetAllMerchants')
END CATCH
Friday, January 22, 2010
BLL_Affiliate.cs
using System;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using Rupiz.SqlDatabaseHelper;
namespace Rupiz.AffiliateNetwork
{
public class BLL_AffiliateNetworkManagement
{
#region "Constructor"
private String _conString;
public BLL_AffiliateNetworkManagement()
{
try
{
if (ConfigurationManager.ConnectionStrings["strConnectionString"] != null)
{
_conString = ConfigurationManager.ConnectionStrings["strConnectionString"].ConnectionString;
}
else
{
throw new ApplicationException("Sorry, connection to database could not made");
}
}
catch
{
throw;
}
}
#endregion
#region "PROPERTIES"
private int? _affNetId = null;
public int? AffNetId
{
get { return _affNetId; }
set { _affNetId = value; }
}
private string _affNetName;
public string AffNetName
{
get { return _affNetName; }
set { _affNetName = value; }
}
private string _affNetUrl;
public string AffNetUrl
{
get { return _affNetUrl; }
set { _affNetUrl = value; }
}
private string _affNetDescription;
public string AffNetDescription
{
get { return _affNetDescription; }
set { _affNetDescription = value; }
}
private string _paymentMode;
public string PaymentMode
{
get { return _paymentMode; }
set { _paymentMode = value; }
}
private string _paymentGrace;
public string PaymentGrace
{
get { return _paymentGrace; }
set { _paymentGrace = value; }
}
private int? _status = null;
public int? Status
{
get { return _status; }
set { _status = value; }
}
private int? _userid = null;
public int? UserID
{
get { return _userid; }
set { _userid = value; }
}
#endregion
#region "FUNCTIONS"
public DataTable GetAllAffiliate()
{
try
{
DataSet ds = SqlHelper.ExecuteDataset(_conString, CommandType.StoredProcedure, "usp_GetAllAffiliate"); // Get Affiliates from database
if (ds != null)
{
DataTable dt = ds.Tables[0].Copy();
ds.Dispose();
return dt;
}
else
{
return (DataTable)null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public void GetAffiliateById()
{
try
{
SqlParameter pAffId = SqlHelper.CreateParameter("@AffiliateId", AffNetId);
SqlParameter[] allParams = { pAffId };
DataSet ds = SqlHelper.ExecuteDataset(_conString, "usp_GetAffiliateById", pAffId); // Get Affiliates from database
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
DataRow dr = ds.Tables[0].Rows[0];
if (dr != null)
{
AffNetDescription = String.Empty;
if (dr["AffDescription"].ToString() != null)
{
AffNetDescription = dr["AffDescription"].ToString();
}
AffNetName = String.Empty;
if (dr["AffNetworkName"].ToString() != null)
{
AffNetName = dr["AffNetworkName"].ToString();
}
AffNetUrl = String.Empty;
if (dr["AffiliateUrl"].ToString() != null)
{
AffNetUrl = dr["AffiliateUrl"].ToString();
}
PaymentMode = String.Empty;
if (dr["PaymentMode"].ToString() != null)
{
PaymentMode = dr["PaymentMode"].ToString();
}
PaymentGrace = String.Empty;
if (dr["PaymentDate"].ToString() != null)
{
PaymentGrace = dr["PaymentDate"].ToString();
}
if (dr["AffiliateStatus"].ToString() != null)
{
Status = Convert.ToInt32(dr["AffiliateStatus"].ToString());
}
}
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public int AddUpdAffiliate()
{
try
{
SqlParameter pAffiliateId = SqlHelper.CreateParameter("@AffiliateId", DBNull.Value);
if (AffNetId.HasValue)
{
pAffiliateId.Value = AffNetId.Value;
}
SqlParameter pNetworkName = SqlHelper.CreateParameter("@AffNetworkName", DBNull.Value);
if (AffNetName != string.Empty)
{
pNetworkName.Value = AffNetName;
}
SqlParameter pAffNetUrl = SqlHelper.CreateParameter("@AffiliateUrl", DBNull.Value);
if (AffNetUrl != string.Empty)
{
pAffNetUrl.Value = AffNetUrl;
}
SqlParameter pAffNetDescription = SqlHelper.CreateParameter("@AffDescription", DBNull.Value);
if (AffNetDescription != string.Empty)
{
pAffNetDescription.Value = AffNetDescription;
}
SqlParameter pPaymentMode = SqlHelper.CreateParameter("@PaymentMode", DBNull.Value);
if (PaymentMode != string.Empty)
{
pPaymentMode.Value = PaymentMode;
}
SqlParameter pPaymentGrace = SqlHelper.CreateParameter("@PaymentDate", DBNull.Value);
if (PaymentGrace != string.Empty)
{
pPaymentGrace.Value = PaymentGrace;
}
SqlParameter pModifiedBy = SqlHelper.CreateParameter("@ModifiedBy", DBNull.Value);
if (UserID.HasValue)
{
pModifiedBy.Value = UserID.HasValue;
}
SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
SqlParameter pStatus = SqlHelper.CreateParameter("@AffiliateStatus", DBNull.Value);
if (Status.HasValue)
{
pStatus.Value = Status.Value;
}
// create array of parameters
SqlParameter[] allParams = { pAffiliateId, pNetworkName, pAffNetUrl, pAffNetDescription, pPaymentMode, pPaymentGrace, pModifiedBy, pStatus, pErr };
// store data into the database
SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_AddUpdAffiliate", allParams);
// return the error number (0,1)
int result = -1;
if (pErr.Value != null)
{
result = (int)pErr.Value;
}
return result;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public DataTable GetAffiliateNetworkByStatus(int Status)
{
try
{
SqlParameter statusAff = SqlHelper.CreateParameter("@AffiliateStatus", Status);
SqlParameter[] allParams = { statusAff };
// store data into the database
DataSet ds = SqlHelper.ExecuteDataset(_conString, CommandType.StoredProcedure, "usp_GetAllAffiliateByStatus", allParams);
// return the error number (0,1)
if (ds != null)
{
DataTable dt = ds.Tables[0].Copy();
ds.Dispose();
return dt;
}
else
{
return (DataTable)null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
//public int AddAffiliateNetwork()
//{
// try
// {
// // create parameters
// SqlParameter affNetworkName = SqlHelper.CreateParameter("@AffNetworkName", AffNetName);
// SqlParameter affiliateUrl = SqlHelper.CreateParameter("@AffiliateUrl", AffNetUrl);
// SqlParameter affDescription = SqlHelper.CreateParameter("@AffDescription", AffNetDescription);
// SqlParameter paymentMode = SqlHelper.CreateParameter("@PaymentMode", PaymentMode);
// SqlParameter paymentDate = SqlHelper.CreateParameter("@PaymentDate", PaymentGrace);
// SqlParameter modifiedBy = SqlHelper.CreateParameter("@ModifiedBy", UserID);
// SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
// // create array of parameters
// SqlParameter[] allParams = { affNetworkName, affiliateUrl, affDescription, paymentMode, paymentDate, modifiedBy, pErr };
// // store data into the database
// SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_AddNewAffiliate", allParams);
// // return the error number (0,1)
// int result = -1;
// if (pErr.Value != null)
// {
// result = (int)pErr.Value;
// }
// return result;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
//public int UpdateAffiliateNetworkStatus()
//{
// try
// {
// // create parameters
// SqlParameter affNetworkId = SqlHelper.CreateParameter("@AffiliateId", AffNetId);
// SqlParameter affStatus = SqlHelper.CreateParameter("@AffiliateStatus", Status);
// SqlParameter modifiedBy = SqlHelper.CreateParameter("@ModifiedBy", UserID);
// SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
// // create array of parameters
// SqlParameter[] allParams = { affNetworkId, affStatus, modifiedBy, pErr };
// // store data into the database
// SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_UpdateAffiliate", allParams);
// // return the error number (0,1)
// int result = -1;
// if (pErr.Value != null)
// {
// result = (int)pErr.Value;
// }
// return result;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
//public int UpdateAffiliateNetwork()
//{
// try
// {
// // create parameters
// SqlParameter affNetworkId = SqlHelper.CreateParameter("@AffiliateId", AffNetId);
// SqlParameter affiliateUrl = SqlHelper.CreateParameter("@AffiliateUrl", AffNetUrl);
// SqlParameter affDescription = SqlHelper.CreateParameter("@AffDescription", AffNetDescription);
// SqlParameter paymentMode = SqlHelper.CreateParameter("@PaymentMode", PaymentMode);
// SqlParameter paymentDate = SqlHelper.CreateParameter("@PaymentDate", PaymentGrace);
// SqlParameter modifiedBy = SqlHelper.CreateParameter("@ModifiedBy", UserID);
// SqlParameter statusAff = SqlHelper.CreateParameter("@AffiliateStatus", Status);
// SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
// // create array of parameters
// SqlParameter[] allParams = { affNetworkId, affiliateUrl, affDescription, paymentMode, paymentDate, modifiedBy, statusAff, pErr };
// // store data into the database
// SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_UpdateAffiliate", allParams);
// // return the error number (0,1)
// int result = -1;
// if (pErr.Value != null)
// {
// result = (int)pErr.Value;
// }
// return result;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
#endregion
}
}
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using Rupiz.SqlDatabaseHelper;
namespace Rupiz.AffiliateNetwork
{
public class BLL_AffiliateNetworkManagement
{
#region "Constructor"
private String _conString;
public BLL_AffiliateNetworkManagement()
{
try
{
if (ConfigurationManager.ConnectionStrings["strConnectionString"] != null)
{
_conString = ConfigurationManager.ConnectionStrings["strConnectionString"].ConnectionString;
}
else
{
throw new ApplicationException("Sorry, connection to database could not made");
}
}
catch
{
throw;
}
}
#endregion
#region "PROPERTIES"
private int? _affNetId = null;
public int? AffNetId
{
get { return _affNetId; }
set { _affNetId = value; }
}
private string _affNetName;
public string AffNetName
{
get { return _affNetName; }
set { _affNetName = value; }
}
private string _affNetUrl;
public string AffNetUrl
{
get { return _affNetUrl; }
set { _affNetUrl = value; }
}
private string _affNetDescription;
public string AffNetDescription
{
get { return _affNetDescription; }
set { _affNetDescription = value; }
}
private string _paymentMode;
public string PaymentMode
{
get { return _paymentMode; }
set { _paymentMode = value; }
}
private string _paymentGrace;
public string PaymentGrace
{
get { return _paymentGrace; }
set { _paymentGrace = value; }
}
private int? _status = null;
public int? Status
{
get { return _status; }
set { _status = value; }
}
private int? _userid = null;
public int? UserID
{
get { return _userid; }
set { _userid = value; }
}
#endregion
#region "FUNCTIONS"
public DataTable GetAllAffiliate()
{
try
{
DataSet ds = SqlHelper.ExecuteDataset(_conString, CommandType.StoredProcedure, "usp_GetAllAffiliate"); // Get Affiliates from database
if (ds != null)
{
DataTable dt = ds.Tables[0].Copy();
ds.Dispose();
return dt;
}
else
{
return (DataTable)null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public void GetAffiliateById()
{
try
{
SqlParameter pAffId = SqlHelper.CreateParameter("@AffiliateId", AffNetId);
SqlParameter[] allParams = { pAffId };
DataSet ds = SqlHelper.ExecuteDataset(_conString, "usp_GetAffiliateById", pAffId); // Get Affiliates from database
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
DataRow dr = ds.Tables[0].Rows[0];
if (dr != null)
{
AffNetDescription = String.Empty;
if (dr["AffDescription"].ToString() != null)
{
AffNetDescription = dr["AffDescription"].ToString();
}
AffNetName = String.Empty;
if (dr["AffNetworkName"].ToString() != null)
{
AffNetName = dr["AffNetworkName"].ToString();
}
AffNetUrl = String.Empty;
if (dr["AffiliateUrl"].ToString() != null)
{
AffNetUrl = dr["AffiliateUrl"].ToString();
}
PaymentMode = String.Empty;
if (dr["PaymentMode"].ToString() != null)
{
PaymentMode = dr["PaymentMode"].ToString();
}
PaymentGrace = String.Empty;
if (dr["PaymentDate"].ToString() != null)
{
PaymentGrace = dr["PaymentDate"].ToString();
}
if (dr["AffiliateStatus"].ToString() != null)
{
Status = Convert.ToInt32(dr["AffiliateStatus"].ToString());
}
}
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public int AddUpdAffiliate()
{
try
{
SqlParameter pAffiliateId = SqlHelper.CreateParameter("@AffiliateId", DBNull.Value);
if (AffNetId.HasValue)
{
pAffiliateId.Value = AffNetId.Value;
}
SqlParameter pNetworkName = SqlHelper.CreateParameter("@AffNetworkName", DBNull.Value);
if (AffNetName != string.Empty)
{
pNetworkName.Value = AffNetName;
}
SqlParameter pAffNetUrl = SqlHelper.CreateParameter("@AffiliateUrl", DBNull.Value);
if (AffNetUrl != string.Empty)
{
pAffNetUrl.Value = AffNetUrl;
}
SqlParameter pAffNetDescription = SqlHelper.CreateParameter("@AffDescription", DBNull.Value);
if (AffNetDescription != string.Empty)
{
pAffNetDescription.Value = AffNetDescription;
}
SqlParameter pPaymentMode = SqlHelper.CreateParameter("@PaymentMode", DBNull.Value);
if (PaymentMode != string.Empty)
{
pPaymentMode.Value = PaymentMode;
}
SqlParameter pPaymentGrace = SqlHelper.CreateParameter("@PaymentDate", DBNull.Value);
if (PaymentGrace != string.Empty)
{
pPaymentGrace.Value = PaymentGrace;
}
SqlParameter pModifiedBy = SqlHelper.CreateParameter("@ModifiedBy", DBNull.Value);
if (UserID.HasValue)
{
pModifiedBy.Value = UserID.HasValue;
}
SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
SqlParameter pStatus = SqlHelper.CreateParameter("@AffiliateStatus", DBNull.Value);
if (Status.HasValue)
{
pStatus.Value = Status.Value;
}
// create array of parameters
SqlParameter[] allParams = { pAffiliateId, pNetworkName, pAffNetUrl, pAffNetDescription, pPaymentMode, pPaymentGrace, pModifiedBy, pStatus, pErr };
// store data into the database
SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_AddUpdAffiliate", allParams);
// return the error number (0,1)
int result = -1;
if (pErr.Value != null)
{
result = (int)pErr.Value;
}
return result;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public DataTable GetAffiliateNetworkByStatus(int Status)
{
try
{
SqlParameter statusAff = SqlHelper.CreateParameter("@AffiliateStatus", Status);
SqlParameter[] allParams = { statusAff };
// store data into the database
DataSet ds = SqlHelper.ExecuteDataset(_conString, CommandType.StoredProcedure, "usp_GetAllAffiliateByStatus", allParams);
// return the error number (0,1)
if (ds != null)
{
DataTable dt = ds.Tables[0].Copy();
ds.Dispose();
return dt;
}
else
{
return (DataTable)null;
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
//public int AddAffiliateNetwork()
//{
// try
// {
// // create parameters
// SqlParameter affNetworkName = SqlHelper.CreateParameter("@AffNetworkName", AffNetName);
// SqlParameter affiliateUrl = SqlHelper.CreateParameter("@AffiliateUrl", AffNetUrl);
// SqlParameter affDescription = SqlHelper.CreateParameter("@AffDescription", AffNetDescription);
// SqlParameter paymentMode = SqlHelper.CreateParameter("@PaymentMode", PaymentMode);
// SqlParameter paymentDate = SqlHelper.CreateParameter("@PaymentDate", PaymentGrace);
// SqlParameter modifiedBy = SqlHelper.CreateParameter("@ModifiedBy", UserID);
// SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
// // create array of parameters
// SqlParameter[] allParams = { affNetworkName, affiliateUrl, affDescription, paymentMode, paymentDate, modifiedBy, pErr };
// // store data into the database
// SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_AddNewAffiliate", allParams);
// // return the error number (0,1)
// int result = -1;
// if (pErr.Value != null)
// {
// result = (int)pErr.Value;
// }
// return result;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
//public int UpdateAffiliateNetworkStatus()
//{
// try
// {
// // create parameters
// SqlParameter affNetworkId = SqlHelper.CreateParameter("@AffiliateId", AffNetId);
// SqlParameter affStatus = SqlHelper.CreateParameter("@AffiliateStatus", Status);
// SqlParameter modifiedBy = SqlHelper.CreateParameter("@ModifiedBy", UserID);
// SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
// // create array of parameters
// SqlParameter[] allParams = { affNetworkId, affStatus, modifiedBy, pErr };
// // store data into the database
// SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_UpdateAffiliate", allParams);
// // return the error number (0,1)
// int result = -1;
// if (pErr.Value != null)
// {
// result = (int)pErr.Value;
// }
// return result;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
//public int UpdateAffiliateNetwork()
//{
// try
// {
// // create parameters
// SqlParameter affNetworkId = SqlHelper.CreateParameter("@AffiliateId", AffNetId);
// SqlParameter affiliateUrl = SqlHelper.CreateParameter("@AffiliateUrl", AffNetUrl);
// SqlParameter affDescription = SqlHelper.CreateParameter("@AffDescription", AffNetDescription);
// SqlParameter paymentMode = SqlHelper.CreateParameter("@PaymentMode", PaymentMode);
// SqlParameter paymentDate = SqlHelper.CreateParameter("@PaymentDate", PaymentGrace);
// SqlParameter modifiedBy = SqlHelper.CreateParameter("@ModifiedBy", UserID);
// SqlParameter statusAff = SqlHelper.CreateParameter("@AffiliateStatus", Status);
// SqlParameter pErr = SqlHelper.CreateParameter("@err", -1, ParameterDirection.Output);
// // create array of parameters
// SqlParameter[] allParams = { affNetworkId, affiliateUrl, affDescription, paymentMode, paymentDate, modifiedBy, statusAff, pErr };
// // store data into the database
// SqlHelper.ExecuteNonQuery(_conString, CommandType.StoredProcedure, "usp_UpdateAffiliate", allParams);
// // return the error number (0,1)
// int result = -1;
// if (pErr.Value != null)
// {
// result = (int)pErr.Value;
// }
// return result;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
//}
#endregion
}
}
view-editAffiliate.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Rupiz.Security;
using Rupiz.AffiliateNetwork;
public partial class UI_EditAffiliateView : System.Web.UI.Page
{
private BLL_AffiliateNetworkManagement affNetwork = null;
private AuthorizeAccess access = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
//lblMsg.Text = String.Empty;
//lblEditAffName.Focus();
access = new AuthorizeAccess();
affNetwork = new BLL_AffiliateNetworkManagement();
if (Request.QueryString["AffId"] != null)
{
ViewState["AffId"] = access.Decrypt(Request.QueryString["AffId"].ToString());
if (!IsPostBack)
{
GetAffDetails();
}
}
else
{
Response.Redirect(Page.ResolveUrl(String.Format("~/Admin/AffiliateNetwork/ViewAffNetworks.aspx?mid={0}&eId={1}", Server.UrlEncode(access.Encrypt("20")), Server.UrlEncode(access.Encrypt("19")))));
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
private void GetAffDetails()
{
try
{
affNetwork.AffNetId = Convert.ToInt32(ViewState["AffId"].ToString());//Convert.ToInt32(Request.QueryString["affId"]);
affNetwork.GetAffiliateById();
txtEditAffDes.Text = affNetwork.AffNetDescription;
lblEditAffName.Text = affNetwork.AffNetName;
txtEditAffUrl.Text = affNetwork.AffNetUrl;
txtEditPaymentDate.Text = affNetwork.PaymentGrace;
rbtnEditAffPaymentmode.SelectedValue = affNetwork.PaymentMode;
if (affNetwork.Status == 1)
{
rdoActive.Checked = true;
}
else if (affNetwork.Status == 0)
{
rdoInactive.Checked = true;
}
else
{
rdoDeleted.Checked = true;
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
private bool ValidateForm()
{
if ((!rdoActive.Checked) && (!rdoInactive.Checked) && (!rdoDeleted.Checked))
{
lblMsg.Text = "The affiliate network status cannot be left unselect";
return false;
}
return true;
}
protected void btnUpdateAff_Click(object sender, EventArgs e)
{
try
{
if (Page.IsValid)
{
if (ValidateForm())
{
affNetwork.AffNetId = Convert.ToInt32(ViewState["AffId"].ToString()); //Convert.ToInt32(Request.QueryString["affId"]);
affNetwork.AffNetDescription = txtEditAffDes.Text.Trim();
affNetwork.AffNetUrl = txtEditAffUrl.Text.Trim();
affNetwork.UserID = Convert.ToInt32(Session["UserId"]);
affNetwork.PaymentMode = rbtnEditAffPaymentmode.SelectedValue.Trim();
affNetwork.PaymentGrace = txtEditPaymentDate.Text.Trim();
if (rdoActive.Checked)
{
affNetwork.Status = 1; // Active
}
else if (rdoInactive.Checked)
{
affNetwork.Status = 0; // Inactive
}
else
{
affNetwork.Status = -1; // Deleted
}
int result = affNetwork.AddUpdAffiliate();
if (result == 0)
{
if (Request.QueryString["eId"] != null)
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&eId=" + Server.UrlEncode(Request.QueryString["eId"].ToString()) + "&UMsg=0", false);
}
else
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&AffId=" + Server.UrlEncode(Request.QueryString["AffId"].ToString()) + "&UMsg=0", false);
}
//lblMsg.Text = "Record Updated Sucessfully";
}
else if (result == 1)
{
lblMsg.Text = "Error Occured!! Try Again";
}
else if (result == 2)
{
lblMsg.Text = "Affiliate Network Name exsists choose another name!!";
}
}
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Rupiz.Security;
using Rupiz.AffiliateNetwork;
public partial class UI_EditAffiliateView : System.Web.UI.Page
{
private BLL_AffiliateNetworkManagement affNetwork = null;
private AuthorizeAccess access = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
//lblMsg.Text = String.Empty;
//lblEditAffName.Focus();
access = new AuthorizeAccess();
affNetwork = new BLL_AffiliateNetworkManagement();
if (Request.QueryString["AffId"] != null)
{
ViewState["AffId"] = access.Decrypt(Request.QueryString["AffId"].ToString());
if (!IsPostBack)
{
GetAffDetails();
}
}
else
{
Response.Redirect(Page.ResolveUrl(String.Format("~/Admin/AffiliateNetwork/ViewAffNetworks.aspx?mid={0}&eId={1}", Server.UrlEncode(access.Encrypt("20")), Server.UrlEncode(access.Encrypt("19")))));
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
private void GetAffDetails()
{
try
{
affNetwork.AffNetId = Convert.ToInt32(ViewState["AffId"].ToString());//Convert.ToInt32(Request.QueryString["affId"]);
affNetwork.GetAffiliateById();
txtEditAffDes.Text = affNetwork.AffNetDescription;
lblEditAffName.Text = affNetwork.AffNetName;
txtEditAffUrl.Text = affNetwork.AffNetUrl;
txtEditPaymentDate.Text = affNetwork.PaymentGrace;
rbtnEditAffPaymentmode.SelectedValue = affNetwork.PaymentMode;
if (affNetwork.Status == 1)
{
rdoActive.Checked = true;
}
else if (affNetwork.Status == 0)
{
rdoInactive.Checked = true;
}
else
{
rdoDeleted.Checked = true;
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
private bool ValidateForm()
{
if ((!rdoActive.Checked) && (!rdoInactive.Checked) && (!rdoDeleted.Checked))
{
lblMsg.Text = "The affiliate network status cannot be left unselect";
return false;
}
return true;
}
protected void btnUpdateAff_Click(object sender, EventArgs e)
{
try
{
if (Page.IsValid)
{
if (ValidateForm())
{
affNetwork.AffNetId = Convert.ToInt32(ViewState["AffId"].ToString()); //Convert.ToInt32(Request.QueryString["affId"]);
affNetwork.AffNetDescription = txtEditAffDes.Text.Trim();
affNetwork.AffNetUrl = txtEditAffUrl.Text.Trim();
affNetwork.UserID = Convert.ToInt32(Session["UserId"]);
affNetwork.PaymentMode = rbtnEditAffPaymentmode.SelectedValue.Trim();
affNetwork.PaymentGrace = txtEditPaymentDate.Text.Trim();
if (rdoActive.Checked)
{
affNetwork.Status = 1; // Active
}
else if (rdoInactive.Checked)
{
affNetwork.Status = 0; // Inactive
}
else
{
affNetwork.Status = -1; // Deleted
}
int result = affNetwork.AddUpdAffiliate();
if (result == 0)
{
if (Request.QueryString["eId"] != null)
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&eId=" + Server.UrlEncode(Request.QueryString["eId"].ToString()) + "&UMsg=0", false);
}
else
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&AffId=" + Server.UrlEncode(Request.QueryString["AffId"].ToString()) + "&UMsg=0", false);
}
//lblMsg.Text = "Record Updated Sucessfully";
}
else if (result == 1)
{
lblMsg.Text = "Error Occured!! Try Again";
}
else if (result == 2)
{
lblMsg.Text = "Affiliate Network Name exsists choose another name!!";
}
}
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
}
editAffiliate.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Rupiz.Security;
using Rupiz.AffiliateNetwork;
public partial class Admin_ProductMgmt_ViewAffDetail : System.Web.UI.Page
{
private BLL_AffiliateNetworkManagement affNetwork = null;
private AuthorizeAccess access = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
lblMsg.Text = String.Empty;
access = new AuthorizeAccess();
affNetwork = new BLL_AffiliateNetworkManagement();
if (Request.QueryString["AffId"] != null)
{
ViewState["AffId"] = access.Decrypt(Request.QueryString["AffId"].ToString());
if (!IsPostBack)
{
GetAffDetails();
}
}
else
{
Response.Redirect(Page.ResolveUrl(String.Format("~/Admin/AffiliateNetwork/ViewAffNetworks.aspx?mid={0}&eId={1}", Server.UrlEncode(access.Encrypt("20")), Server.UrlEncode(access.Encrypt("19")))));
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
private void GetAffDetails()
{
try
{
affNetwork.AffNetId = Convert.ToInt32(ViewState["AffId"].ToString());//Convert.ToInt32(Request.QueryString["affId"]);
affNetwork.GetAffiliateById();
lblAffNetDesc.Text = affNetwork.AffNetDescription;
lblAffNetName.Text = affNetwork.AffNetName;
lblAffNetUrl.Text = affNetwork.AffNetUrl;
lblPaymentDate.Text = affNetwork.PaymentGrace;
lblPaymentBy.Text = affNetwork.PaymentMode;
if (affNetwork.Status == 1)
{
lblStatus.Text = "Active";
}
else if (affNetwork.Status == 0)
{
lblStatus.Text = "Inactive";
}
else
{
lblStatus.Text = "Deleted";
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
protected void btnBack_Click(object sender, EventArgs e)
{
try
{
if (Request.QueryString["eId"] != null)
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&eId=" + Server.UrlEncode(Request.QueryString["eId"].ToString()));
}
else if (Request.QueryString["vId"] != null)
{
Response.Redirect(Page.ResolveUrl("~/admin/MerchantMgmt/ViewMerchants.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&eId=" + Server.UrlEncode(Request.QueryString["vId"].ToString())), false);
}
else
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()), false);
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Rupiz.Security;
using Rupiz.AffiliateNetwork;
public partial class Admin_ProductMgmt_ViewAffDetail : System.Web.UI.Page
{
private BLL_AffiliateNetworkManagement affNetwork = null;
private AuthorizeAccess access = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
lblMsg.Text = String.Empty;
access = new AuthorizeAccess();
affNetwork = new BLL_AffiliateNetworkManagement();
if (Request.QueryString["AffId"] != null)
{
ViewState["AffId"] = access.Decrypt(Request.QueryString["AffId"].ToString());
if (!IsPostBack)
{
GetAffDetails();
}
}
else
{
Response.Redirect(Page.ResolveUrl(String.Format("~/Admin/AffiliateNetwork/ViewAffNetworks.aspx?mid={0}&eId={1}", Server.UrlEncode(access.Encrypt("20")), Server.UrlEncode(access.Encrypt("19")))));
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
private void GetAffDetails()
{
try
{
affNetwork.AffNetId = Convert.ToInt32(ViewState["AffId"].ToString());//Convert.ToInt32(Request.QueryString["affId"]);
affNetwork.GetAffiliateById();
lblAffNetDesc.Text = affNetwork.AffNetDescription;
lblAffNetName.Text = affNetwork.AffNetName;
lblAffNetUrl.Text = affNetwork.AffNetUrl;
lblPaymentDate.Text = affNetwork.PaymentGrace;
lblPaymentBy.Text = affNetwork.PaymentMode;
if (affNetwork.Status == 1)
{
lblStatus.Text = "Active";
}
else if (affNetwork.Status == 0)
{
lblStatus.Text = "Inactive";
}
else
{
lblStatus.Text = "Deleted";
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
protected void btnBack_Click(object sender, EventArgs e)
{
try
{
if (Request.QueryString["eId"] != null)
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&eId=" + Server.UrlEncode(Request.QueryString["eId"].ToString()));
}
else if (Request.QueryString["vId"] != null)
{
Response.Redirect(Page.ResolveUrl("~/admin/MerchantMgmt/ViewMerchants.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&eId=" + Server.UrlEncode(Request.QueryString["vId"].ToString())), false);
}
else
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()), false);
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
}
addAffiliate.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Drawing;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Rupiz.AffiliateNetwork;
public partial class UI_AddAffiliateNetwork : System.Web.UI.Page
{
private BLL_AffiliateNetworkManagement affNetwork = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
lblMsg.Text = String.Empty;
affNetwork = new BLL_AffiliateNetworkManagement();
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
try
{
AddAffiliate();
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
protected void btnClear_Click(object sender, EventArgs e)
{
try
{
txtAffDescription.Text = String.Empty;
txtAffNetName.Text = String.Empty;
txtAffNetUrl.Text = String.Empty;
txtPaymentDate.Text = String.Empty;
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
#region User Defined Functions
protected void AddAffiliate()
{
try
{
if (Page.IsValid)
{
affNetwork.AffNetDescription = txtAffDescription.Text.Trim();
affNetwork.AffNetName = txtAffNetName.Text.Trim();
affNetwork.AffNetUrl = txtAffNetUrl.Text.Trim();
affNetwork.UserID = Convert.ToInt32(Session["UserId"].ToString());
affNetwork.PaymentMode = rbtnlstPaymentBy.SelectedValue.Trim();
affNetwork.PaymentGrace = txtPaymentDate.Text.Trim();
int result = affNetwork.AddUpdAffiliate();
if (result == 0)
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&AMsg=1");
}
else if (result == 2)
{
lblMsg.Font.Bold = true;
lblMsg.ForeColor = Color.Red;
lblMsg.Text = "Affiliate Network Name Exsists Choose another Name!!";
}
else
{
lblMsg.Font.Bold = true;
lblMsg.ForeColor = Color.Red;
lblMsg.Text = "Error Occured!!!! Try Again..";
}
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
#endregion
protected void btnBack_Click(object sender, EventArgs e)
{
try
{
Response.Redirect("ViewAffNetworks.aspx?mid="+Server.UrlEncode(Request.QueryString["mid"].ToString()));
}
catch(Exception ex)
{
lblMsg.Text = ex.Message;
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Drawing;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Rupiz.AffiliateNetwork;
public partial class UI_AddAffiliateNetwork : System.Web.UI.Page
{
private BLL_AffiliateNetworkManagement affNetwork = null;
protected void Page_Load(object sender, EventArgs e)
{
try
{
lblMsg.Text = String.Empty;
affNetwork = new BLL_AffiliateNetworkManagement();
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
try
{
AddAffiliate();
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
protected void btnClear_Click(object sender, EventArgs e)
{
try
{
txtAffDescription.Text = String.Empty;
txtAffNetName.Text = String.Empty;
txtAffNetUrl.Text = String.Empty;
txtPaymentDate.Text = String.Empty;
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
#region User Defined Functions
protected void AddAffiliate()
{
try
{
if (Page.IsValid)
{
affNetwork.AffNetDescription = txtAffDescription.Text.Trim();
affNetwork.AffNetName = txtAffNetName.Text.Trim();
affNetwork.AffNetUrl = txtAffNetUrl.Text.Trim();
affNetwork.UserID = Convert.ToInt32(Session["UserId"].ToString());
affNetwork.PaymentMode = rbtnlstPaymentBy.SelectedValue.Trim();
affNetwork.PaymentGrace = txtPaymentDate.Text.Trim();
int result = affNetwork.AddUpdAffiliate();
if (result == 0)
{
Response.Redirect("ViewAffNetworks.aspx?mid=" + Server.UrlEncode(Request.QueryString["mid"].ToString()) + "&AMsg=1");
}
else if (result == 2)
{
lblMsg.Font.Bold = true;
lblMsg.ForeColor = Color.Red;
lblMsg.Text = "Affiliate Network Name Exsists Choose another Name!!";
}
else
{
lblMsg.Font.Bold = true;
lblMsg.ForeColor = Color.Red;
lblMsg.Text = "Error Occured!!!! Try Again..";
}
}
}
catch (Exception ex)
{
lblMsg.Text = ex.Message;
}
}
#endregion
protected void btnBack_Click(object sender, EventArgs e)
{
try
{
Response.Redirect("ViewAffNetworks.aspx?mid="+Server.UrlEncode(Request.QueryString["mid"].ToString()));
}
catch(Exception ex)
{
lblMsg.Text = ex.Message;
}
}
}
Thursday, January 21, 2010
Subscribe to:
Posts (Atom)