public async Task <string> AddUpdateSalary(SalaryDomainModel salary)
        {
            string status = "";

            if (salary.sal_id > 0)
            {
                tblSalary salaryToUpdate = await salaryRepository.SingleOrDefault(s => s.sal_id == salary.sal_id);

                if (salaryToUpdate != null)
                {
                    salaryToUpdate.date   = salary.date;
                    salaryToUpdate.emp_id = salary.emp_id;
                    salaryToUpdate.amount = salary.amount;
                    await salaryRepository.Update(salaryToUpdate);

                    status = "updated";
                }
            }
            else
            {
                tblSalary salaryToAdd = new tblSalary();
                salaryToAdd.date   = salary.date;
                salaryToAdd.emp_id = salary.emp_id;
                salaryToAdd.amount = salary.amount;
                await salaryRepository.Insert(salaryToAdd);

                status = "added";
            }
            return(status);
        }
 public void AddEmployee(DAL.Employee e, tblSalary s)
 {
     using (OriginatorEntities db = new OriginatorEntities())
     {
         db.Employees.Add(e);
         db.SaveChanges();
         s.EmployeeId = e.ID;
         db.tblSalaries.Add(s);
         db.SaveChanges();
     }
 }
Example #3
0
 public int Save(tblSalary sal)
 {
     try
     {
         int?SalId = 0;
         objData.STP_Insert_tblSalary(Convert.ToInt32(sal.EmpId), Convert.ToDateTime(sal.SalDate), Convert.ToInt32(sal.No_of_Days), Convert.ToInt32(sal.LeavesTaken), Convert.ToInt32(sal.Attend_Days), Convert.ToString(sal.Sal_Month), Convert.ToDecimal(sal.NetPayment), Convert.ToBoolean(sal.IsPaymentDone), Convert.ToInt32(sal.OTHours), ref SalId);
         return(SalId.Value);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
 public bool Add(tblSalary obj)
 {
     try
     {
         repository.tblSalaries.Add(obj);
         repository.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #5
0
 protected void BtnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         Session["MyFlag"] = "Edit";
         ImageButton imgEdit = (ImageButton)sender;
         GridViewRow row     = (GridViewRow)imgEdit.NamingContainer;
         Session["LedgerId"] = Convert.ToInt32(dgvSalary.DataKeys[row.RowIndex].Value);
         tblSalary    sal = new tblSalary();
         EntitySalary lst = mobjSalBLL.GetDetail(Convert.ToInt32(Session["LedgerId"]));
         if (lst.IsPaymentDone == true)
         {
             lblMessage.Text = "Payment is Done.You Cannot Edit Details....";
             return;
         }
         else
         {
             ListItem item = ddlEmployee.Items.FindByText(Convert.ToString(row.Cells[1].Text));
             ddlEmployee.SelectedValue = item.Value;
             ddlEmployee_SelectedIndexChanged(sender, e);
             txtDos.Text         = string.Format("{0:dd/MM/yyyy}", row.Cells[2].Text).ToString();
             txtMonth.Text       = string.Format("{0:MMM/yyyy}", row.Cells[3].Text).ToString();
             txtDays.Text        = Convert.ToString(row.Cells[4].Text);
             txtAttendDays.Text  = Convert.ToString(row.Cells[5].Text);
             txtLeavesTaken.Text = Convert.ToString(row.Cells[6].Text);
             txtOTHours.Text     = Convert.ToString(row.Cells[7].Text);
             txtNetAmount.Text   = Convert.ToString(row.Cells[8].Text);
             ddlEmployee.Enabled = false;
             lblbaseSal.Enabled  = false;
             txtDoj.Enabled      = false;
             txtDos.Enabled      = false;
             //calDos.Enabled = false;
             txtMonth.Enabled       = false;
             txtDays.Enabled        = false;
             txtAttendDays.Enabled  = false;
             txtLeavesTaken.Enabled = true;
             txtOTHours.Enabled     = true;
             BindSalary(Convert.ToInt32(Session["LedgerId"]));
             BindSalaryDeduction(Convert.ToInt32(Session["LedgerId"]));
             BtnSave.Visible   = false;
             btnUpdate.Visible = true;
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
     MultiView1.SetActiveView(View2);
 }
Example #6
0
 public ActionResult AddEmployee(VMEmployee Employee)
 {
     try
     {
         if (ModelState.IsValid)
         {
             tblUser user = Session[WebUtil.CURRENT_USER] as tblUser;
             if (!(user != null))
             {
                 return(RedirectToAction("RedirectToLogin", "user"));
             }
             Employee e   = new Employee();
             long     uno = DateTime.Now.Ticks;
             if (Employee.ImageUrl != null)
             {
                 HttpPostedFileBase file = Employee.ImageUrl;
                 if (!string.IsNullOrWhiteSpace(file.FileName))
                 {
                     string url  = $"~/DataImages/Employee/{uno}{file.FileName.Substring(file.FileName.LastIndexOf("."))}";
                     string path = Request.MapPath(url);
                     file.SaveAs(path);
                     e.ImageUrl = url;
                 }
             }
             e.CompanyId   = user.CompanyId;
             e.FirstName   = Employee.FirstName;
             e.LastName    = Employee.LastName;
             e.Designation = Employee.Designation;
             e.CreatedBy   = user.Id;
             e.CreatedDate = DateTime.Now;
             tblSalary s = new tblSalary();
             s.Salary      = Employee.Salary;
             s.CreatedBy   = user.CreatedBy;
             s.CreatedDate = DateTime.Now;
             s.EmployeeId  = 0;
             new EmployeeHandler().AddEmployee(e, s);
             return(JavaScript("showMessage('success', 'Employee added Successfully','bottom-right','Employee', 'Manage')"));
         }
         else
         {
             return(JavaScript("showMessage('error', 'All fields are required, Please try again','bottom-right','Employee', 'Manage')"));
         }
     }
     catch (Exception ex)
     {
         return(JavaScript("showMessage('error', 'Failed to Add Employee, Please Contact to Administrator','bottom-right','Employee', 'Manage')"));
     }
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            tblSalary result = get_Data_From_Form();

            result.SalaryId = Int32.Parse(Request.QueryString["id"]);
            Salary repository = new Salary();

            if (repository.Update(result))
            {
                Response.Redirect("~/pages/salary.aspx");
            }
            else
            {
                this.ShowErrorNotification("Error occured");
            }
        }
        private void Get_Salary_Data_By_QueryString()
        {
            // Set up environment
            gridSalary.Visible = false;
            btnInsert.Visible  = false;
            btnUpdate.Visible  = true;
            linkBack.Visible   = true;


            Salary    repository = new Salary();
            tblSalary result     = repository.Get(Int32.Parse(Request.QueryString["id"]));

            cbEmployee.SelectedValue = result.EmployeeId.ToString();
            txtStartDate.Text        = result.StartDate.ToShortDateString();
            txtEndDate.Text          = result.EndDate.ToShortDateString();
            txtTotalHours.Text       = result.TotalHours.ToString();
            lblTotalSalary.Text      = "$" + result.TotalSalary.ToString();
        }
Example #9
0
 public bool Delete(int id)
 {
     try
     {
         tblSalary result = Get(id);
         if (result != null)
         {
             result.Deleted = true;
             repository.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #10
0
 public bool Update(tblSalary obj)
 {
     try
     {
         tblSalary result = Get(obj.SalaryId);
         if (result != null)
         {
             repository.Entry(result).CurrentValues.SetValues(obj);
             repository.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #11
0
        public int?Save(tblSalary sal, List <tblSalaryDetail> lst)
        {
            int?SalId = 0;

            try
            {
                objData.STP_Insert_tblSalary(Convert.ToInt32(sal.EmpId), Convert.ToDateTime(sal.SalDate), Convert.ToInt32(sal.No_of_Days), Convert.ToInt32(sal.LeavesTaken), Convert.ToInt32(sal.Attend_Days), Convert.ToString(sal.Sal_Month), Convert.ToDecimal(sal.NetPayment), Convert.ToBoolean(sal.IsPaymentDone), Convert.ToInt32(sal.OTHours), ref SalId);
                foreach (tblSalaryDetail item in lst)
                {
                    item.SalId = Convert.ToInt32(SalId);
                    objData.tblSalaryDetails.InsertOnSubmit(item);
                }
                objData.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(SalId);
        }
Example #12
0
        public void Update(tblSalary obj, List <tblSalaryDetail> lst)
        {
            try
            {
                tblSalary objcurrent = (from tbl in objData.tblSalaries
                                        where tbl.SalId == obj.SalId
                                        select tbl).FirstOrDefault();
                if (objcurrent != null)
                {
                    objcurrent.IsPaymentDone = obj.IsPaymentDone;
                    objcurrent.Attend_Days   = obj.Attend_Days;
                    objcurrent.LeavesTaken   = obj.LeavesTaken;
                    objcurrent.OTHours       = obj.OTHours;
                    objcurrent.NetPayment    = obj.NetPayment;
                }

                foreach (tblSalaryDetail item in lst)
                {
                    tblSalaryDetail objsal = (from tbl in objData.tblSalaryDetails
                                              where tbl.SalId == item.SalId &&
                                              tbl.AllowanceDeduction_Id == item.AllowanceDeduction_Id &&
                                              tbl.IsDelete == false
                                              select tbl).FirstOrDefault();
                    if (objsal != null)
                    {
                        objsal.Amount   = item.Amount;
                        objsal.IsDelete = item.IsDelete;
                    }
                    else
                    {
                        objsal = item;
                        objData.tblSalaryDetails.InsertOnSubmit(objsal);
                    }
                }
                objData.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #13
0
 public bool ValidateAllocation(tblSalary sal)
 {
     try
     {
         var res = (from tbl in objData.tblSalaries
                    where tbl.EmpId == sal.EmpId &&
                    tbl.Sal_Month == sal.Sal_Month
                    select tbl).FirstOrDefault();
         if (res != null)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void UpdateEmployee(long EmployeeId, DAL.Employee e, tblSalary s)
        {
            using (OriginatorEntities db = new OriginatorEntities())
            {
                DAL.Employee found = db.Employees.Find(EmployeeId);
                if (!string.IsNullOrWhiteSpace(e.FirstName))
                {
                    found.FirstName = e.FirstName;
                }
                if (!string.IsNullOrWhiteSpace(e.LastName))
                {
                    found.LastName = e.LastName;
                }
                if (!string.IsNullOrWhiteSpace(e.Designation))
                {
                    found.Designation = e.Designation;
                }
                if (!string.IsNullOrWhiteSpace(e.ImageUrl))
                {
                    found.ImageUrl = e.ImageUrl;
                }
                if (e.ModifiedBy != null && e.ModifiedBy > 0)
                {
                    found.ModifiedBy = e.ModifiedBy;
                }
                if (!string.IsNullOrWhiteSpace(e.ModifiedDate.ToString()))
                {
                    found.ModifiedDate = e.ModifiedDate;
                }

                // Get Latest Salary
                // If Latest salary is equal to parameter wali salary then then you dont want to change anything
                // other wise add new entry to salary table
                db.SaveChanges();
            }
        }
Example #15
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                decimal     totalAllowances = 0;
                decimal     totalDed        = 0;
                tblEmployee objFac          = mobjSalBLL.GetEmployee(Convert.ToInt32(ddlEmployee.SelectedValue));
                if (objFac != null)
                {
                    tblSalary obj = new tblSalary();
                    if (chkIspayment.Checked == true)
                    {
                        obj.IsPaymentDone = true;
                    }
                    else
                    {
                        obj.IsPaymentDone = false;
                    }
                    if (mobjSalBLL.ValidateAllocation(obj, Convert.ToInt32(Session[" LedgerId"])))
                    {
                        tblSalary sal = new tblSalary();
                        List <tblSalaryDetail> lst = new List <tblSalaryDetail>();
                        foreach (GridViewRow item in DgvAllowance.Rows)
                        {
                            lst.Add(new tblSalaryDetail {
                                SalDetail_Id = Convert.ToInt32(item.Cells[0].Text), SalDate = Convert.ToDateTime(txtDos.Text), SalId = Convert.ToInt32(Session["LedgerId"]), AllowanceDeduction_Id = Convert.ToInt32(item.Cells[1].Text), IsDelete = false, Amount = Convert.ToDecimal(item.Cells[3].Text)
                            });
                            totalAllowances += Convert.ToDecimal(item.Cells[3].Text);
                        }
                        foreach (GridViewRow item in dgvDeduction.Rows)
                        {
                            lst.Add(new tblSalaryDetail {
                                SalDetail_Id = Convert.ToInt32(item.Cells[0].Text), SalDate = Convert.ToDateTime(txtDos.Text), SalId = Convert.ToInt32(Session["LedgerId"]), AllowanceDeduction_Id = Convert.ToInt32(item.Cells[1].Text), IsDelete = false, Amount = Convert.ToDecimal(item.Cells[3].Text)
                            });
                            totalDed += Convert.ToDecimal(item.Cells[3].Text);
                        }
                        //List<tblSalaryDetail> lstDeletedAllDed = new List<tblSalaryDetail>();
                        List <EntityAllowanceDeduction> lstDel    = (List <EntityAllowanceDeduction>)Session["FromEdit"];
                        List <EntityAllowanceDeduction> lstDelDed = (List <EntityAllowanceDeduction>)Session["FromEditDeduction"];
                        foreach (EntityAllowanceDeduction item in lstDel)
                        {
                            if (item.IsDelete)
                            {
                                lst.Add(new tblSalaryDetail()
                                {
                                    AllowanceDeduction_Id = item.AllowDedId, SalId = Convert.ToInt32(Session["LedgerId"]), IsDelete = item.IsDelete, Amount = item.Amount
                                });
                            }
                        }
                        foreach (EntityAllowanceDeduction item in lstDelDed)
                        {
                            if (item.IsDelete)
                            {
                                lst.Add(new tblSalaryDetail()
                                {
                                    AllowanceDeduction_Id = item.AllowDedId, SalId = Convert.ToInt32(Session["LedgerId"]), IsDelete = item.IsDelete, Amount = item.Amount
                                });
                            }
                        }

                        decimal netPay       = totalAllowances - totalDed;
                        decimal dayPayment   = netPay / Convert.ToInt32(txtDays.Text);
                        decimal hours        = dayPayment / 8;
                        decimal Payment      = Convert.ToInt32(txtOTHours.Text) * decimal.Round(hours, 2);
                        decimal monthpayment = dayPayment * Convert.ToDecimal(txtAttendDays.Text);
                        decimal NetPayment   = monthpayment + Payment;
                        obj.IsPaymentDone = chkIspayment.Checked;
                        obj.SalId         = Convert.ToInt32(Session["LedgerId"]);
                        obj.LeavesTaken   = Convert.ToInt32(txtLeavesTaken.Text);
                        obj.OTHours       = Convert.ToInt32(txtOTHours.Text);
                        obj.Attend_Days   = Convert.ToInt32(txtAttendDays.Text);
                        obj.NetPayment    = decimal.Round(NetPayment, 0);
                        mobjSalBLL.Update(obj, lst);
                        lblMessage.Text = "Record Updated successfully.";
                        List <EntityAllowanceDeduction> lstallow = new List <EntityAllowanceDeduction>();
                        List <EntityAllowanceDeduction> lstded   = new List <EntityAllowanceDeduction>();
                        DgvAllowance.DataSource = lstallow;
                        DgvAllowance.DataBind();
                        dgvDeduction.DataSource = lstded;
                        dgvDeduction.DataBind();
                        BindSalaryAllocation();
                        Session["FromEditDeduction"] = null;
                        Session["FromEdit"]          = null;
                    }
                }
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
            MultiView1.SetActiveView(View1);
        }
Example #16
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool flag = false;
                foreach (GridViewRow item in DgvAllowance.Rows)
                {
                    bool IsBasic = mobjSalBLL.CheckIsBasic(Convert.ToInt32(item.Cells[1].Text));
                    if (IsBasic)
                    {
                        flag = true;
                        break;
                    }
                    else
                    {
                        flag = false;
                    }
                }
                if (!flag)
                {
                    lblMsg.Text = "You shuould be add Basic in Salary";
                    return;
                }
                tblSalary           sal    = new tblSalary();
                EntitySalaryDetails obj    = new EntitySalaryDetails();
                EntitySalary        salobj = new EntitySalary();
                sal.EmpId       = Convert.ToInt32(ddlEmployee.SelectedValue);
                sal.SalDate     = Convert.ToDateTime(txtDos.Text);
                sal.Sal_Month   = string.Format("{0:MMM-yyyy}", txtMonth.Text);
                sal.No_of_Days  = Convert.ToInt32(txtDays.Text);
                sal.Attend_Days = Convert.ToInt32(txtAttendDays.Text);
                sal.LeavesTaken = Convert.ToInt32(txtLeavesTaken.Text);
                sal.OTHours     = Convert.ToInt32(txtOTHours.Text);
                decimal day     = Convert.ToDecimal(txtNetAmount.Text) / Convert.ToDecimal(txtDays.Text);
                decimal month   = day * Convert.ToDecimal(txtAttendDays.Text);
                decimal hour    = day / 8;
                decimal tothour = Convert.ToInt32(txtOTHours.Text) * decimal.Round(hour, 2);
                decimal payment = Convert.ToDecimal(month + tothour);
                txtNetAmount.Text = Convert.ToString(payment);
                sal.NetPayment    = decimal.Round(payment, 0);

                if (chkIspayment.Checked == true)
                {
                    sal.IsPaymentDone = true;
                }
                else
                {
                    sal.IsPaymentDone = false;
                }
                tblEmployee objFac = mobjSalBLL.GetEmployee(Convert.ToInt32(ddlEmployee.SelectedValue));
                if (objFac != null)
                {
                    tblSalary objExist = mobjSalBLL.CheckExistRecord(objFac.PKId, Convert.ToString(txtMonth.Text));
                    if (objExist == null)
                    {
                        if (mobjSalBLL.ValidateAllocation(sal))
                        {
                            List <tblSalaryDetail> lst = new List <tblSalaryDetail>();
                            foreach (GridViewRow item in DgvAllowance.Rows)
                            {
                                lst.Add(new tblSalaryDetail {
                                    SalDate = Convert.ToDateTime(txtDos.Text), AllowanceDeduction_Id = Convert.ToInt32(item.Cells[1].Text), IsDelete = false, Amount = Convert.ToDecimal(item.Cells[3].Text)
                                });
                            }
                            foreach (GridViewRow item in dgvDeduction.Rows)
                            {
                                lst.Add(new tblSalaryDetail {
                                    SalDate = Convert.ToDateTime(txtDos.Text), AllowanceDeduction_Id = Convert.ToInt32(item.Cells[1].Text), IsDelete = false, Amount = Convert.ToDecimal(item.Cells[3].Text)
                                });
                            }
                            int SalId = Convert.ToInt32(mobjSalBLL.Save(sal, lst));
                            lblMessage.Text = "Record Saved Successfully.....";
                            Clear();
                        }
                    }
                    else
                    {
                        Clear();
                        List <EntityAllowanceDeduction> lst    = new List <EntityAllowanceDeduction>();
                        List <EntityAllowanceDeduction> lstded = new List <EntityAllowanceDeduction>();
                        DgvAllowance.DataSource = lst;
                        DgvAllowance.DataBind();
                        dgvDeduction.DataSource = lstded;
                        dgvDeduction.DataBind();
                        lblMsg.Text = string.Empty;
                        MultiView1.SetActiveView(View1);
                        lblMessage.Text = "Salary Is Already Allocated To Employee!!";
                    }
                }
                else
                {
                    lblMsg.Text = "Invalid Employee";
                }
                Session["allowance"] = new List <EntityAllowanceDeduction>();
                Session["Deduction"] = new List <EntityAllowanceDeduction>();
                BindSalaryAllocation();
                MultiView1.SetActiveView(View1);
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;
            }
        }