Пример #1
0
        /// <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>cTimesheet object</returns>
        public static cTimesheet CreateIfRequiredAndGet(string i_sName)
        {
            cTimesheet oObj = cTimesheet.Get_Name(i_sName);

            if (oObj == null)
            {
                oObj       = cTimesheet.Create();
                oObj.sName = i_sName;
                oObj.Save();
            }
            return(oObj);
        }
Пример #2
0
        public JsonResult MyTimeSheet(string startDate, string endDate, string projectId, string ActivityID, string monday, string tuesday, string wed, string thu, string fri, string sat, string sun, string desc)
        {
            try
            {
                string id = HttpContext.User.Identity.Name;
                // DateTime dt = Convert.ToDateTime(startDate);
                DateTime          stDate        = DateTime.ParseExact(startDate, "dd/MM/yyyy", null);
                DateTime          enDate        = DateTime.ParseExact(endDate, "dd/MM/yyyy", null);
                List <cTimesheet> aObjTimesheet = cTimesheet.Find(" objEmpLogin = "******" and dtStartDate = " + stDate + " and dtEndDate = " + enDate);
                //List<cTimesheet> aObjTimesheet = cTimesheet.Find(" dtStartDate = " + stDate);
                if (aObjTimesheet.Count > 0)
                {
                    List <cTimeSheetActivity> aobjTimeActivity = cTimeSheetActivity.Find(" objTimesheet = " + aObjTimesheet[0].iID + " and objActivity = " + Convert.ToInt32(ActivityID));

                    if (aobjTimeActivity.Count > 0)
                    {
                        cTimeSheetActivityDes objDesc = cTimeSheetActivityDes.Create();
                        objDesc.objTimeSheetActivity.iObjectID = aobjTimeActivity[0].iID;
                        objDesc.sMonday      = monday;
                        objDesc.sTuesday     = tuesday;
                        objDesc.sWed         = wed;
                        objDesc.sThu         = thu;
                        objDesc.sFri         = fri;
                        objDesc.sSat         = sat;
                        objDesc.sSun         = sun;
                        objDesc.sDescription = desc;
                        objDesc.bIsActive    = true;
                        objDesc.Save();
                    }
                    else
                    {
                        cTimeSheetActivity objActive = cTimeSheetActivity.Create();
                        objActive.objActivity.iObjectID  = Convert.ToInt32(ActivityID);
                        objActive.objTimesheet.iObjectID = aObjTimesheet[0].iID;
                        objActive.bIsActive = true;

                        objActive.Save();

                        cTimeSheetActivityDes objDesc = cTimeSheetActivityDes.Create();
                        objDesc.objTimeSheetActivity.iObjectID = objActive.iID;
                        objDesc.sMonday      = monday;
                        objDesc.sTuesday     = tuesday;
                        objDesc.sWed         = wed;
                        objDesc.sTuesday     = thu;
                        objDesc.sFri         = fri;
                        objDesc.sSat         = sat;
                        objDesc.sSun         = sun;
                        objDesc.bIsActive    = true;
                        objDesc.sDescription = desc;

                        objDesc.Save();
                    }
                }
                else
                {
                    cTimesheet objTimesheet = cTimesheet.Create();
                    objTimesheet.objEmpLogin.iObjectID = Convert.ToInt32(id);
                    objTimesheet.dtStartDate           = stDate;
                    objTimesheet.dtEndDate             = enDate;
                    objTimesheet.objProject.iObjectID  = Convert.ToInt32(projectId);
                    objTimesheet.bIsActive             = false;
                    objTimesheet.sTotalTime            = "";
                    objTimesheet.Save();

                    cTimeSheetActivity objTimeActivity = cTimeSheetActivity.Create();
                    objTimeActivity.objActivity.iObjectID  = Convert.ToInt32(ActivityID);
                    objTimeActivity.objTimesheet.iObjectID = Convert.ToInt32(objTimesheet.iID);
                    objTimesheet.bIsActive = true;
                    objTimeActivity.Save();

                    cTimeSheetActivityDes objTimeActDesc = cTimeSheetActivityDes.Create();
                    objTimeActDesc.objTimeSheetActivity.iObjectID = objTimeActivity.iID;
                    objTimeActDesc.sMonday      = monday;
                    objTimeActDesc.sTuesday     = tuesday;
                    objTimeActDesc.sWed         = wed;
                    objTimeActDesc.sThu         = thu;
                    objTimeActDesc.sFri         = fri;
                    objTimeActDesc.sSat         = sat;
                    objTimeActDesc.sSun         = sun;
                    objTimeActDesc.sDescription = desc;
                    objTimeActDesc.bIsActive    = true;
                    objTimeActDesc.Save();
                }
                DateTime mon;
                System.Globalization.CultureInfo ci = System.Threading.Thread.CurrentThread.CurrentCulture;
                DayOfWeek fdow  = ci.DateTimeFormat.FirstDayOfWeek;
                DayOfWeek today = DateTime.Now.DayOfWeek;
                DateTime  sow   = dtCurrent.AddDays(-(today - fdow)).Date;
                mon = sow.AddDays(1);
                string workHours = TimeCount(mon);
                long   mm        = 0;
                long   hh        = 0;
                hh        = hh + Convert.ToInt64(workHours) / 60;
                mm        = mm + Convert.ToInt64(workHours) % 60;
                workHours = hh + " : " + mm;

                return(Json(workHours));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }