You are on page 1of 5

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 System.Text.RegularExpressions;
using rcw.PMIContactObjects;
using System.Reflection;

public partial class CompanyBillingInfo : System.Web.UI.Page,


System.Web.UI.ICallbackEventHandler
{
private const int CSUSERKEY = 0;
public clsCommon objclsCommon = null;
public String strBrandPath = String.Empty;
private String strCBResult = String.Empty;
protected GetUser objGetUser;
public String strComName = String.Empty;
public int intTotalCCRecords = 0;
public String StrSeparator1 = "#@~;";
public String StrSeparator2 = "#@@~;";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsCallback)
{
int intCompanyKey = 0;
string strUserKeyFromQueryString = String.Empty;
string strHashKeyFromQueryString = String.Empty;
if (Request.QueryString["u"] != "" && Request.QueryString["h"] != "" &&
Request.QueryString["u"]!=null)
{
strUserKeyFromQueryString =
Convert.ToString(Request.QueryString["u"]);
strHashKeyFromQueryString =
Convert.ToString(Request.QueryString["h"]).ToUpper();
Session["Billing_CompanyKey"] =
Convert.ToInt32(Request.QueryString["lstCompany"]);
UCMHashKeyValidation csHashKeyValidation = new
UCMHashKeyValidation();

csHashKeyValidation.CreateHashPreviousKey(csHashKeyValidation.GENERICHash,
strUserKeyFromQueryString);
if ((csHashKeyValidation.hash.ToUpper() !=
strHashKeyFromQueryString) && (csHashKeyValidation.hashprev.ToUpper() !=
strHashKeyFromQueryString))
{
Response.Write("UnAuthorized Access");
Response.End();
}
Session["UserKey"] = strUserKeyFromQueryString;
objGetUser = new GetUser();
}
else
{
if (Convert.ToString(Session["UserKey"]) != "")
{
objGetUser = new GetUser();
}
else
{
Response.Write("UnAuthorized Access");
Response.End();
}
}
//----------------------- These code is for call back functionality
-----------------------//
string cbReference = Page.ClientScript.GetCallbackEventReference(this,
"arg", "getServerOutput", "context");
string cbScript = "function useCallback(arg,context)" + "{" +
cbReference + ";" + "}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"useCallback", cbScript, true);
//---------------------------------------------------------------------
--------------------
strBrandPath = Session["ASPX_UserBrandPath"].ToString();
csslink.Href = strBrandPath + Session["ASPX_CSSName"].ToString();
//---------------------------------------------------------------------
-------------------------
pmiUserAddressColl objUserAddColl = null;
Type objTypeAddColl = typeof(pmiUserAddressColl);
pmiCollection CCColl = null;
pmiCompany objCompany = null;
Type objTypeCom = typeof(pmiCompany);
try
{
objUserAddColl =new pmiUserAddressColl();
objclsCommon = new clsCommon();
CCColl =new pmiCollection();
objCompany =new pmiCompany();
objTypeCom.InvokeMember("GetCompanyBasicsOnly",
BindingFlags.InvokeMethod, null, objCompany, new object[]
{ Convert.ToString(Session["Billing_CompanyKey"]) });
intCompanyKey = Convert.ToInt32(Session["Billing_CompanyKey"]);
objCompany.GetCardInfo(ref intCompanyKey);
CCColl = objCompany.CCCollection;
intTotalCCRecords = CCColl.Count;
CreditCardDetails.setCCCollection = CCColl;
CreditCardDetails.BrandPath = strBrandPath;
CreditCardDetails.DisplayModeCompany = true;
objCompany.GetCompanyBillingInfo(ref intCompanyKey);
strComName = objCompany.CompanyName;
if(!Page.IsPostBack)
{ txtEmail.Text
=Convert.ToString(objCompany.BillingEmailAddress).Trim();}
else if(Page.IsPostBack)
{txtEmail.Text =Convert.ToString(txtEmail.Text).Trim();}
}
catch (Exception ex) { Response.Write("Unexpected error."); }
finally
{
if (objUserAddColl != null)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objUserAddColl);
if (objCompany != null)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objCompany);
}
}
Response.CacheControl= "no-cache";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
}

