protected void Button1_Click1(object sender, EventArgs e)
    {
        try
        {
            if (Convert.ToDateTime(txtStartLdate.Text) < DateTime.Now)
            {
                Response.Write("<script>alert('Please enter proper date.....!');</script>");
                return;
            }
            LeaveMaster l = new LeaveMaster();
            l.LeaveReason    = txtLreason.Text;
            l.LeaveDate      = Convert.ToDateTime(txtLdate.Text);
            l.StartLeaveDate = Convert.ToDateTime(txtStartLdate.Text);
            l.EndLeaveDate   = Convert.ToDateTime(txtEndLdate.Text);
            l.EmpId          = Convert.ToInt16(Session["EmpId"].ToString());
            l.LeaveStatus    = "Not Approve";
            db.LeaveMasters.InsertOnSubmit(l);
            db.SubmitChanges();
            //db.manage_leavemaster(0, txtLreason.Text, "Not Approve",, 1);
            bindgrid();
            Response.Write("<script>alert('Leave Request Sent Successfully');</script>");

            txtEndLdate.Text   = "";
            txtLdate.Text      = "";
            txtLreason.Text    = "";
            txtStartLdate.Text = "";
        }


        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            LeaveMaster leaveMaster = db.LeaveMasters.Find(id);

            db.LeaveMasters.Remove(leaveMaster);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "CustomerId,LeaveId,LeaveTypeId,LeaveCount,CalenderYear,IsActive,IsDelete,IsCreated")] LeaveMaster leaveMaster)
 {
     if (ModelState.IsValid)
     {
         db.Entry(leaveMaster).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(leaveMaster));
 }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "CustomerId,LeaveId,LeaveTypeId,LeaveCount,CalenderYear,IsActive,IsDelete,IsCreated")] LeaveMaster leaveMaster)
        {
            if (ModelState.IsValid)
            {
                db.LeaveMasters.Add(leaveMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(leaveMaster));
        }
Ejemplo n.º 5
0
    public static string[] GetCompletionListLeaveName(string prefixText, int count, string contextKey)
    {
        LeaveMaster objLeaveMaster = new LeaveMaster();
        DataTable   dt             = new DataView(objLeaveMaster.GetLeaveMaster(HttpContext.Current.Session["CompId"].ToString()), "Leave_Name like '" + prefixText.ToString() + "%'", "", DataViewRowState.CurrentRows).ToTable();

        string[] txt = new string[dt.Rows.Count];

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            txt[i] = dt.Rows[i]["Leave_Name"].ToString();
        }
        return(txt);
    }
Ejemplo n.º 6
0
        // GET: LeaveMasters/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LeaveMaster leaveMaster = db.LeaveMasters.Find(id);

            if (leaveMaster == null)
            {
                return(HttpNotFound());
            }
            return(View(leaveMaster));
        }
Ejemplo n.º 7
0
        public static void CalculateLeave(OtherLeave LeaveTransaction, EmployeeLeaveList obj, LeaveListCalc leaveListCalc, int branchId)
        {
            LeaveMaster lMaster = new LeaveMaster();

            if (obj.LeaveTypeId == lMaster.CASUALLEAVE(branchId))
            {
                leaveListCalc.currentLeaves = leaveListCalc.currentLeaves - obj.Days.Value;
            }
            else if (obj.LeaveTypeId == lMaster.ANNUALLEAVE(branchId))
            {
                leaveListCalc.currentLeaves = leaveListCalc.currentLeaves - obj.Days.Value;
            }
            if (obj.LeaveTypeId == lMaster.MEDICALLEAVE(branchId))
            {
                leaveListCalc.currentLeaves = leaveListCalc.currentLeaves - obj.Days.Value;
            }
        }
Ejemplo n.º 8
0
        public decimal GetLeavesCount(int BranchID, int EmployeeID, int LeaveType, DateTime fromDate)
        {
            DateTime date = fromDate;
            //int currentMonth = date.Month;
            int     currentYear    = date.Year;
            decimal eligibleLeaves = 0;
            decimal appliedLeave   = 0;

            using (HrDataContext dbContext = new HrDataContext())
            {
                OtherLeave leave            = dbContext.OtherLeaves.Where(x => x.BranchId == BranchID && x.LeaveTypeId == LeaveType).FirstOrDefault();
                LeaveTran  leaveTransaction = dbContext.LeaveTrans.Where(x => x.EmployeeId == EmployeeID && x.BranchId == BranchID && x.LeaveType == LeaveType)
                                              .OrderByDescending(x => x.TransactionId)
                                              .ThenByDescending(x => x.CreatedOn).FirstOrDefault();

                DateTime now       = date;
                var      startDate = new DateTime(now.Year, now.Month, 1);
                var      endDate   = startDate.AddMonths(1).AddDays(-1);

                List <EmployeeLeaveList> leaveList = dbContext.EmployeeLeaveLists
                                                     .Where(x => x.EmployeeId == EmployeeID && x.BranchId == BranchID && x.LeaveTypeId == LeaveType &&
                                                            x.FromDate >= startDate && x.ToDate <= endDate && x.Status != UTILITY.LEAVECANCELLED).ToList();
                decimal?DaysCount = 0;
                foreach (EmployeeLeaveList item in leaveList)
                {
                    DaysCount += item.Days;
                }

                if (leaveTransaction != null)
                {
                    LeaveMaster lMaster = new LeaveMaster();

                    if (LeaveType == lMaster.MEDICALLEAVE(BranchID))
                    {
                        appliedLeave = leave.LeavesPerYear.Value - leaveTransaction.CurrentLeaves;
                        if (leave.IsCarryForward)
                        {
                            eligibleLeaves = (currentYear * leave.LeavesPerYear.Value) - appliedLeave;
                        }
                        else
                        {
                            eligibleLeaves = leave.LeavesPerYear.Value - appliedLeave;
                        }
                    }
                    if (LeaveType == lMaster.CASUALLEAVE(BranchID))
                    {
                        appliedLeave = leave.LeavesPerYear.Value - leaveTransaction.CurrentLeaves;
                        if (leave.IsCarryForward)
                        {
                            eligibleLeaves = (currentYear * leave.LeavesPerYear.Value) - appliedLeave;
                        }
                        else if (DaysCount == 0)
                        {
                            eligibleLeaves = leave.LeavesPerYear.Value;
                        }
                        else
                        {
                            eligibleLeaves = leave.LeavesPerYear.Value - appliedLeave;
                        }
                    }
                    if (LeaveType == lMaster.ANNUALLEAVE(BranchID))
                    {
                        appliedLeave = leave.LeavesPerYear.Value - leaveTransaction.CurrentLeaves;
                        if (leave.IsCarryForward)
                        {
                            eligibleLeaves = (currentYear * leave.LeavesPerYear.Value) - appliedLeave;
                        }
                        else
                        {
                            eligibleLeaves = leave.LeavesPerYear.Value - appliedLeave;
                        }
                    }
                    //else if (LeaveType == UTILITY.PAIDLEAVE)
                    //{
                    //    appliedLeave = leave.LeavesPerYear.Value - leaveTransaction.CurrentLeaves;
                    //    eligibleLeaves = (currentMonth * leave.LeavesPerMonth.Value) - appliedLeave;

                    //}
                    //else if (LeaveType == UTILITY.PAIDLEAVE)
                    //{
                    //    appliedLeave = leave.LeavesPerYear.Value - leaveTransaction.CurrentLeaves;
                    //    eligibleLeaves = (currentMonth * leave.LeavesPerMonth.Value) - appliedLeave;

                    //}
                }
                return(eligibleLeaves);
            }
        }