예제 #1
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 = "" }));
        }
예제 #2
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 = "" }));
        }