コード例 #1
0
        public async Task <JsonResult> Create(FormCollection fc)
        {
            Domain.Model.User o = UserHelper.GetObject(fc);

            Dictionary <string, object> err = null;

            ISession se = NHibernateHelper.CurrentSession;

            err = o.IsValid(se);

            if (err == null)
            {
                await Task.Run(() =>
                {
                    using (ITransaction tx = se.BeginTransaction())
                    {
                        o.EncryptPassword();
                        se.SaveOrUpdate(o);
                        tx.Commit();
                    }
                });

                return(Json(new Dictionary <string, object>
                {
                    { "success", 1 },
                    { "message", "User was successfully added." }
                },
                            JsonRequestBehavior.AllowGet));
            }

            else
            {
                return(Json(err, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public async Task <ActionResult> Edit(Guid id)
        {
            ViewBag.form_id = "edit-form";

            ISession se = NHibernateHelper.CurrentSession;

            Domain.Model.User o = await Task.Run(() => { return(se.Get <Domain.Model.User>(id)); });

            return(View("_form", o));
        }
コード例 #3
0
        public async Task <JsonResult> Update(Guid id, FormCollection fc)
        {
            Dictionary <string, object> err = null;

            Domain.Model.User o = null;
            Domain.Model.User x = UserHelper.GetObject(fc);

            ISession se = NHibernateHelper.CurrentSession;

            o = await Task.Run(() => { return(se.Get <Domain.Model.User>(id)); });

            x.Id = id;

            err = x.IsValid(se);

            if (err == null)
            {
                await Task.Run(() =>
                {
                    using (ITransaction tx = se.BeginTransaction())
                    {
                        o.Role     = x.Role;
                        o.Username = x.Username;
                        o.Status   = x.Status;

                        if (x.Password != Domain.Model.User.UNCHANGED_PASSWORD)
                        {
                            o.Password = x.Password;
                            o.EncryptPassword();
                        }

                        se.SaveOrUpdate(o);
                        tx.Commit();
                    }
                });

                return(Json(new Dictionary <string, object>
                {
                    { "success", 1 },
                    { "message", "User was successfully updated." }
                },
                            JsonRequestBehavior.AllowGet));
            }

            else
            {
                return(Json(err, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #4
0
        private async Task DeleteReferences(ISession se, string[] idlist)
        {
            foreach (string id in idlist)
            {
                Guid uid            = new Guid(id);
                Domain.Model.User o = se.Get <Domain.Model.User>(uid);
                Employee          e = o.Employee;

                if (e != null)
                {
                    e.User = null;

                    await Task.Run(() =>
                    {
                        using (ITransaction tx = se.BeginTransaction())
                        {
                            se.SaveOrUpdate(e);
                            tx.Commit();
                        }
                    });
                }
            }
        }
コード例 #5
0
ファイル: UserHelper.cs プロジェクト: kenny007/Payroll_MVC4
        public static User GetObject(FormCollection fc)
        {
            string paramStatus = fc.Get("status");
            bool status = paramStatus == "1" ? true : false;

            string paramRole = fc.Get("role");
            int role = CommonHelper.GetValue<int>(paramRole);

            User o = new User
            {
                Role = role,
                Username = fc.Get("username"),
                Status = status,
                Password = fc.Get("pwd"),
                PasswordConfirmation = fc.Get("pwdconfirm")
            };

            return o;
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: kenny007/Payroll_MVC4
        private static async Task CreateSeed(ISessionFactory s)
        {
            using (ISession se = s.OpenSession())
            {
                using (ITransaction tx = se.BeginTransaction())
                {
                    User a = new User { Username = "******", Password = "******", Role = 1, Status = true };
                    a.EncryptPassword();
                    se.SaveOrUpdate(a);

                    a = new User { Username = "******", Password = "******", Role = 2, Status = true };
                    a.EncryptPassword();
                    se.SaveOrUpdate(a);

                    Employee o = new Employee
                    {
                        Staffid = "S0001",
                        Firstname = "Ben",
                        Lastname = "Ng",
                        Newic = "77665544",
                        Gender = "M",
                        Maritalstatus = "S",
                        Nationality = "Malaysian",
                        Dob = new DateTime(1988, 6, 5),
                        Placeofbirth = "PJ",
                        Race = "Chinese",
                        Isbumi = false,
                        User = a
                    };
                    se.SaveOrUpdate(o);

                    Employeecontact ect = new Employeecontact
                    {
                        Id = o.Id,
                        Address1 = "No. 6, Jalan Awan Kecil 1",
                        Address2 = "Taman OUG",
                        Address3 = "Off Jalan Klang Lama",
                        City = "KL",
                        State = "WP",
                        Postcode = "58200",
                        Country = "Malaysia",
                        Homephone = "88098776",
                        Mobilephone = "77609887",
                        Workemail = "*****@*****.**",
                        Otheremail = "*****@*****.**",
                    };
                    se.SaveOrUpdate(ect);

                    await CreateListAttendance(se, o.Staffid, o);

                    Employeesalary es = new Employeesalary
                    {
                        Id = o.Id,
                        Salary = 0,
                        Allowance = 45,
                        Epf = 278,
                        Socso = 46,
                        Incometax = 57,
                        Bankname = "RHB",
                        Bankaccno = "5509800076",
                        Bankacctype = "Savings",
                        Bankaddress = "Jalan Awan Besar",
                        Epfno = "443987542",
                        Socsono = "8876908539",
                        Incometaxno = "439877055",
                        Paytype = 2
                    };
                    se.SaveOrUpdate(es);

                    Designation des = new Designation { Title = "Software Developer" };
                    se.SaveOrUpdate(des);

                    Department dept = new Department { Name = "R&D" };
                    se.SaveOrUpdate(dept);

                    Jobcategory jobcat = new Jobcategory { Name = "Software Development" };
                    se.SaveOrUpdate(jobcat);

                    Employmentstatus empstat = new Employmentstatus { Name = "Probation" };
                    se.SaveOrUpdate(empstat);

                    empstat = new Employmentstatus { Name = "Confirmed" };
                    se.SaveOrUpdate(empstat);

                    Employeejob empjob = new Employeejob
                    {
                        Id = o.Id,
                        Designation = des,
                        Department = dept,
                        Employmentstatus = empstat,
                        Jobcategory = jobcat,
                        Joindate = new DateTime(2000, 1, 1),
                        Confirmdate = new DateTime(2000, 3, 1)
                    };
                    se.SaveOrUpdate(empjob);

                    //

                    a = new User { Username = "******", Password = "******", Role = 2, Status = true };
                    a.EncryptPassword();
                    se.SaveOrUpdate(a);

                    o = new Employee
                    {
                        Staffid = "S0002",
                        Firstname = "Ken",
                        Lastname = "Lee",
                        Newic = "785400",
                        Gender = "M",
                        Maritalstatus = "S",
                        Nationality = "Malaysian",
                        Dob = new DateTime(1986, 6, 5),
                        Placeofbirth = "PJ",
                        Race = "Chinese",
                        Isbumi = false,
                        User = a
                    };
                    se.SaveOrUpdate(o);

                    ect = new Employeecontact
                    {
                        Id = o.Id,
                        Address1 = "No. 7, Jalan Putra 1",
                        Address2 = "Taman Pinang",
                        Address3 = "Off Jalan Putra Perdana",
                        City = "KL",
                        State = "WP",
                        Postcode = "59200",
                        Country = "Malaysia",
                        Homephone = "88028776",
                        Mobilephone = "77659887",
                        Workemail = "*****@*****.**",
                        Otheremail = "*****@*****.**"
                    };
                    se.SaveOrUpdate(ect);

                    await CreateListAttendance(se, o.Staffid, o);

                    es = new Employeesalary
                    {
                        Id = o.Id,
                        Salary = 0,
                        Allowance = 55,
                        Epf = 298,
                        Socso = 65,
                        Incometax = 95,
                        Bankname = "RHB",
                        Bankaccno = "5509800077",
                        Bankacctype = "Savings",
                        Bankaddress = "Jalan Awan Besar",
                        Epfno = "443987548",
                        Socsono = "8878908539",
                        Incometaxno = "439899055",
                        Paytype = 2
                    };
                    se.SaveOrUpdate(es);

                    des = new Designation { Title = "Account Executive" };
                    se.SaveOrUpdate(des);

                    dept = new Department { Name = "Admin" };
                    se.SaveOrUpdate(dept);

                    jobcat = new Jobcategory { Name = "Administration" };
                    se.SaveOrUpdate(jobcat);

                    empjob = new Employeejob
                    {
                        Id = o.Id,
                        Designation = des,
                        Department = dept,
                        Employmentstatus = empstat,
                        Jobcategory = jobcat,
                        Joindate = new DateTime(2000, 2, 1),
                        Confirmdate = new DateTime(2000, 4, 1)
                    };
                    se.SaveOrUpdate(empjob);

                    //

                    a = new User { Username = "******", Password = "******", Role = 2, Status = true };
                    a.EncryptPassword();
                    se.SaveOrUpdate(a);

                    o = new Employee
                    {
                        Staffid = "S0003",
                        Firstname = "Steve",
                        Lastname = "Yap",
                        Newic = "65098765",
                        Gender = "M",
                        Maritalstatus = "S",
                        Nationality = "Malaysian",
                        Dob = new DateTime(1974, 6, 5),
                        Placeofbirth = "PJ",
                        Race = "Chinese",
                        Isbumi = false,
                        User = a
                    };
                    se.SaveOrUpdate(o);

                    ect = new Employeecontact
                    {
                        Id = o.Id,
                        Address1 = "No. 5, Jalan Bukit Bintang",
                        Address2 = "Taman Bintang",
                        Address3 = "Off Jalan Bukit",
                        City = "KL",
                        State = "WP",
                        Postcode = "57200",
                        Country = "Malaysia",
                        Homephone = "88798776",
                        Mobilephone = "79609887",
                        Workemail = "*****@*****.**",
                        Otheremail = "*****@*****.**"
                    };
                    se.SaveOrUpdate(ect);

                    await CreateListAttendance(se, o.Staffid, o);

                    es = new Employeesalary
                    {
                        Id = o.Id,
                        Salary = 0,
                        Allowance = 55,
                        Epf = 300,
                        Socso = 62,
                        Incometax = 48,
                        Bankname = "RHB",
                        Bankaccno = "5509100076",
                        Bankacctype = "Savings",
                        Bankaddress = "Jalan Awan Besar",
                        Epfno = "473987542",
                        Socsono = "8879908539",
                        Incometaxno = "439817055",
                        Paytype = 2
                    };
                    se.SaveOrUpdate(es);

                    des = new Designation { Title = "Sales Executive" };
                    se.SaveOrUpdate(des);

                    dept = new Department { Name = "Sales" };
                    se.SaveOrUpdate(dept);

                    jobcat = new Jobcategory { Name = "Sales" };
                    se.SaveOrUpdate(jobcat);

                    empjob = new Employeejob
                    {
                        Id = o.Id,
                        Designation = des,
                        Department = dept,
                        Employmentstatus = empstat,
                        Jobcategory = jobcat,
                        Joindate = new DateTime(2000, 3, 1),
                        Confirmdate = new DateTime(2000, 5, 1)
                    };
                    se.SaveOrUpdate(empjob);

                    await CreatePayRate(se, "S0001");
                    await CreatePayRate(se, "S0002");
                    await CreatePayRate(se, "S0003");

                    //

                    a = new User { Username = "******", Password = "******", Role = 2, Status = true };
                    a.EncryptPassword();
                    se.SaveOrUpdate(a);

                    o = new Employee
                    {
                        Staffid = "S0004",
                        Firstname = "Kelly",
                        Lastname = "Yap",
                        Newic = "55441122",
                        Gender = "F",
                        Maritalstatus = "S",
                        Nationality = "Malaysian",
                        Dob = new DateTime(1979, 6, 5),
                        Placeofbirth = "KL",
                        Race = "Chinese",
                        Isbumi = false,
                        User = a
                    };
                    se.SaveOrUpdate(o);

                    ect = new Employeecontact
                    {
                        Id = o.Id,
                        Address1 = "No. 2, Jalan Kerinchi 5",
                        Address2 = "Taman Bukit Kerinchi",
                        Address3 = "Off Jalan Kerinchi Besar",
                        City = "KL",
                        State = "WP",
                        Postcode = "56200",
                        Country = "Malaysia",
                        Homephone = "88098476",
                        Mobilephone = "77609187",
                        Workemail = "*****@*****.**",
                        Otheremail = "*****@*****.**"
                    };
                    se.SaveOrUpdate(ect);

                    await CreateListAttendance(se, o.Staffid, o);

                    Random r = new Random();

                    es = new Employeesalary
                    {
                        Id = o.Id,
                        Salary = r.Next(2500, 3000),
                        Allowance = r.Next(60, 100),
                        Epf = r.Next(100, 200),
                        Socso = r.Next(90, 100),
                        Incometax = r.Next(100, 200),
                        Bankname = "RHB",
                        Bankaccno = "667743290",
                        Bankacctype = "Savings",
                        Bankaddress = "Jalan Pinang",
                        Epfno = "59876000",
                        Socsono = "76545",
                        Incometaxno = "ASD965777",
                        Paytype = 1
                    };
                    se.SaveOrUpdate(es);

                    des = new Designation { Title = "Marketing Executive" };
                    se.SaveOrUpdate(des);

                    dept = new Department { Name = "Marketing" };
                    se.SaveOrUpdate(dept);

                    jobcat = new Jobcategory { Name = "Marketing" };
                    se.SaveOrUpdate(jobcat);

                    empjob = new Employeejob
                    {
                        Id = o.Id,
                        Designation = des,
                        Department = dept,
                        Employmentstatus = empstat,
                        Jobcategory = jobcat,
                        Joindate = new DateTime(2000, 1, 1),
                        Confirmdate = new DateTime(2000, 3, 1)
                    };
                    se.SaveOrUpdate(empjob);

                    await CreateOvertimeRate(se);
                    await CreateSalaryAdj(se, o.Staffid);

                    tx.Commit();
                }
            }
        }
コード例 #7
0
ファイル: ForumService.cs プロジェクト: DnY-stuff/Forum
 /// <summary>
 /// ������ �����մϴ�.
 /// </summary>
 /// <param name="eraser">������</param>
 /// <param name="forumId">���� Id</param>
 public void DeleteForum(User eraser, Guid forumId)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
ファイル: ForumService.cs プロジェクト: DnY-stuff/Forum
 /// <summary>
 /// ���ο� ��Ÿ���� �����մϴ�.
 /// </summary>
 /// <param name="creator">������</param>
 /// <param name="forum">�Ҽ�����</param>
 /// <param name="title">����</param>
 /// <param name="content">����</param>
 /// <param name="description">����</param>
 /// <returns>������ ��Ÿ��</returns>
 public Thread CreateNewThread(User creator, Forum forum, string title, string content, string description)
 {
     throw new NotImplementedException();
 }
コード例 #9
0
ファイル: ForumService.cs プロジェクト: DnY-stuff/Forum
 /// <summary>
 /// ���ο� ������ �����մϴ�.
 /// </summary>
 /// <param name="creator">������</param>
 /// <param name="title">����</param>
 /// <param name="description">����</param>
 /// <returns>������ ����</returns>
 public Forum CreateForum(User creator, string title, string description)
 {
     throw new NotImplementedException();
 }
コード例 #10
0
ファイル: ForumService.cs プロジェクト: DnY-stuff/Forum
 /// <summary>
 /// ��Ÿ���� �亯�մϴ�.
 /// </summary>
 /// <param name="replier">�亯��</param>
 /// <param name="thread">��Ÿ��</param>
 /// <param name="title">����</param>
 /// <param name="content">����</param>
 /// <returns>��Ÿ��</returns>
 public Thread ReplyThread(User replier, Thread thread, string title, string content)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
ファイル: ForumService.cs プロジェクト: DnY-stuff/Forum
 /// <summary>
 /// ��Ÿ���� ���ϴ� �������� �̵���ŵ�ϴ�.
 /// </summary>
 /// <param name="moderator">������</param>
 /// <param name="thread">��Ÿ��</param>
 /// <param name="forumToMove">�̵���ų ����</param>
 public void MoveThreadToForum(User moderator, Thread thread, Forum forumToMove)
 {
     throw new NotImplementedException();
 }
コード例 #12
0
ファイル: ForumService.cs プロジェクト: DnY-stuff/Forum
 /// <summary>
 /// ���� �����մϴ�.
 /// </summary>
 /// <param name="modifier">������</param>
 /// <param name="thread">�Ҽӱ�Ÿ��</param>
 /// <param name="postId">�� Id</param>
 /// <param name="title">����</param>
 /// <param name="content">����</param>
 /// <returns>��Ÿ��</returns>
 public Thread ModifyPost(User modifier, Thread thread, Guid postId, string title, string content)
 {
     throw new NotImplementedException();
 }