public bool Insert(Membership membership)
 {
     using (MembershipDataAdapter adapter = new MembershipDataAdapter())
     {
         return adapter.InsertMembership(membership.Username, membership.Password,
                                                      membership.Authorization, membership.EmployeeId);
     }
 }
        private Membership PopulateReader(IDataReader dr)
        {
            Membership membership = new Membership();
            if (dr["Id"] != DBNull.Value)
                membership.Id = Convert.ToInt32(dr["Id"]);

            membership.Username = dr["Username"].ToString();
            membership.Password = dr["Password"].ToString();
            membership.Authorization = Convert.ToInt32(dr["Authorization"]);
            membership.EmployeeId = dr["EmployeeId"].ToString();
            return membership;
        }
 public Membership GetMembershipByUsername(string username)
 {
     Membership membership = new Membership();
     using (MembershipDataAdapter adapter = new MembershipDataAdapter())
     {
         IDataReader dr = adapter.GetMembershipByUsername(username);
         if (dr.Read())
         {
             membership = PopulateReader(dr);
             adapter.Dispose();
         }
         return membership;
     }
 }
 public Membership GetMembershipById(int id)
 {
     Membership membership = new Membership();
     using (MembershipDataAdapter adapter = new MembershipDataAdapter())
     {
         IDataReader dr = adapter.GetMembershipById(id);
         if (dr.Read())
         {
             membership = PopulateReader(dr);
             adapter.Dispose();
         }
         return membership;
     }
 }
    private bool CheckUserPassword(string userId,string password)
    {
        if (ValidateUserAvailability(userId))
        {
            MembershipModule membershipModule = new MembershipModule();
            InventorySystem.Business.Membership membership = new InventorySystem.Business.Membership();
            membership = membershipModule.GetMembershipByUsername(userId);

            if (membership.Username == userId && membership.Password == password)
                return true;

        }
        return false;
    }
    private void InsertMembership()
    {
        InventorySystem.Business.Membership membership = new InventorySystem.Business.Membership();
        InventorySystem.Business.MembershipModule membershipModule = new InventorySystem.Business.MembershipModule();
        if (ViewState["id"] != null)
            membership.Username = ViewState["id"].ToString();
        else
            membership.Username = null;

        membership.Username = txtMembershipUserid.Text;
        membership.Password = txtMembershipPassword.Text;
        membership.Authorization = Convert.ToInt32(ddlMembershipAuthorization.SelectedValue.ToString());
        membership.EmployeeId = ddlMembershipEmployeeName.SelectedValue.ToString();

        membershipModule.Save(membership);
    }
 public void Save(Membership membership)
 {
     membership.Save();
 }