コード例 #1
0
 public WCFAssignRole GetAssignRole(string assignrolecode, string email, string password)
 {
     if (loginService.ValidateUser(email, password))
     {
         AssignRole    a      = dCon.GetAssignRoleInfo(assignrolecode);
         string        emName = dCon.GetEmployeeName(a.EmployeeCode);
         WCFAssignRole ass    = new WCFAssignRole(a.AssignRoleCode, a.TemporaryRoleCode, a.EmployeeCode,
                                                  string.Format("{0:dd/MM/yyyy}", a.StartDate), string.Format("{0:dd/MM/yyyy}", a.EndDate),
                                                  a.AssignedBy, emName);
         return(ass);
     }
     else
     {
         return(null);
     }
 }
コード例 #2
0
        public String AddAssignRole(WCFAssignRole wcfassignrole, string email, string password)
        {
            if (loginService.ValidateUser(email, password))
            {
                //try
                //{
                string rolecodeselected = wcfassignrole.TemporaryRoleCode;
                string assignrolecode   = "AS" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
                if (rolecodeselected == "ActHead")
                {
                    DateTime startdateselected = Convert.ToDateTime(wcfassignrole.StartDate);
                    DateTime enddateselected   = Convert.ToDateTime(wcfassignrole.EndDate);

                    bool checkvalue    = dCon.CheckTemporaryRoleAndDates(rolecodeselected, startdateselected, enddateselected, eCon.GetDeptCodeByUserName(email));
                    bool checkemployee = dCon.CheckEmployee(wcfassignrole.EmployeeCode, eCon.GetDeptCodeByUserName(email));
                    if (checkvalue && checkemployee)
                    {
                        dCon.AddAssignRole(assignrolecode, rolecodeselected, wcfassignrole.EmployeeCode, startdateselected, enddateselected, wcfassignrole.AssignedBy);
                        return("truee");
                    }
                    else
                    {
                        return("false");
                    }
                }
                else
                {
                    bool checkvalue    = dCon.CheckTemporaryRole(rolecodeselected, eCon.GetDeptCodeByUserName(email));
                    bool checkemployee = dCon.CheckEmployee(wcfassignrole.EmployeeCode, eCon.GetDeptCodeByUserName(email));
                    if (checkvalue && checkemployee)
                    {
                        dCon.AddTemporaryRole(assignrolecode, rolecodeselected, wcfassignrole.EmployeeCode);
                        return("true");
                    }
                    else
                    {
                        return("false");
                    }
                }
            }
            else
            {
                return(null);
            }
            //AssignRole a = new AssignRole()
            //{
            //    AssignRoleCode = "AS" + DateTime.Now.ToString("yyyyMMddHHmmssfff"),
            //    TemporaryRoleCode = wcfassignrole.TemporaryRoleCode,
            //    EmployeeCode = wcfassignrole.EmployeeCode,

            //    // StartDate = Convert.ToDateTime( wcfassignrole.StartDate) ,
            //    //EndDate = Convert.ToDateTime(wcfassignrole.EndDate),
            //    AssignedBy = wcfassignrole.AssignedBy
            //};
            //if (wcfassignrole.TemporaryRoleCode != "ActHead")
            //{
            //    a.StartDate = null;
            //    a.EndDate = null;
            //}
            //else
            //{
            //    a.StartDate = Convert.ToDateTime(wcfassignrole.StartDate);
            //    a.EndDate = Convert.ToDateTime(wcfassignrole.EndDate);
            //}

            //if (wcfassignrole.TemporaryRoleCode == "ActHead")
            //{
            //    if (dController.CheckTemporaryRoleAndDates(wcfassignrole.TemporaryRoleCode, Convert.ToDateTime(a.StartDate),
            //        Convert.ToDateTime(a.EndDate))
            //        &&
            //        dController.CheckEmployee(wcfassignrole.EmployeeCode))
            //    {
            //        dController.AddAssignRole(a.AssignRoleCode, a.TemporaryRoleCode,
            //            a.EmployeeCode, a.StartDate, a.EndDate, a.AssignedBy);
            //        return "true";
            //    }
            //    else
            //    {
            //        return "false";
            //    }
            //}
            //else
            //{
            //    if (dController.CheckTemporaryRole(wcfassignrole.TemporaryRoleCode) &&
            //        dController.CheckEmployee(wcfassignrole.EmployeeCode))
            //    {
            //        dController.AddAssignRole(a.AssignRoleCode, a.TemporaryRoleCode,
            //            a.EmployeeCode, a.StartDate, a.EndDate, a.AssignedBy);
            //        return "true";

            //    }
            //    else
            //    {
            //        return "false";
            //    }


            //}
            ////}
            ////catch (Exception ex)
            ////{
            ////    //ex.Message;

            ////}
        }