14.1.10

Login BOL ,BLL, DAL with application block

1.)BOL

using System;


namespace Customer.Login
{
public class LoggedInUser
{
String _Regi_PK, _ITR_PK;
String _User_Name;
String _PrefferredName;
String _EmailAddress;
String _Address, _SSN;
Boolean _IsJointStatement,_HaveDependents,_IsLocked;
Int16 _Step ;
String _Year;
Int32 _NewMessages;


public String Regi_PK
{
get { return _Regi_PK; }
set { _Regi_PK = value; }
}
public String ITR_PK
{
get { return _ITR_PK; }
set { _ITR_PK = value; }
}
public String User_Name
{
get { return _User_Name; }
set { _User_Name = value; }
}
public String PrefferredName
{
get { return _PrefferredName; }
set { _PrefferredName = value; }
}
public String EmailAddress
{
get { return _EmailAddress; }
set { _EmailAddress = value; }
}
public String Address
{
get { return _Address; }
set { _Address = value; }
}

public String SSN
{
get { return _SSN; }
set { _SSN = value; }
}

public String Year
{
get { return _Year; }
set { _Year = value; }
}



public Boolean IsJointStatement
{
get { return _IsJointStatement; }
set { _IsJointStatement = value; }
}

public Boolean HaveDependents
{
get { return _HaveDependents; }
set { _HaveDependents = value; }
}
public Boolean IsLocked
{
get { return _IsLocked; }
set { _IsLocked = value; }
}


public Int16 Step
{
get { return _Step; }
set { _Step = value; }
}

public Int32 NewMessages
{
get { return _NewMessages; }
set { _NewMessages = value; }
}

public LoggedInUser(String Regi_PK, String ITR_PK, String User_Name, String EmailAddress, String Address, String PreferredName)
{
this.Regi_PK = Regi_PK;
this.ITR_PK = ITR_PK;
this.User_Name = User_Name;
this.PrefferredName = PreferredName;
this.EmailAddress = EmailAddress;
this.Address = Address;
this.SSN = "";
this.NewMessages = 0;
this.Step = 0;
this.Year = "All";

}
public LoggedInUser(String Regi_PK, String ITR_PK, String User_Name, String EmailAddress, String Address, String SSN, String PreferredName,Int32 NewMessages)
{
this.Regi_PK = Regi_PK;
this.ITR_PK = ITR_PK;
this.User_Name = User_Name;
this.PrefferredName = PreferredName;
this.EmailAddress = EmailAddress;
this.Address = Address;
this.SSN = SSN;
this.NewMessages = NewMessages;
this.Step = 0;
this.Year = "All";
}


}


}

2.)BLL

using System;
using System.Collections.Generic;

namespace Customer.Login
{
public class LoginBOL : LoginDAL
{
String _LoginMessage;
public String LoginMessage
{
get { return _LoginMessage; }
set { _LoginMessage = value; }
}

public LoggedInUser UpdatePassword(String Regi_PK, String Email, String Pwd, String NewPwd)
{
String Message = "";
String Regi_Id = "";
String FullName = "";
String Address = "";
String ITR_PK = "";
String PreferredName="";

base.UpdatePassword(Regi_PK, Email, Pwd, NewPwd, out Message, out Regi_Id, out ITR_PK, out FullName, out Address, out PreferredName);
this.LoginMessage = Message;
return new LoggedInUser(Regi_Id, ITR_PK, FullName, Email, Address, PreferredName);

}
public LoggedInUser ValidateUser(String Email, String Pwd)
{
String Message = "";
String Regi_Id = "";
String FullName = "";
String Address = "";
String SSN = "";
String ITR_PK = "";
String PreferredName = "";
Int32 NewEmails = 0;
base.ValidateUser(Email, Pwd, out Message, out Regi_Id, out FullName, out Address, out SSN, out PreferredName, out NewEmails);
this.LoginMessage = Message;
return new LoggedInUser(Regi_Id, ITR_PK, FullName, Email, Address, SSN, PreferredName, NewEmails);

}

public void ChangePassword(String Regi_PK, String Email, String Pwd, String NewPwd)
{
String Message = "";
base.ChangePassword(Regi_PK, Email, Pwd, NewPwd, out Message);
this.LoginMessage = Message;

}

public LoggedInUser ForgotPassword(String Email)
{
String Message = "";
String Regi_Id = "";
String ITR_PK = "";
String FullName = "";
String Password = "";
String SSN = "";
String PreferredName = "";
base.ForgotPassword(Email, out Message, out Regi_Id, out FullName, out Password, out PreferredName);

this.LoginMessage = Message;
return new LoggedInUser(Regi_Id, ITR_PK,FullName, Email, Password, PreferredName);

}


}
}

3.)DAL

using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace Customer.Login
{
public class LoginDAL : AppConfig
{
protected void UpdatePassword(String Regi_PK, String Email, String Pwd, String NewPwd, out String Message, out String Regi_Id, out String ITR_PK, out String FullName, out String Address, out String PreferredName)
{
SqlParameter[] Param;
Param = new SqlParameter[11];
Param[0] = new SqlParameter("@Flag", SqlDbType.SmallInt);
Param[0].Value = 1;
Param[1] = new SqlParameter("@Regi_PK", SqlDbType.NVarChar);
Param[1].Value = Regi_PK;
Param[2] = new SqlParameter("@UserName", SqlDbType.NVarChar);
Param[2].Value = Email;
Param[3] = new SqlParameter("@Password", SqlDbType.NVarChar);
Param[3].Value = Pwd;
Param[4] = new SqlParameter("@NewPassword", SqlDbType.NVarChar);
Param[4].Value = NewPwd;
Param[5] = new SqlParameter("@ITR_PK", SqlDbType.NVarChar, 36);
Param[5].Direction = ParameterDirection.Output;
Param[6] = new SqlParameter("@Regi_Id", SqlDbType.NVarChar, 36);
Param[6].Direction = ParameterDirection.Output;
Param[7] = new SqlParameter("@fullName", SqlDbType.NVarChar, 500);
Param[7].Direction = ParameterDirection.Output;
Param[8] = new SqlParameter("@Address", SqlDbType.NVarChar, 500);
Param[8].Direction = ParameterDirection.Output;
Param[9] = new SqlParameter("@msgout", SqlDbType.NVarChar, 100);
Param[9].Direction = ParameterDirection.Output;
Param[10] = new SqlParameter("@preferred", SqlDbType.NVarChar, 200);
Param[10].Direction = ParameterDirection.Output;

SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, "usp_Customer_ValidateUser", Param);
Message = Param[9].Value.ToString();
if (Message == "OK")
{
ITR_PK = Param[5].Value.ToString();
Regi_Id = Param[6].Value.ToString();
FullName = Param[7].Value.ToString();
Address = Param[8].Value.ToString();
PreferredName = Param[10].Value.ToString();
}
else
{
ITR_PK = String.Empty;
Regi_Id = String.Empty;
FullName = String.Empty;
Address = String.Empty;
PreferredName = String.Empty;

}

}
protected void ValidateUser(String Email, String Pwd, out String Message, out String Regi_Id, out String FullName, out String Address, out String SSN, out String PreferredName, out Int32 NewMessages)
{
SqlParameter[] Param;
Param = new SqlParameter[12];
Param[0] = new SqlParameter("@Flag", SqlDbType.SmallInt);
Param[0].Value = 4;
Param[1] = new SqlParameter("@Regi_PK", SqlDbType.NVarChar);
Param[1].Value = String.Empty;
Param[2] = new SqlParameter("@UserName", SqlDbType.NVarChar);
Param[2].Value = Email;
Param[3] = new SqlParameter("@Password", SqlDbType.NVarChar);
Param[3].Value = Pwd;
Param[4] = new SqlParameter("@NewPassword", SqlDbType.NVarChar);
Param[4].Value = String.Empty;
Param[5] = new SqlParameter("@Regi_Id", SqlDbType.NVarChar, 36);
Param[5].Direction = ParameterDirection.Output;
Param[6] = new SqlParameter("@fullName", SqlDbType.NVarChar, 500);
Param[6].Direction = ParameterDirection.Output;
Param[7] = new SqlParameter("@Address", SqlDbType.NVarChar, 500);
Param[7].Direction = ParameterDirection.Output;
Param[8] = new SqlParameter("@msgout", SqlDbType.NVarChar, 100);
Param[8].Direction = ParameterDirection.Output;

Param[9] = new SqlParameter("@SSN", SqlDbType.NVarChar, 100);
Param[9].Direction = ParameterDirection.Output;

Param[10] = new SqlParameter("@preferred", SqlDbType.NVarChar, 200);
Param[10].Direction = ParameterDirection.Output;

Param[11] = new SqlParameter("@newMessages", SqlDbType.Int);
Param[11].Direction = ParameterDirection.Output;

SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, "usp_Customer_ValidateUser", Param);
Message = Param[8].Value.ToString();
if (Message == "OK")
{

Regi_Id = Param[5].Value.ToString();
FullName = Param[6].Value.ToString();
Address = Param[7].Value.ToString();
PreferredName = Param[10].Value.ToString();
try
{
SSN = Convert.ToInt64(Param[9].Value).ToString("###-##-####");

}
catch
{
SSN = String.Empty;

}
NewMessages = Convert.ToInt32(Param[11].Value);
}
else
{
Regi_Id = String.Empty;
FullName = String.Empty;
Address = String.Empty;
SSN = String.Empty;
PreferredName = String.Empty;
NewMessages = 0;
}

}
protected void ChangePassword(String Regi_PK, String Email, String Pwd, String NewPwd, out String Message)
{
SqlParameter[] Param;
Param = new SqlParameter[6];
Param[0] = new SqlParameter("@Flag", SqlDbType.SmallInt);
Param[0].Value = 2;
Param[1] = new SqlParameter("@Regi_PK", SqlDbType.NVarChar);
Param[1].Value = Regi_PK;
Param[2] = new SqlParameter("@UserName", SqlDbType.NVarChar);
Param[2].Value = Email;
Param[3] = new SqlParameter("@Password", SqlDbType.NVarChar);
Param[3].Value = Pwd;
Param[4] = new SqlParameter("@NewPassword", SqlDbType.NVarChar);
Param[4].Value = NewPwd;
Param[5] = new SqlParameter("@msgout", SqlDbType.NVarChar, 100);
Param[5].Direction = ParameterDirection.Output;

SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, "usp_Customer_ValidateUser", Param);
Message = Param[5].Value.ToString();



}
protected void ForgotPassword(String Email, out String Message, out String Regi_Id, out String FullName, out String Password, out String PreferredName)
{
SqlParameter[] Param;
Param = new SqlParameter[7];
Param[0] = new SqlParameter("@Flag", SqlDbType.SmallInt);
Param[0].Value = 3;
Param[1] = new SqlParameter("@UserName", SqlDbType.NVarChar);
Param[1].Value = Email;
Param[2] = new SqlParameter("@Regi_Id", SqlDbType.NVarChar, 36);
Param[2].Direction = ParameterDirection.Output;
Param[3] = new SqlParameter("@fullName", SqlDbType.NVarChar, 500);
Param[3].Direction = ParameterDirection.Output;
Param[4] = new SqlParameter("@Address", SqlDbType.NVarChar, 500);
Param[4].Direction = ParameterDirection.Output;
Param[5] = new SqlParameter("@msgout", SqlDbType.NVarChar, 100);
Param[5].Direction = ParameterDirection.Output;
Param[6] = new SqlParameter("@preferred", SqlDbType.NVarChar, 200);
Param[6].Direction = ParameterDirection.Output;
SqlHelper.ExecuteNonQuery(connectionString, CommandType.StoredProcedure, "usp_Customer_ValidateUser", Param);
Message = Param[5].Value.ToString();


if (Message == "OK")
{
Regi_Id = Param[2].Value.ToString();
FullName = Param[3].Value.ToString();
Password = Param[4].Value.ToString();
PreferredName = Param[5].Value.ToString();
}
else
{
Regi_Id = String.Empty;
FullName = String.Empty;
Password = String.Empty;
PreferredName = String.Empty;
}
}
}
}

No comments: