/// <summary>
        /// Creates a cEmpPersonalDetails object. It will be saved in permanent storage only
        /// on calling Save()
        /// </summary>
        /// <returns>cEmpPersonalDetails object</returns>
        public static cEmpPersonalDetails Create()
        {
            cEmpPersonalDetails oObj = new cEmpPersonalDetails();

            SecurityCheck((int)enEmpPersonalDetails_Action.Create);

            // Create an object in memory, will be saved to storage on calling Save()
            oObj.m_bCreating = true;
            oObj.m_bInvalid  = false;
            return(oObj);
        }
        /// <summary>
        /// Ensures that an object with the specified name exists, while creating other properties are set to their default values
        /// </summary>
        /// <param name="i_sName">Name</param>
        /// <returns>cEmpPersonalDetails object</returns>
        public static cEmpPersonalDetails CreateIfRequiredAndGet(string i_sName)
        {
            cEmpPersonalDetails oObj = cEmpPersonalDetails.Get_Name(i_sName);

            if (oObj == null)
            {
                oObj       = cEmpPersonalDetails.Create();
                oObj.sName = i_sName;
                oObj.Save();
            }
            return(oObj);
        }
        /// <summary>
        /// Finds and return cEmpPersonalDetails objects matching the specified criteria
        /// </summary>
        /// <param name="i_oFilter">Filter criteria (WHERE clause)</param>
        /// <returns>cEmpPersonalDetails objects</returns>
        public static List <cEmpPersonalDetails> Find(cFilter i_oFilter)
        {
            DataTable dt = Find_DataTable(i_oFilter, null);
            List <cEmpPersonalDetails> l = new List <cEmpPersonalDetails>();
            cEmpPersonalDetails        oObj;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                oObj                   = new cEmpPersonalDetails();
                oObj.m_iID             = Convert.ToInt32(dt.Rows[i]["iID"]);
                oObj.m_sName           = dt.Rows[i]["sName"].ToString();
                oObj.m_dtCreatedOn     = Convert.ToDateTime(dt.Rows[i]["dtCreatedOn"]);
                oObj.m_dtLastUpdatedOn = Convert.ToDateTime(dt.Rows[i]["dtLastUpdatedOn"]);

                oObj.m_sFirstName            = Convert.ToString(dt.Rows[i]["sFirstName"]);
                oObj.m_sMiddleName           = Convert.ToString(dt.Rows[i]["sMiddleName"]);
                oObj.m_sLastName             = Convert.ToString(dt.Rows[i]["sLastName"]);
                oObj.m_sGender               = Convert.ToString(dt.Rows[i]["sGender"]);
                oObj.m_sFatherName           = Convert.ToString(dt.Rows[i]["sFatherName"]);
                oObj.m_sMotherName           = Convert.ToString(dt.Rows[i]["sMotherName"]);
                oObj.m_sCurrAddress          = Convert.ToString(dt.Rows[i]["sCurrAddress"]);
                oObj.m_sPerAddress           = Convert.ToString(dt.Rows[i]["sPerAddress"]);
                oObj.m_sMartialStatus        = Convert.ToString(dt.Rows[i]["sMartialStatus"]);
                oObj.m_dtDOB                 = Convert.ToDateTime(dt.Rows[i]["dtDOB"]);
                oObj.m_sGovtID               = Convert.ToString(dt.Rows[i]["sGovtID"]);
                oObj.m_sCity                 = Convert.ToString(dt.Rows[i]["sCity"]);
                oObj.m_sState                = Convert.ToString(dt.Rows[i]["sState"]);
                oObj.m_sZipCode              = Convert.ToString(dt.Rows[i]["sZipCode"]);
                oObj.m_sCountry              = Convert.ToString(dt.Rows[i]["sCountry"]);
                oObj.m_sNationality          = Convert.ToString(dt.Rows[i]["sNationality"]);
                oObj.m_sPerContactNo         = Convert.ToString(dt.Rows[i]["sPerContactNo"]);
                oObj.m_sWorkTelp             = Convert.ToString(dt.Rows[i]["sWorkTelp"]);
                oObj.m_sPersoanlEmailID      = Convert.ToString(dt.Rows[i]["sPersoanlEmailID"]);
                oObj.m_bIsActive             = Convert.ToBoolean(dt.Rows[i]["bIsActive"]);
                oObj.m_objEmpLogin.iObjectID = Convert.ToInt32(dt.Rows[i]["objEmpLogin"].ToString());
                oObj.m_bInvalid              = false;
                l.Add(oObj);
            }
            return(l);
        }
