Exemplo n.º 1
0
        private void AddLeaveIntoDatabase(string empDate, VMLeaveEditor datas, string Name, string date, bool IsHalf)
        {
            int    empid  = db.Emps.First(aa => aa.EmpNo == datas.EmpNo).EmpID;
            LvType lvtype = new LvType();

            if (Name == "HLV:Casual")
            {
                lvtype = db.LvTypes.First(aa => aa.LvDesc == "LV:Casual");
            }
            else if (Name == "HLV:Annual")
            {
                lvtype = db.LvTypes.First(aa => aa.LvDesc == "LV:Annual");
            }
            else
            {
                lvtype = db.LvTypes.First(aa => aa.LvDesc == Name);
            }
            User          LoggedInUser = Session["LoggedUser"] as User;
            LvApplication lv           = new LvApplication();

            lv.EmpID       = empid;
            lv.LeaveTypeID = lvtype.LvTypeID;
            lv.LvDate      = DateTime.Today;
            if (IsHalf == true)
            {
                lv.NoOfDays = (float)0.5;
                lv.IsHalf   = true;
            }
            else
            {
                lv.NoOfDays = 1;
            }
            lv.CreatedBy = LoggedInUser.UserID;
            lv.FromDate  = Convert.ToDateTime(date);
            lv.ToDate    = Convert.ToDateTime(date);
            if (lvtype.UpdateBalance == true)
            {
                if (HasLeaveQuota(empid, lvtype.LvTypeID, lvtype))
                {
                    if (CheckLeaveBalance(lv, lvtype))
                    {
                        CreateLeave(lv, lvtype);
                    }
                    else
                    {
                        ViewBag.validtonmessage = "Leave Balance Exceeds, Please check the balance";
                    }
                }
                else
                {
                    ViewBag.validtonmessage = "Leave Quota does not exist";
                }
            }
            else
            {
                CreateLeave(lv, lvtype);
            }
        }
Exemplo n.º 2
0
        private void AddJobCardAppToJobCardData(VMLeaveEditor datas)
        {
            List <JobCardApp> _jobCardApp = new List <JobCardApp>();

            _jobCardApp = db.JobCardApps.Where(aa => aa.Status == false).ToList();
            List <Emp> _Emp = new List <Emp>();

            foreach (var jcApp in _jobCardApp)
            {
                jcApp.Status = true;
                AddJobCardData(datas, jcApp);
            }
        }
Exemplo n.º 3
0
        public ActionResult JCLeaveEditor(VMLeaveEditor vmdata)
        {
            List <string> dropDownValues = new List <string>();

            dropDownValues.Add("None");
            dropDownValues.AddRange(db.JobCards.Select(aa => aa.WorkCardName).ToList());
            dropDownValues.AddRange(db.LvTypes.Select(aa => aa.LvDesc).ToList());
            dropDownValues.Add("HLV:Casual");
            dropDownValues.Add("HLV:Annual");
            vmdata.dropdowns = dropDownValues;
            User           LoggedInUser = Session["LoggedUser"] as User;
            List <EmpView> emps         = new List <EmpView>();

            emps = db.EmpViews.Where(aa => aa.EmpNo == vmdata.EmpNo && aa.Status == true).ToList();
            emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList());
            try
            {
                if (emps.Count() > 0 && vmdata.FromDate != null && vmdata.ToDate != null)
                {
                    List <ViewAttData> attdata = new List <ViewAttData>();
                    attdata = db.ViewAttDatas.Where(aa => aa.EmpNo == vmdata.EmpNo && aa.AttDate >= vmdata.FromDate && aa.AttDate <= vmdata.ToDate && aa.StatusAB == true).ToList();
                    if (attdata.Count() == 0)
                    {
                        ViewBag.message = "No entry found";
                    }
                    vmdata.dbViewAttData = attdata;
                }
                else
                {
                    ViewBag.Messages = "There is no employee found";
                }
                return(View("Index", vmdata));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        private void AddJobCardData(VMLeaveEditor datas, JobCardApp jcApp)
        {
            int      _empID   = db.Emps.First(aa => aa.EmpNo == datas.EmpNo).EmpID;
            string   _empDate = "";
            int      _userID  = (int)jcApp.UserID;
            DateTime _Date    = (DateTime)jcApp.DateStarted;

            while (_Date <= jcApp.DateEnded)
            {
                _empDate = _empID + _Date.ToString("yyMMdd");
                AddJobCardDataToDatabase(_empDate, _empID, _Date, _userID, jcApp);
                db.SaveChanges();
                if (db.AttDatas.Where(aa => aa.EmpDate == _empDate).Count() > 0)
                {
                    //1	Official Duty
                    //2	Present
                    //3	Absent
                    //5	Special Holiday
                    switch (jcApp.CardType)
                    {
                    case 1:    // Official Duty
                        AddJCToAttData(_empDate, _empID, _Date, "O", false, false, false, false, true, "Offical Duty");
                        break;

                    case 5:    // Field Visit
                        AddJCToAttData(_empDate, _empID, _Date, "O", false, false, false, false, true, "Field Visit");
                        break;

                    case 7:    // Training
                        AddJCToAttData(_empDate, _empID, _Date, "O", false, false, false, false, true, "Training");
                        break;
                    }
                }
                _Date = _Date.AddDays(1);
            }
        }
Exemplo n.º 5
0
        private void AddJobCardsIntoDatabse(string empDate, VMLeaveEditor datas, string Name, string date)
        {
            User       LoggedInUser = Session["LoggedUser"] as User;
            int        empid        = db.Emps.First(aa => aa.EmpNo == datas.EmpNo).EmpID;
            int        cardtypeid   = db.JobCards.First(aa => aa.WorkCardName == Name).WorkCardID;
            JobCardApp jc           = new JobCardApp();

            jc.DateStarted     = Convert.ToDateTime(date);
            jc.DateEnded       = Convert.ToDateTime(date);
            jc.CardType        = (short)cardtypeid;
            jc.JobCardCriteria = "E";
            jc.CriteriaDate    = empid;
            jc.Status          = false;
            jc.UserID          = LoggedInUser.UserID;
            List <Emp> emptemp = db.Emps.Where(aa => aa.EmpNo == datas.EmpNo && aa.Deleted == false).ToList();

            if (emptemp.Count > 0)
            {
                if (ValidateJobCard(jc))
                {
                    db.JobCardApps.Add(jc);
                    if (db.SaveChanges() > 0)
                    {
                        AddJobCardAppToJobCardData(datas);
                    }
                }
                else
                {
                    ViewBag.validtonmessageforJC = "Job Card Validation failed";
                }
            }
            else
            {
                ViewBag.validtonmessageforJC = "There is no employee found";
            }
        }
Exemplo n.º 6
0
        public ActionResult UpdateEditor(VMLeaveEditor datas)
        {
            List <string> dropDownValues = new List <string>();

            dropDownValues.Add("None");
            dropDownValues.AddRange(db.JobCards.Select(aa => aa.WorkCardName).ToList());
            dropDownValues.AddRange(db.LvTypes.Select(aa => aa.LvDesc).ToList());
            dropDownValues.Add("HLV:Casual");
            dropDownValues.Add("HLV:Annual");
            datas.dropdowns = dropDownValues;
            if (datas.EmpNo != "" && datas.FromDate != null && datas.ToDate != null)
            {
                List <string> empDates = db.ViewAttDatas.Where(aa => aa.EmpNo == datas.EmpNo && aa.AttDate >= datas.FromDate && aa.AttDate <= datas.ToDate && aa.StatusAB == true).Select(aa => aa.EmpDate).ToList();
                foreach (var empDate in empDates)
                {
                    if (Request.Form["EmpDate" + empDate].ToString() != null && Request.Form["EmpDate" + empDate].ToString() != "" && Request.Form["EmpDate" + empDate].ToString() != "None")
                    {
                        AttData attData = db.AttDatas.First(aa => aa.EmpDate == empDate);
                        string  date    = attData.AttDate.ToString();
                        var     Name    = Request.Form["EmpDate" + empDate].ToString();
                        if (Name.Count() > 0)
                        {
                            switch (Name)
                            {
                            case "JC:Official Duty":
                                AddJobCardsIntoDatabse(empDate, datas, Name, date);
                                break;

                            case "JC:Field Visit":
                                AddJobCardsIntoDatabse(empDate, datas, Name, date);
                                break;

                            case "JC:Training":
                                AddJobCardsIntoDatabse(empDate, datas, Name, date);
                                break;

                            case "LV:Casual":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Annual":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "HLV:Casual":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, true);
                                break;

                            case "HLV:Annual":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, true);
                                break;

                            case "LV:Sick":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Ex Pakistan Leave":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Study Leave":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Optional Leave":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Maternity Leave":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Compensatory":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Special Leave":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Recreation Leave":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;

                            case "LV:Extraordinary Leave":
                                AddLeaveIntoDatabase(empDate, datas, Name, date, false);
                                break;
                            }
                        }
                        db.SaveChanges();
                    }
                }
            }
            datas.dbViewAttData = db.ViewAttDatas.Where(aa => aa.EmpNo == datas.EmpNo && aa.AttDate >= datas.FromDate && aa.AttDate <= datas.ToDate && aa.StatusAB == true).ToList();
            return(View("Index", datas));
        }
Exemplo n.º 7
0
        public ActionResult Index()
        {
            VMLeaveEditor vm = new VMLeaveEditor();

            return(View(vm));
        }