<F>BOL<F>
BOL.cs
............
using System;
using System.Collections.Generic;
using System.Text;
namespace T
{
namespace BOL
public struct Users
public long UserID;
public string UserName;
public string Password;
public byte AdminUser;
public byte Status;
}
public struct Customers
public long CustomerID;
public string Mobilenumber;
public string City;
public DateTime BirthDate;
<F>BLL<F>
UsersBLL.cs
.........................
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using T.BOL;
using T.DAL;
namespace BLL
public class UsersBLL
public UsersBLL()
//
// TODO: Add constructor logic here
public int AddUser(string name, string pass, byte admUser, byte status)
Users user = new Users();
user.UserName = name;
user.Password = pass;
user.AdminUser = admUser;
user.Status = status;
UsersDAL userDAl = new UsersDAL();
return userDAl.AddUser(user);
public void EditUser(string name, string pass, byte admUser, byte status, int id)
user.UserID = id;
userDAl.EditUser(user);
public void UpdateStatus(int ID, byte status)
user.UserID = ID;
userDAl.UpdateStatus(user);
public Users CheckUser(String UserName, String Password)
return userDAl.CheckUser(UserName,Password);
public Users CheckUserAvailable(String UserName)
return userDAl.CheckUserAvailable(UserName);
public Users GetByUserID(long UserID)
return userDAl.GetByUserID(UserID);
public DataTable GetAllUsers()
return userDAl.GetAllUsers();
<F>DAL</F>
UsersDAL.cs
....................
namespace DAL
public class UsersDAL : DALBase
public UsersDAL()
public int AddUser(Users user)
SqlCommand cmnd = BuildCommandSP("User_AddUser");
cmnd.Parameters.AddWithValue("@UserName", user.UserName);
cmnd.Parameters.AddWithValue("@Password", user.Password );
cmnd.Parameters.AddWithValue("@AdminUser", user.AdminUser );
cmnd.Parameters.AddWithValue("@Status", user.Status);
return ExecCmndSP(ref cmnd);
public void EditUser(Users user)
SqlCommand cmnd = BuildCommandSP("User_EditUser");
cmnd.Parameters.AddWithValue("@Password", user.Password);
cmnd.Parameters.AddWithValue("@AdminUser", user.AdminUser);
cmnd.Parameters.AddWithValue("@UserID", user.UserID);
ExecCmndSP(ref cmnd);
public void UpdateStatus(Users user)
SqlCommand cmnd = BuildCommandSP("User_UpdateStatus");
SqlCommand cmnd = BuildCommandSP("User_CheckUser");
cmnd.Parameters.AddWithValue("@Username", UserName);
cmnd.Parameters.AddWithValue("@PassWord", Password);
if (cmnd.Connection.State != ConnectionState.Open)
cmnd.Connection.Open();
SqlDataReader dr;
dr = cmnd.ExecuteReader();
if (dr.Read())
user.UserID = Convert.ToByte(dr["UserID"].ToString());
user.UserName = dr["Username"].ToString();
user.Password = dr["PassWord"].ToString();
user.AdminUser = Convert.ToByte(dr["AdminUser"]);
user.Status = Convert.ToByte (dr["Status"]);
cmnd.Connection.Close();
return user;
SqlCommand cmnd = BuildCommandSP("User_CheckUserAvailable");
user.Status = Convert.ToByte(dr["Status"]);
SqlCommand cmnd = BuildCommandSP("User_GetByUserID");
cmnd.Parameters.AddWithValue("@UserID", UserID);
user.UserID = Convert.ToInt64( dr["UserID"].ToString());
user.AdminUser = Convert.ToByte (dr["AdminUser"]);
user.Status = Convert.ToByte(dr["Status"].ToString());
DataTable result = new DataTable("Users");
SqlDataAdapter da = BuildBasicQuerySP("User_GetAllUsers");
da.Fill(result);
return result;
.................................................
Users.aspx.cs
...................
using System.Collections;
using T.BLL;
public partial class CreateUser : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (Session["UserName"] == null)
Response.Redirect("LogOf.aspx");
return;
if (Session["AdminUser"].ToString() == "0")
hlCreateUser.Visible = false;
else
hlCreateUser.Visible = true;
lblErrorMsg.Visible = false;
if (!IsPostBack)
refreshUserGrid();