Example #4
0
        public JsonResult Add(EmployeeViewModel emp, string hdnEmployeeID)
        {
            try
            {
                EmployeeViewModel objEmpViewMod = new EmployeeViewModel();
                if (emp.SelectedRollAccess[0] == "" || emp.SelectedReportHead[0] == "" || emp.SelectedLocation[0] == "" || emp.SelectedDepartmentType[0] == "" || emp.SelectedDesignation[0] == "" || emp.SelectedRollAccess[0] == "" || emp.SelectedReportHead[0] == "")
                {
                    return(Json("1"));//Some Dropdown are not selected
                }
                else
                {
                    //if (ModelState.IsValid)
                    //{
                    if (hdnEmployeeID != null && hdnEmployeeID != "")
                    {
                        string strTitle = "0";
                        if (emp.SelectedTitle[0] == "")
                        {
                            strTitle = "0";
                        }
                        else
                        {
                            strTitle = emp.SelectedTitle[0];
                        }
                        int ID = Convert.ToInt32(hdnEmployeeID);

                        cEmpLogin objEmpLogin = cEmpLogin.Get_ID(ID);
                        objEmpLogin.sEmailID = emp.EmployeeEmailIdUpdate;
                        List <cManageGroup> objManag = cManageGroup.Find(" objFunctionalGroup = " + emp.DepTypeID + " and iReportingHead = " + Convert.ToInt32(emp.SelectedReportHead[0]));
                        if (objManag.Count > 0)
                        {
                            objEmpLogin.objManageGroup.iObjectID = objManag[0].iID;
                        }
                        else
                        {
                            cManageGroup aobjManag = cManageGroup.Create();
                            aobjManag.objFunctionalGroup.iObjectID = Convert.ToInt32(emp.SelectedDepartmentType[0]);
                            aobjManag.iReportingHead = Convert.ToInt32(emp.SelectedReportHead[0]);
                            aobjManag.Save();
                            objEmpLogin.objManageGroup.iObjectID = aobjManag.iID;
                        }
                        objEmpLogin.objRoleAccess.iObjectID  = Convert.ToInt32(emp.SelectedRollAccess[0]);
                        objEmpLogin.objTitle.iObjectID       = Convert.ToInt32(emp.SelectedTitle[0]);
                        objEmpLogin.objLocation.iObjectID    = Convert.ToInt32(emp.SelectedLocation[0]);
                        objEmpLogin.objDesignation.iObjectID = Convert.ToInt32(emp.SelectedDesignation[0]);
                        objEmpLogin.sFirstTime = "1";
                        objEmpLogin.bIsActive  = true;
                        objEmpLogin.sPassword  = emp.Password;
                        objEmpLogin.Save();

                        List <cEmpPersonalDetails> aobjEmployeePersonalDetails = cEmpPersonalDetails.Find(" objEmpLogin = "******"";
                        }
                        else
                        {
                            aobjEmployeePersonalDetails[0].sMiddleName = aobjEmployeePersonalDetails[0].sMiddleName;
                        }
                        //aobjEmployeePersonalDetails[0].sMiddleName = emp.EmpPersonal.MiddleName;

                        aobjEmployeePersonalDetails[0].sLastName             = emp.EmpPersonal.LastName;
                        aobjEmployeePersonalDetails[0].sPersoanlEmailID      = emp.PersonalEmailUpdate;
                        aobjEmployeePersonalDetails[0].objEmpLogin.iObjectID = objEmpLogin.iID;
                        aobjEmployeePersonalDetails[0].Save();


                        List <cEmployee> aobjEmp = cEmployee.Find(" objEmpLogin = "******" iID = " + aobjEmp[0].objEmpDesigDepartmentType.iObjectID);
                        //aobjDesigDepart[0].objDepartmentType.iObjectID = Convert.ToInt32(emp.SelectedDepartmentType[0]);
                        //aobjDesigDepart[0].objDesignation.iObjectID = Convert.ToInt32(emp.SelectedDesignation[0]);
                        //aobjDesigDepart[0].Save();
                        MailCreateEmployee(objEmpLogin.sEmailID, objEmpLogin.sPassword, "Update");
                        return(Json("2"));//Update
                    }
                    else
                    {
                        string strTitle = "0";
                        if (emp.SelectedTitle[0] == "")
                        {
                            strTitle = "0";
                        }
                        else
                        {
                            strTitle = emp.SelectedTitle[0];
                        }
                        cEmpLogin objEmpLogin = cEmpLogin.Create();
                        objEmpLogin.sEmailID = emp.EmployeeEmailId;
                        objEmpLogin.objRoleAccess.iObjectID = Convert.ToInt32(emp.SelectedRollAccess[0]);
                        objEmpLogin.sFirstTime = "1";
                        objEmpLogin.bIsActive  = true;
                        objEmpLogin.sPassword  = emp.Password;
                        objEmpLogin.objDesignation.iObjectID = Convert.ToInt32(emp.SelectedDesignation[0]);
                        objEmpLogin.objLocation.iObjectID    = Convert.ToInt32(emp.SelectedLocation[0]);
                        objEmpLogin.objTitle.iObjectID       = Convert.ToInt32(emp.SelectedTitle[0]);
                        List <cManageGroup> objManag = cManageGroup.Find(" objFunctionalGroup = " + emp.DepTypeID + " and iReportingHead = " + Convert.ToInt32(emp.SelectedReportHead[0]));
                        if (objManag.Count > 0)
                        {
                            objEmpLogin.objManageGroup.iObjectID = objManag[0].iID;
                        }
                        else
                        {
                            cManageGroup aobjManag = cManageGroup.Create();
                            aobjManag.objFunctionalGroup.iObjectID = Convert.ToInt32(emp.SelectedDepartmentType[0]);
                            aobjManag.iReportingHead = Convert.ToInt32(emp.SelectedReportHead[0]);
                            aobjManag.Save();
                            objEmpLogin.objManageGroup.iObjectID = aobjManag.iID;
                        }
                        objEmpLogin.Save();

                        cEmpPersonalDetails objEmployeePersonalDetails = cEmpPersonalDetails.Create();
                        objEmployeePersonalDetails.sFirstName = emp.EmpPersonal.FirstName;
                        if (emp.EmpPersonal.MiddleName == null)
                        {
                            objEmployeePersonalDetails.sMiddleName = "";
                        }
                        else
                        {
                            objEmployeePersonalDetails.sMiddleName = emp.EmpPersonal.MiddleName;
                        }

                        objEmployeePersonalDetails.sLastName             = emp.EmpPersonal.LastName;
                        objEmployeePersonalDetails.sPersoanlEmailID      = emp.PersonalEmail;
                        objEmployeePersonalDetails.objEmpLogin.iObjectID = objEmpLogin.iID;
                        objEmployeePersonalDetails.bIsActive             = true;
                        objEmployeePersonalDetails.Save();

                        cEmployee objEmp = cEmployee.Create();
                        objEmp.objEmpLogin.iObjectID = objEmpLogin.iID;

                        objEmp.dtDOJ = Convert.ToDateTime(emp.Employee.DOJ);
                        objEmp.Save();
                        MailCreateEmployee(objEmpLogin.sEmailID, objEmpLogin.sPassword, "Create");
                        return(Json("3"));//Create
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #5
0
        public JsonResult ReviewTimeSheet(string empId)
        {
            try
            {
                List <TimeReview> lists     = new List <TimeReview>();
                TimeSheet         timeSheet = new TimeSheet();
                int      id = Convert.ToInt32(HttpContext.User.Identity.Name);
                DateTime mon;
                System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture;
                DayOfWeek fdow  = ci.DateTimeFormat.FirstDayOfWeek;
                DayOfWeek today = DateTime.Now.DayOfWeek;
                DateTime  sow   = DateTime.Now.AddDays(-(today - fdow)).Date;
                mon           = sow;
                timeSheet.Mon = mon.ToString("dd/MM/yyyy");

                DateTime RStarts = new DateTime();
                DateTime EndDate = new DateTime();
                RStarts = mon.AddDays(1);
                EndDate = RStarts.AddDays(6);
                cEmpPersonalDetails empIdlogin = cEmpPersonalDetails.Get_ID(Convert.ToInt32(empId));
                int userId = empIdlogin.objEmpLogin.iObjectID;
                List <cEmpLogin> empLogin = cEmpLogin.Find(" objEmpLogin = "******" and iID = " + Convert.ToInt32(empId));


                if (empLogin.Count > 0)
                {
                    foreach (var item in empLogin)
                    {
                        List <cTimesheet> objTimes1 = cTimesheet.Find(" objEmpLogin = "******" iID = " + items.iID + " and dtStartDate = " + RStarts + " and dtEndDate = " + EndDate);

                                if (objTime.Count > 0)
                                {
                                    foreach (var itemTS in objTime)
                                    {
                                        List <cTimeSheetActivity> objActivity = cTimeSheetActivity.Find(" objTimesheet = " + itemTS.iID);

                                        if (objActivity.Count > 0)
                                        {
                                            foreach (var itemTSA in objActivity)
                                            {
                                                List <cTimeSheetActivityDes> objDes = cTimeSheetActivityDes.Find(" objTimeSheetActivity = " + itemTSA.iID);
                                                if (objDes.Count > 0)
                                                {
                                                    foreach (var itemDes in objDes)
                                                    {
                                                        string workHours = ReviewTimeCount(RStarts, Convert.ToInt32(empId));
                                                        long   mm        = 0;
                                                        long   hh        = 0;
                                                        hh        = hh + Convert.ToInt64(workHours) / 60;
                                                        mm        = mm + Convert.ToInt64(workHours) % 60;
                                                        workHours = hh + " : " + mm;
                                                        tm.Total  = workHours;
                                                        tm.date   = RStarts.ToString("dd/MM/yyyy");
                                                        DateTime dts = RStarts;
                                                        tm.sunday = dts.AddDays(6).ToString("dd/MM/yyyy");
                                                        if (objTime[0].bIsActive)
                                                        {
                                                            tm.status = "Submitted";
                                                        }
                                                        else
                                                        {
                                                            tm.status = "Saved";
                                                        }
                                                    }
                                                }
                                            }
                                        } //TimeSheetLoop
                                    }
                                }         //TimeSheet
                                lists.Add(tm);
                                RStarts = RStarts.AddDays(-7);
                                EndDate = EndDate.AddDays(-7);
                            }
                        }
                    }
                }

                return(Json(lists));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
using System;