Esempio n. 1
0
 public ActionResult Index(FormCollection fc)
 {
     try
     {
         string username = (fc["username"]).ToString();
         string pass     = (fc["password"].ToString());
         string hash     = Hash(pass);
         Login  log      = new Login();
         log = LoginControllerSql.Get(username, hash);
         if (username == "")
         {
             return(RedirectToAction("Home", "Admin"));
         }
         if (log.Level == 4)
         {
             Member mem = new Member();
             mem = MemberControllerSql.GetByLoginId(log.Id);
             Session["Fullname"]  = mem.Fname + " " + mem.Mname + " " + mem.Lname;
             Session["MemberId"]  = mem.Id;
             Session["MemberId1"] = mem.EmployeeId;
             return(RedirectToAction("Home", "Member"));
         }
         else if (log.Level == 3)
         {
             Admin a = new Admin();
             a = AdminControllerSql.GetById(log.Id);
             Session["Fullname"]  = a.Fname + " " + a.Mname + " " + a.Lname;
             Session["MemberId"]  = a.Id;
             Session["MemberId1"] = a.AdminId;
             return(RedirectToAction("Home", "Admin"));
         }
         else
         {
             Response.Write("<script type = 'text/javascript'>alert('Wrong Username or Password');</script>");
         }
     }
     catch (Exception)
     {
         Response.Write("<script type = 'text/javascript'>alert('Wrong Username or Password');</script>");
     }
     return(View());
 }
Esempio n. 2
0
        public ActionResult MemberAdd(Member me)
        {
            bool     status = false;
            DateTime day    = DateTime.Now;

            Session["status"] = null;
            List <Login> loglist = new List <Login>();

            loglist = LoginControllerSql.GetAll(me.EmailAddress);
            List <Member> mem = new List <Member>();

            mem = MemberControllerSql.GetAll();
            int    iid   = mem.Count + 1;
            string memid = "M" + (iid).ToString();
            string salut = "";

            if (loglist.Count == 0)
            {
                string pass = Hash((me.Birthdate.ToShortDateString()));
                Login  log  = new Login
                {
                    Username     = me.EmailAddress,
                    Hash         = pass,
                    CreatedBy    = "none",
                    ModifyBy     = "none",
                    Level        = 4,
                    CreatedDate  = day,
                    ModifiedDate = day,
                    Locked       = 0,
                    LastLogin    = day
                };
                status = LoginControllerSql.Insert(log);

                if (status == true)
                {
                    if (me.Gender == "Male")
                    {
                        salut = "Mr";
                    }
                    else if (me.Gender == "Female")
                    {
                        if (me.MaritalStatus == "Married")
                        {
                            salut = "Mrs";
                        }
                        else
                        {
                            salut = "Ms";
                        }
                    }
                    List <Login> ul  = LoginControllerSql.GetAll(me.EmailAddress);
                    Member       ret = new Member
                    {
                        Fname              = me.Fname,
                        Mname              = me.Mname,
                        Lname              = me.Lname,
                        Birthdate          = me.Birthdate,
                        Position           = me.Position,
                        EmailAddress       = me.EmailAddress,
                        Deleted            = 0,
                        Url                = "---",
                        LoginId            = ul[0].Id,
                        ResidentialAddress = me.ResidentialAddress,
                        Gender             = me.Gender,
                        ContactNo          = me.ContactNo,
                        MaritalStatus      = me.MaritalStatus,
                        EmployeeId         = memid,
                        EmergencyContactNo = me.EmergencyContactNo,
                        SalaryAmt          = me.SalaryAmt,
                        Salutation         = salut
                    };
                    status            = MemberControllerSql.Insert(ret);
                    Session["status"] = 1;
                }
            }
            else
            {
                Session["status"] = 2;
                Response.Write("<script type='text/javascript'>alert('Email is already exist');</script>");
            }
            Session["AddMessage"] = status;
            return(RedirectToAction("MemberView", "Member", new { id = "" }));
        }
Esempio n. 3
0
        public ActionResult AdminAdd(Admin adm)
        {
            bool     status = false;
            DateTime day    = DateTime.Now;

            Session["status"] = null;
            List <Login> loglist = new List <Login>();

            loglist = LoginControllerSql.GetAll(adm.EmailAddress);
            List <Admin> adminlist = new List <Admin>();

            adminlist = AdminControllerSql.GetAll();
            int    iid = adminlist.Count + 1;
            string aid = "M" + (iid).ToString();

            if (loglist.Count == 0)
            {
                int level = 0;
                if (adm.Position == "Finance")
                {
                    level = 2;
                }
                else if (adm.Position == "Accountant")
                {
                    level = 3;
                }
                string pass = Hash((adm.Bdate.ToShortDateString()));
                Login  log  = new Login
                {
                    Username     = adm.EmailAddress,
                    Hash         = pass,
                    CreatedBy    = "none",
                    ModifyBy     = "none",
                    Level        = level,
                    CreatedDate  = day,
                    ModifiedDate = day,
                    Locked       = 0,
                    LastLogin    = day
                };
                status = LoginControllerSql.Insert(log);

                if (status == true)
                {
                    List <Login> ul  = LoginControllerSql.GetAll(adm.EmailAddress);
                    Admin        ret = new Admin
                    {
                        Fname              = adm.Fname,
                        Mname              = adm.Mname,
                        Lname              = adm.Lname,
                        Bdate              = adm.Bdate,
                        Deleted            = 0,
                        EmailAddress       = adm.EmailAddress,
                        Url                = "---",
                        Position           = adm.Position,
                        MaritalStatus      = adm.MaritalStatus,
                        ContactNo          = adm.ContactNo,
                        EmergencyNo        = adm.EmergencyNo,
                        AdminId            = aid,
                        ResidentialAddress = adm.ResidentialAddress,
                        LoginId            = ul[0].Id,
                        Gender             = adm.Gender
                    };
                    status            = AdminControllerSql.Insert(ret);
                    Session["status"] = 1;
                }
            }
            else
            {
                Session["status"] = 2;
                Response.Write("<script type='text/javascript'>alert('Email is already exist');</script>");
            }
            Session["AddMessage"] = status;
            return(RedirectToAction("AdminView", "Admin", new { id = "" }));
        }