You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

572 lines
26 KiB

using Swift.API.Common.Helper;
using Swift.DAL.OnlineAgent;
using Swift.DAL.SwiftDAL;
using Swift.web.Library;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI.WebControls;
namespace Swift.web.MobileRemit.Admin.Operation
{
public partial class ManageActivate : System.Web.UI.Page
{
private readonly RemittanceLibrary _sl = new RemittanceLibrary();
private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
private readonly StaticDataDdl _sdd = new StaticDataDdl();
private const string ViewFunctionId = "30110000";
private const string ApproveFunctionId = "30110010";
private bool isEdit = Convert.ToBoolean(GetStatic.ReadQueryString("edit", "false"));
protected void Page_Load(object sender, EventArgs e)
{
Authenticate();
//displayOnlyOnEdit.Visible = CheckAddOrEdit();
addEditPanel.Attributes.Add("style", "display:none");
GetStatic.PrintMessage(Page);
if (GetStatic.ReadQueryString("hdnId", "").ToString() != "")
{
ShowPrintLink(GetStatic.ReadQueryString("hdnId", "").ToString());
}
else
{
linkDiv.Visible = false;
}
var MethodName = Request.Form["MethodName"];
if (!IsPostBack)
{
//if (GetStatic.ReadQueryString("customerId", "") != "" || GetStatic.ReadQueryString("edit", "") == "true")
// divUploadImage.Visible = false;
//else
// divUploadImage.Visible = true;
PopulateDdl();
GetCustomerDocument();
if (MethodName == "GetAddressDetailsByZipCode")
{
GetAddressDetailsByZipCode();
}
if (MethodName == "GetCustomerDetails")
{
GetCustomerDetails();
}
if (IsCallFromList().ToLower() == "true")
{
if (GetStatic.ReadQueryString("customerId", "") != "")
{
GetStatic.CallJSFunction(this, "CallFromListPage('" + GetStatic.ReadQueryString("customerId", "") + "')");
}
}
}
}
private string IsCallFromList()
{
return GetStatic.ReadQueryString("isCallFromList", "False");
}
public void ShowPrintLink(string membershipId)
{
//linkDiv.Visible = true;
printLink.Attributes["href"] = "PrintDetails.aspx?membershipId=" + membershipId;
printLink.InnerText = "Print Details of " + membershipId + "";
}
private void Authenticate()
{
_sl.CheckAuthentication(ViewFunctionId);
//if (CheckAddOrEdit())
// _sl.CheckAuthentication(EditViewFunctionId);
//else
// _sl.CheckAuthentication(AddViewFunctionId);
string eId = GetStatic.ReadQueryString("customerId", "");
var hasRight = true;
if (eId == "")
{
hasRight = _sl.HasRight(ApproveFunctionId);
register.Enabled = hasRight;
register.Visible = hasRight;
}
else
{
hasRight = _sl.HasRight(ApproveFunctionId);
register.Enabled = hasRight;
register.Visible = hasRight;
}
}
//private bool CheckAddOrEdit()
//{
// if (isEdit)
// {
// customerType.Attributes.Add("hidden", "hidden");
// }
// else
// {
// customerType.Attributes.Remove("hidden");
// }
// return isEdit;
//}
private void PopulateForm(string eId)
{
var dr = _cd.GetCustomerDetails(eId, GetStatic.GetUser());
if (null != dr)
{
hdnCustomerId.Value = dr["customerId"].ToString();
firstName.Text = dr["firstName"].ToString();
middleName.Text = dr["middleName"].ToString();
lastName.Text = dr["lastName1"].ToString();
txtCompanyName.Text = dr["firstName"].ToString();
genderList.SelectedValue = dr["gender"].ToString();
countryList.SelectedValue = dr["country"].ToString();
addressLine1.Text = dr["address"].ToString();
zipCode.Text = dr["zipCode"].ToString();
city.Text = dr["city"].ToString();
email.Text = dr["email"].ToString();
hddOldEmailValue.Value = dr["email"].ToString();
emailConfirm.Text = dr["email"].ToString();
phoneNumber.Text = dr["telNo"].ToString();
mobile.Text = dr["mobile"].ToString();
nativeCountry.SelectedItem.Text = dr["nativeCountry"].ToString();
nativeCountry.SelectedItem.Value = dr["nativeCountryId"].ToString();
dob.Text = dr["dob"].ToString();
occupation.Text = dr["occupation"].ToString();
IssueDate.Text = dr["idIssueDate"].ToString();
ExpireDate.Text = dr["idExpiryDate"].ToString();
idType.SelectedValue = dr["idType"].ToString();
verificationTypeNo.Text = dr["idNumber"].ToString();
hddIdNumber.Value = dr["homePhone"].ToString();
txtMembershipId.Text = dr["membershipId"].ToString();
hdnMembershipNo.Value = dr["membershipId"].ToString();
txtMembershipId.Attributes.Add("readonly", "readonly");
txtRegistrationNo.Text = dr["registerationNo"].ToString();
txtAdditionalAddress.Text = dr["additionalAddress"].ToString();
txtDateOfIncorporation.Text = dr["dateofIncorporation"].ToString();
txtNameofAuthoPerson.Text = dr["nameOfAuthorizedPerson"].ToString();
txtStreet.Text = dr["street"].ToString();
txtsenderCityjapan.Text = dr["cityUnicode"].ToString();
txtstreetJapanese.Text = dr["streetUnicode"].ToString();
txtNameofEmployeer.Text = dr["nameOfEmployeer"].ToString();
rbRemitanceAllowed.SelectedValue = (dr["remittanceAllowed"].ToString().ToLower() == "true" ? "Enabled" : "Disabled");
rbOnlineLogin.SelectedValue = (dr["onlineUser"].ToString() == "Y" ? "Enabled" : "Disabled");
rbMobileLogin.SelectedValue = (dr["mobileUser"].ToString() == "Y" ? "Enabled" : "Disabled");
txtRemarks.Text = dr["remarks"].ToString();
txtSSnNo.Text = dr["SSNNO"].ToString();
ddlSalary.Text = dr["monthlyIncome"].ToString();
ddlDocType.SelectedValue = dr["documentType"].ToString();
//if (!string.IsNullOrEmpty(dr["customerType"].ToString()) && !string.IsNullOrWhiteSpace(dr["customerType"].ToString()))
//{
// ddlCustomerType.SelectedValue = dr["customerType"].ToString();
//}
if (!string.IsNullOrEmpty(dr["employeeBusinessType"].ToString()) && !string.IsNullOrWhiteSpace(dr["employeeBusinessType"].ToString()))
{
ddlEmployeeBusType.SelectedValue = dr["employeeBusinessType"].ToString();
}
if (!string.IsNullOrEmpty(dr["natureOfCompany"].ToString()) && !string.IsNullOrWhiteSpace(dr["natureOfCompany"].ToString()))
{
ddlnatureOfCompany.SelectedValue = dr["natureOfCompany"].ToString();
}
if (!string.IsNullOrEmpty(dr["organizationType"].ToString()) && !string.IsNullOrWhiteSpace(dr["organizationType"].ToString()))
{
ddlOrganizationType.SelectedValue = dr["organizationType"].ToString();
}
ddlPosition.SelectedValue = dr["position"].ToString();
ddlVisaStatus.SelectedValue = dr["visaStatus"].ToString();
ddSourceOfFound.SelectedValue = dr["sourceOfFund"].ToString();
setStateDll(countryList.SelectedValue, zipCode.Text, dr["state"].ToString());
email.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true;
emailConfirm.Enabled = (dr["isTxnMade"].ToString() == "Y") ? false : true;
hddTxnsMade.Value = dr["isTxnMade"].ToString();
if (dr["isTxnMade"].ToString() == "Y")
{
msgDiv.Visible = true;
msgLabel.Text = "Note: The customer has already made transactions in JME system, so the email can not be modified. For more info please contact HO.";
}
if (dr["idType"].ToString() == "8008")
{
expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4 hidden");
}
else
{
expiryDiv.Attributes.Remove("class");
expiryDiv.Attributes.Add("class", "col-md-4 col-sm-4");
}
membershipDiv.Visible = true;
}
}
private void PopulateDdl()
{
_sl.SetDDL(ref genderList, "EXEC proc_online_dropDownList @flag='GenderList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
_sl.SetDDL(ref countryList, "EXEC proc_online_dropDownList @flag='onlineCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "");
_sl.SetDDL(ref nativeCountry, "EXEC proc_online_dropDownList @flag='allCountrylist',@user='" + GetStatic.GetUser() + "'", "countryId", "countryName", "", "Select..");
_sl.SetDDL(ref occupation, "EXEC proc_online_dropDownList @flag='occupationList',@user='" + GetStatic.GetUser() + "'", "valueId", "detailTitle", "", "Select..");
_sl.SetDDL(ref idType, "EXEC proc_online_dropDownList @flag='IdTypeWithDetails',@user='" + GetStatic.GetUser() + "',@countryId='" + countryList.SelectedValue + "'", "valueId", "detailTitle", "", "Select..");
//_sl.SetDDL(ref ddlCustomerType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=4700", "valueId", "detailTitle", ddlCustomerType.SelectedValue, "");
_sl.SetDDL(ref ddlOrganizationType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7002", "valueId", "detailTitle", "", "Select..");
_sl.SetDDL(ref ddlnatureOfCompany, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7003", "valueId", "detailTitle", "", "Select..");
_sl.SetDDL(ref ddSourceOfFound, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=3900", "valueId", "detailTitle", "", "Select..");
_sl.SetDDL(ref ddlEmployeeBusType, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7004", "valueId", "detailTitle", "", "");
_sl.SetDDL(ref ddlVisaStatus, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7005", "valueId", "detailTitle", "", "Select..");
_sl.SetDDL(ref ddlPosition, "EXEC proc_online_dropDownList @flag='dropdownList',@user='" + GetStatic.GetUser() + "',@parentId=7006", "valueId", "detailTitle", "", "Select..");
_sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", "", "Select..");
_sdd.SetDDL(ref ddlSearchBy, "exec proc_sendPageLoadData @flag='search-cust-by'", "VALUE", "TEXT", "", "");
_sdd.SetStaticDdl(ref ddlDocType, "7009", "", "Select");
}
protected void register_Click(object sender, EventArgs e)
{
string cId = hdnCustomerId.Value;
string crFrom = hdnCreatedFrom.Value;
string verifyType = GetStatic.ReadQueryString("type", "");
//if (!_sl.HasRight(GetFunctionIdByUserType(SaveEditIdFromAgent, SaveEditIdFromMobile)))
//{
// GetStatic.AlertMessage(this, "You are not authorized to Edit Customer!");
// return;
//}
if (!email.Text.IsValidEmail())
{
GetStatic.AlertMessage(this, "Invalid Email format of customer! Unable to proceed for activation.");
return;
}
//if (hddTxnsMade.Value == "Y" && (!email.Text.Equals(hddOldEmailValue.Value.ToString())))
//{
// GetStatic.AlertMessage(this, "You can not change the email of customer who have already done transaction!");
// return;
//}
//if (_sl.HasRight(SignatureFunctionId) && !isEdit && (string.IsNullOrEmpty(customerPassword.Text) || string.IsNullOrWhiteSpace(customerPassword.Text)) && (string.IsNullOrEmpty(hddImgURL.Value) || string.IsNullOrWhiteSpace(hddImgURL.Value)))
//{
// GetStatic.AlertMessage(this, "Customer signature or customer password is required!");
// return;
//}
string a = Request.Form["txtStreet"];
string trimmedfirstName = firstName.Text.Trim() == "" ? null : firstName.Text.Trim();
string trimmedMiddleName = middleName.Text.Trim() == "" ? null : middleName.Text.Trim();
string trimmedlastName = lastName.Text.Trim() == "" ? null : lastName.Text.Trim();
string occupationVal = occupationHidden.Value;
OnlineCustomerModel customerModel = new OnlineCustomerModel()
{
flag = "customer-register-core",
firstName = trimmedfirstName,
middleName = trimmedMiddleName,
lastName1 = trimmedlastName,
gender = genderList.SelectedValue,
customerType = "4700",
country = countryList.Text,
address = addressLine1.Text,
zipCode = zipCode.Text,
street = Request.Form["txtStreet"],
AdditionalAddress = txtAdditionalAddress.Text,
city = cityHidden.Value,
state = ddlStateHidden.Value,
senderCityjapan = txtsenderCityjapan.Text,
email = email.Text,
streetJapanese = txtstreetJapanese.Text,
homePhone = phoneNumber.Text,
mobile = mobile.Text,
visaStatus = ddlVisaStatus.SelectedValue,
employeeBusinessType = ddlEmployeeBusType.SelectedValue,
nativeCountry = nativeCountry.SelectedValue,
dob = dob.Text,
occupation = occupation.Text,
telNo = phoneNumber.Text,
ipAddress = GetStatic.GetIp(),
createdBy = GetStatic.GetUser(),
idNumber = verificationTypeNo.Text,
idIssueDate = IssueDate.Text,
idExpiryDate = ExpireDate.Text,
idType = idType.Text.Split('|')[0].ToString(),
membershipId = txtMembershipId.Text,
remitanceAllowed = (rbRemitanceAllowed.SelectedValue == "Enabled" ? true : false),
onlineUser = (rbOnlineLogin.SelectedValue == "Enabled" ? true : false),
// mobileUser = (rbMobileLogin.SelectedValue == "Enabled" ? true : false),
remarks = txtRemarks.Text,
registrationNo = txtRegistrationNo.Text,
natureOfCompany = ddlnatureOfCompany.Text,
organizationType = ddlOrganizationType.SelectedValue,
dateOfIncorporation = txtDateOfIncorporation.Text,
position = ddlPosition.SelectedValue,
nameofAuthoPerson = txtNameofAuthoPerson.Text,
nameofEmployeer = txtNameofEmployeer.Text,
companyName = txtCompanyName.Text,
MonthlyIncome = ddlSalary.Text,
IsCounterVisited = customerCounterVisit.Checked ? "Y" : "N",
customerPassword = customerPassword.Text,
agentId = GetStatic.GetAgent().ToInt(),
DocumentType = ddlDocType.SelectedValue,
occupationOther = occupationText.Text,
otherIdNumber = otherVerificationTypeNo.Text,
ReferralId = referraltxt.Text
};
if (hdnCustomerId.Value != "")
{
customerModel.customerId = hdnCustomerId.Value;
customerModel.flag = "customer-editeddata";
}
//else
//{
// var custom = PasswordGenerator.GenerateRandomPassword();
// customerModel.password = custom;
//}
var dbResult = _cd.RegisterCustomerNewAgent(customerModel);
if (dbResult.ErrorCode == "1")
{
GetStatic.AlertMessage(this.Page, dbResult.Msg);
}
if (dbResult.ErrorCode == "0")
{
saveCustomerDocument(dbResult);
string Id = hdnCustomerId.Value;
string createdFrom = hdnCreatedFrom.Value;
string referral = referraltxt.Text;
string memberId = "";
if (dbResult.Msg.Split(':').Length > 1)
{
memberId = dbResult.Msg.Split(':')[1].Trim();
}
var custompass = PasswordGenerator.GenerateRandomPassword();
var dbRes = _cd.ActivateMobileLogin(GetStatic.GetUser(), Id, custompass, referral, Request.Form["membershipId"]);
GetStatic.AlertMessage(this, dbRes.Msg);
if (dbRes.ErrorCode == "0")
{
Response.Redirect("/MobileRemit/Admin/Operation/LetterForCustomerFromMobile.aspx?createdFrom=" + createdFrom + "&customerId=" + Id + "&membershipId=" + Request.Form["membershipId"] + "");
}
// Approve(sender, e, createdFrom, "approve");
}
else
GetStatic.SetMessage(dbResult.ErrorCode, dbResult.Msg);
//Page_Load(sender, e);
//return;
}
protected string GetReferalId()
{
return GetStatic.ReadQueryString("code", "");
}
public string GetFunctionIdByUserType(string functionIdAgent, string functionIdAdmin)
{
return (GetStatic.GetUserType() == "HO") ? functionIdAdmin : functionIdAgent;
}
private void saveCustomerDocument(DbResult dbresult)
{
var result = dbresult.Id.Split('|');
var customerId = result[0];
var membershipId = result[1];
var registerDate = result[2];
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.AllKeys.Length; i++)
{
HttpPostedFile file = fileCollection[i];
if (file != null)
{
string documentTypeName = "";
string documentType = "";
string fileType = "";
var keyName = fileCollection.AllKeys[i];
if (keyName.ToLower().Equals("reg_front_id"))
{
documentTypeName = "ID_Front";
documentType = "11394";//11386
}
if (keyName.ToLower().Equals("reg_back_id"))
{
documentTypeName = "ID_Back";
documentType = "11395";//"11387";
}
if (keyName.ToLower().Equals("add_id_front"))
{
documentTypeName = "Additional_ID_Front";
documentType = "11396";// "11389";
}
if (keyName.ToLower().Equals("add_id_back"))
{
documentTypeName = "Additional_ID_Back";
documentType = "11397";// "11395";
}
if (keyName.ToLower().Equals("other_document"))
{
documentTypeName = "Other_Document";
documentType = "11398";// "11390";
}
if (keyName.ToLower().Equals("reg_form"))
{
documentTypeName = "Registration_Form";
documentType = "11399";// "11393";
}
string fileName = (!string.IsNullOrWhiteSpace(file.FileName) ? GetStatic.UploadDocument(file, customerId, documentTypeName, membershipId, registerDate, out fileType) : GetStatic.UploadDocument(file, customerId, documentType, membershipId, registerDate, out fileType));
CustomerDocument cm = new CustomerDocument();
if (!string.IsNullOrEmpty(fileName) && fileName.ToLower() != "notvalid")
_cd.UpdateCustomerDocument("", customerId, fileName, documentTypeName, fileType, documentType, GetStatic.GetUser());
}
}
}
public int UploadSignatureImage(string imageData, string registerDate, string membershipId, string customerId)
{
int errorCode = 0;
try
{
string path = GetStatic.ReadWebConfig("customerDocPath", "") + "CustomerDocument\\" + registerDate.Replace("-", "\\") + "\\" + membershipId;
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
string fileName = path + "\\" + customerId + "_signature" + ".png";
using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
using (BinaryWriter bw = new BinaryWriter(fs))
{
byte[] data = Convert.FromBase64String(imageData);
bw.Write(data);
bw.Close();
}
}
}
catch (Exception)
{
errorCode = 1;
}
return errorCode;
}
public class CustomerAddress
{
public string errrorCode { get; set; }
public string msg { get; set; }
public string State { get; set; }
public string City { get; set; }
public string Street { get; set; }
}
private void GetAddressDetailsByZipCode()
{
addEditPanel.Visible = true;
string customerId = Request.Form["customerId"];
string zipCode = Request.Form["zipCode"];
string rowID = Request.Form["RowID"];
string action = Request.Form["action"];
var dr = _cd.GetAddressByZipCodeAdmin(zipCode, GetStatic.GetUser(), rowID, customerId, action);
var json = GetStatic.DataTableToJson(dr);
GetStatic.JsonResponse(json, this);
}
private void GetCustomerDetails()
{
addEditPanel.Visible = true;
string eId = Request.Form["Id"];
var dt = _cd.GetDetailsForEditCustomer(eId, GetStatic.GetUser());
Response.ContentType = "text/plain";
var json = DataTableToJson(dt);
Response.Write(json);
Response.End();
}
public static string DataTableToJson(DataTable table)
{
if (table == null)
return "";
var list = new List<Dictionary<string, object>>();
foreach (DataRow row in table.Rows)
{
var dict = new Dictionary<string, object>();
foreach (DataColumn col in table.Columns)
{
dict[col.ColumnName] = string.IsNullOrEmpty(row[col].ToString()) ? "" : row[col];
}
list.Add(dict);
}
var serializer = new JavaScriptSerializer();
string json = serializer.Serialize(list);
return json;
}
private void setStateDll(string countryId, string zipCode, string stateId)
{
if (countryId != "")
{
_sl.SetDDL(ref ddlState, "EXEC proc_online_dropDownList @flag='state',@countryId='" + countryList.SelectedValue + "'", "stateId", "stateName", stateId, "Select..");
}
}
protected void clickBtnForGetCustomerDetails_Click(object sender, EventArgs e)
{
string eId = hdnCustomerId.Value;
if (eId != "")
{
PopulateForm(eId);
}
}
protected string GetCustomerId()
{
return GetStatic.ReadQueryString("customerId", "");
}
private void GetCustomerDocument()
{
string eId = hdnCustomerId.Value;
var dt = _cd.GetDocumentForEditCustomerActivate(eId, GetStatic.GetUser());
if (dt != null)
{
var str = new StringBuilder("");
var sn = 1;
foreach (DataRow dr in dt.Rows)
{
str.Append("<tr>");
str.Append("<td>" + sn + "</td>");
str.Append("<td>" + dr["documentType"].ToString() + "</td>");
str.Append("<td>" + dr["fileType"].ToString() + "</td>");
str.Append("<td>" + dr["fileName"].ToString() + "</td>");
str.Append("<td>" + dr["uploadedDate"].ToString() + "</td>");
str.Append("</tr>");
sn++;
}
docdetails.InnerHtml = str.ToString();
}
}
}
}