Example #1
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 #2
0
        public EntitySalary GetDetail(int LedgerId)
        {
            try
            {
                EntitySalary lst = (from tbl in objData.tblSalaries
                                    where tbl.IsDelete == false &&
                                    tbl.SalId == LedgerId
                                    select new EntitySalary
                {
                    IsPaymentDone = tbl.IsPaymentDone
                }).FirstOrDefault();

                return(lst);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #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;
            }
        }