public void RaiseCallbackEvent(string eventArg)


{
string[] argList;
string EventDescription = "";
int AdminUserKey = Convert.ToInt32(Session["UserKey"]);
int intCSRKey = CSUSERKEY;
argList = Regex.Split(eventArg, StrSeparator1);

if (argList[0] == "SAVEEMAILADDRESS")
{
String strSendInvoice = String.Empty;
int intCompanyKey = 0;
String[] arrInvoiceDetails = Regex.Split(argList[1], StrSeparator2);
strSendInvoice = arrInvoiceDetails[1];
intCompanyKey = Convert.ToInt32(Session["Billing_CompanyKey"]);
pmiCompany objCompany = null;
try
{
objCompany =new pmiCompany();
Type objTypeComp=typeof(pmiCompany);
objCompany.GetCardInfo(ref intCompanyKey);
objCompany.GetCompanyBillingInfo(ref intCompanyKey);
EventDescription = "Company billing email address modified from " +
objCompany.BillingEmailAddress + " to " + strSendInvoice;
objCompany.BillingEmailAddress = strSendInvoice;
objCompany.UpdateCompanyBillingInfo();
objCompany.AddAuditTrail(ref intCSRKey,ref EventDescription, ref
intCompanyKey,ref AdminUserKey );
}
catch (Exception ex) { strCBResult = "SAVEEMAILADDRESS" + StrSeparator1
+ "Error"; }
finally
{
if (objCompany != null)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objCompany);
if (strCBResult == "")
{
strCBResult = "SAVEEMAILADDRESS" + StrSeparator1 + "Success";
}
}

}
else if (argList[0] == "UPDATEPRIORITY")
{
String[] arrTemp;
String strAllPriorities = String.Empty;
String strAllCCIds = String.Empty;
PmiCreditCard objCC = null;
Type objTypeCreditCard = typeof(PmiCreditCard);
strCBResult = String.Empty;
for (int intIndexOfPrirityDetails = 1; intIndexOfPrirityDetails <
argList.Length; intIndexOfPrirityDetails++)
{
arrTemp = Regex.Split(argList[intIndexOfPrirityDetails],
StrSeparator2);
if (intIndexOfPrirityDetails == 1) { strAllCCIds = arrTemp[0];
strAllPriorities = arrTemp[1]; }
else
{
strAllCCIds = strAllCCIds + "," + arrTemp[0];
strAllPriorities = strAllPriorities + "," + arrTemp[1];
}
}
try
{
objCC =new PmiCreditCard();
objCC.AdminUserKey = AdminUserKey;
objTypeCreditCard.InvokeMember("UpdateCCPriority",
BindingFlags.InvokeMethod, null, objCC, new object[] { strAllCCIds,
strAllPriorities, Type.Missing, Session["Billing_CompanyKey"], Type.Missing });
}
catch (Exception ex)
{
strCBResult = "UPDATEPRIORITY" + StrSeparator1 + "Error";
}
finally
{
if (objCC != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objCC);
if (strCBResult == "")
{
strCBResult = "UPDATEPRIORITY" + StrSeparator1 + "Success";
}
}
}
else if (argList[0] == "DELETECARD")
{
PmiCreditCard objCC = null;
String strCardId = String.Empty;
strCBResult = String.Empty;
strCardId = argList[1];
Type objTypeCreditCard = typeof(PmiCreditCard);
try
{
objCC =new PmiCreditCard();
objCC.AdminUserKey = AdminUserKey;
objTypeCreditCard.InvokeMember("DeleteCard",
BindingFlags.InvokeMethod, null, objCC, new object[] { strCardId });
}
catch (Exception ex)
{
strCBResult = "DELETECARD" + StrSeparator1 + "Error";
}
finally
{
if (objCC != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(objCC);
if (strCBResult == "")
{ strCBResult = "DELETECARD" + StrSeparator1 + "Success"; }
}
}
}
public string GetCallbackResult()
{
return strCBResult;
}
}

You might also like