Пример #1
0
 public void BindSalary(int Id)
 {
     try
     {
         List <EntityAllowanceDeduction> lst = mobjSalBLL.GetDeductionsForEdit(Id);
         DgvAllowance.DataSource = lst;
         DgvAllowance.DataBind();
         Session["FromEdit"] = lst;
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Пример #2
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);
        }
Пример #3
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;
            }
        }
Пример #4
0
        protected void btnAllowAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlAllowance.SelectedIndex > 0)
                {
                    List <EntityAllowanceDeduction> lst = null;
                    //DgvAllowance.DataSource = null;
                    //DgvAllowance.DataBind();
                    //dgvDeduction.DataSource = null;
                    //dgvDeduction.DataBind();
                    if (Convert.ToString(Session["MyFlag"]).Equals("ADD", StringComparison.CurrentCultureIgnoreCase))
                    {
                        lst = (List <EntityAllowanceDeduction>)Session["allowance"];
                    }
                    else
                    {
                        lst = (List <EntityAllowanceDeduction>)Session["FromEdit"];
                    }
                    if (lst != null)
                    {
                        int cnt = (from tbl in lst
                                   where tbl.AllowDedId == Convert.ToInt32(ddlAllowance.SelectedValue)
                                   select tbl).ToList().Count;

                        if (cnt > 0)
                        {
                            lblMsg.Text = "This Allowance is Already Added";
                        }
                        else
                        {
                            lst.Add(new EntityAllowanceDeduction()
                            {
                                Description = Convert.ToString(ddlAllowance.SelectedItem.Text), Amount = Convert.ToDecimal(txtAllowAmount.Text), AllowDedId = Convert.ToInt32(ddlAllowance.SelectedValue), SalDetail_Id = 0
                            });
                            if (Convert.ToString(Session["MyFlag"]).Equals("ADD", StringComparison.CurrentCultureIgnoreCase))
                            {
                                Session["allowance"] = lst;
                            }
                            else
                            {
                                Session["FromEdit"] = lst;
                            }
                            DgvAllowance.DataSource = lst;
                            DgvAllowance.DataBind();
                            txtNetAmount.Text          = Convert.ToString(Convert.ToDecimal(txtNetAmount.Text) + Convert.ToDecimal(txtAllowAmount.Text));
                            ddlAllowance.SelectedIndex = 0;
                            txtAllowAmount.Text        = string.Empty;
                        }
                    }
                    else
                    {
                        lst.Add(new EntityAllowanceDeduction()
                        {
                            Description = Convert.ToString(ddlAllowance.SelectedItem.Text), Amount = Convert.ToDecimal(txtAllowAmount.Text), AllowDedId = Convert.ToInt32(ddlAllowance.SelectedValue), SalDetail_Id = 0
                        });
                        if (Convert.ToString(Session["MyFlag"]).Equals("ADD", StringComparison.CurrentCultureIgnoreCase))
                        {
                            Session["allowance"] = lst;
                        }
                        else
                        {
                            Session["FromEdit"] = lst;
                        }
                        DgvAllowance.DataSource = lst;
                        DgvAllowance.DataBind();
                        txtNetAmount.Text          = Convert.ToString(Convert.ToDecimal(txtNetAmount.Text) + Convert.ToDecimal(txtAllowAmount.Text));
                        ddlAllowance.SelectedIndex = 0;
                        txtAllowAmount.Text        = string.Empty;
                    }
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;
            }
        }
Пример #5
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                ImageButton imgDelete = (ImageButton)sender;
                GridViewRow row       = (GridViewRow)imgDelete.NamingContainer;
                Session["Delete_Charge"] = Convert.ToInt32(row.Cells[1].Text);
                decimal amt = Convert.ToDecimal(row.Cells[3].Text);
                List <EntityAllowanceDeduction> lstFinal = new List <EntityAllowanceDeduction>();
                bool IsRemoveBasic = mobjSalBLL.CheckIsBasic(Convert.ToInt32(row.Cells[1].Text));
                if (IsRemoveBasic)
                {
                    lblMsg.Text = "You are not allowed to remove Basic.";
                    return;
                }
                if (Session["MyFlag"] == "ADD")
                {
                    List <EntityAllowanceDeduction> lst = (List <EntityAllowanceDeduction>)Session["allowance"];
                    foreach (EntityAllowanceDeduction item in lst)
                    {
                        if (item.AllowDedId != Convert.ToInt32(row.Cells[1].Text))
                        {
                            lstFinal.Add(item);
                        }
                    }
                    Session["allowance"]    = lstFinal;
                    txtNetAmount.Text       = Convert.ToString(Convert.ToDecimal(txtNetAmount.Text) - amt);
                    DgvAllowance.DataSource = Session["allowance"];
                    DgvAllowance.DataBind();
                }
                if (Session["MyFlag"] == "Edit")
                {
                    List <EntityAllowanceDeduction> lst = (List <EntityAllowanceDeduction>)Session["FromEdit"];
                    if (IsRemoveBasic)
                    {
                        lblMsg.Text = "You are not allowed to remove Basic.";
                    }
                    foreach (EntityAllowanceDeduction item in lst)
                    {
                        if (item.AllowDedId != Convert.ToInt32(row.Cells[1].Text))
                        {
                            item.IsDelete = false;
                        }
                        else
                        {
                            item.IsDelete = true;
                        }

                        lstFinal.Add(item);
                    }
                    Session["FromEdit"] = lstFinal;
                    txtNetAmount.Text   = Convert.ToString(Convert.ToDecimal(txtNetAmount.Text) - amt);
                }
                DgvAllowance.DataSource = lstFinal.Where(p => p.IsDelete == false).ToList();
                DgvAllowance.DataBind();
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;
            }
        }