예제 #1
0
 private void FillForm(int detailId)
 {
     if (detailId != 0)
     {
         dsSalary ds = new dsSalary();
         dsSalaryTableAdapters.vSalaryFormTableAdapter taSalaryDetail = new dsSalaryTableAdapters.vSalaryFormTableAdapter();
         taSalaryDetail.FillByDetailId(ds.vSalaryForm, detailId);
         var salaryDetail = ds.vSalaryForm.NewvSalaryFormRow();
         if (ds.vSalaryForm.Rows.Count > 0)
         {
             salaryDetail = ds.vSalaryForm[0];
             DateTime date = salaryDetail.SalaryDate;
             tbxSalaryMonth.Text = salaryDetail.SalaryDate.ToString("MMMM") + " " + salaryDetail.SalaryDate.Year.ToString();
             int workingDays = GetNumberOfWorkingDays(SalaryList.FirstOfMonth(date), SalaryList.LastOfMonth(date));
             salaryDetail            = ds.vSalaryForm[0];
             tbxName.Text            = salaryDetail.EmployeeName;
             tbxCode.Text            = salaryDetail.Code.ToString();
             tbxSalary.Text          = (Math.Round(salaryDetail.Salary, 2)).ToString();
             tbxJoiningDate.Text     = salaryDetail.HireDate.ToShortDateString();
             tbxWorkingDays.Text     = workingDays.ToString();
             tbxPresent.Text         = salaryDetail.Presents.ToString();
             tbxAbsents.Text         = salaryDetail.Absents.ToString();
             tbxLeaves.Text          = salaryDetail.Leaves.ToString();
             tbxAbsentDeduction.Text = (Math.Round((salaryDetail.Salary / workingDays) * Convert.ToInt32(tbxAbsents.Text), 2)).ToString();
             tbxTotalSalary.Text     = Math.Round(salaryDetail.Total, 2).ToString();
             tbxOtherDeductions.Text = salaryDetail.IsDeductionsNull() ? "0" : salaryDetail.Deductions.ToString();
             saveValues();
         }
     }
 }
예제 #2
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                dsSalary ds = new dsSalary();
                dsSalaryTableAdapters.SalaryTableAdapter       taSalary       = new dsSalaryTableAdapters.SalaryTableAdapter();
                dsSalaryTableAdapters.SalaryDetailTableAdapter taSalaryDetail = new dsSalaryTableAdapters.SalaryDetailTableAdapter();
                dsSalaryTableAdapters.EmployeeTableAdapter     taEmployee     = new dsSalaryTableAdapters.EmployeeTableAdapter();
                dsSalaryTableAdapters.vSalaryFormTableAdapter  tavSalary      = new dsSalaryTableAdapters.vSalaryFormTableAdapter();
                var salary = ds.Salary.NewSalaryRow();
                taSalary.FillByDate(ds.Salary, currenrtMonth, currentYear);
                if (ds.Salary.Rows.Count > 0)
                {
                    MessageBox.Show("Salary Sheet for this Month Already Exist!");
                }
                else
                {
                    salary.SalaryDate = SmartManger.BAL.Common.DateNow();
                    salary.CreatedOn  = SmartManger.BAL.Common.DateNow();
                    ds.Salary.AddSalaryRow(salary);
                    taSalary.Update(salary);
                    RecordId = salary.SalaryId;
                    DataTable dt    = taEmployee.GetData();
                    int       empid = 0;
                    foreach (DataRow item in dt.Rows)
                    {
                        empid = Convert.ToInt32(item[0]);
                        var salaryDetail = ds.SalaryDetail.NewSalaryDetailRow();
                        salaryDetail.SalaryId   = RecordId;
                        salaryDetail.EmployeeId = Convert.ToInt32(item[0]);
                        salaryDetail.Salary     = Convert.ToDouble(item[1]);
                        salaryDetail.Absents    = Convert.ToInt32(tavSalary.GetAbsents(empid, First, Last));
                        salaryDetail.Presents   = Convert.ToInt32(tavSalary.GetPresents(empid, First, Last));
                        int workingdays = SalaryForm.GetNumberOfWorkingDays(Convert.ToDateTime(First), Convert.ToDateTime(Last));
                        salaryDetail.Leaves          = Convert.ToInt32(tavSalary.GetAL(empid, First, Last)) + Convert.ToInt32(tavSalary.GetCL(empid, First, Last)) + Convert.ToInt32(tavSalary.GetSL(empid, First, Last));
                        salaryDetail.AbsentDeduction = ((salaryDetail.Salary / workingdays) * salaryDetail.Absents);
                        salaryDetail.Total           = ((salaryDetail.Salary / workingdays) * salaryDetail.Presents) + ((salaryDetail.Salary / workingdays) * salaryDetail.Leaves);

                        ds.SalaryDetail.AddSalaryDetailRow(salaryDetail);
                        taSalaryDetail.Update(salaryDetail);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
        private void FillGrid(int recordId, DateTime First, DateTime Last)
        {
            dsSalary ds = new dsSalary();

            dsSalaryTableAdapters.vSalaryFormTableAdapter taSalryDetail = new dsSalaryTableAdapters.vSalaryFormTableAdapter();
            DataTable dt = taSalryDetail.GetData4Grid(recordId, First.ToString(), Last.ToString());

            grdSalaryDetail.Rows.Clear();
            grdSalaryDetail.AutoGenerateColumns = false;
            int count = 0;

            foreach (DataRow item in dt.Rows)
            {
                count++;
                grdSalaryDetail.Rows.Add(item[4], count, item[1], Convert.ToDateTime(item[2]).ToString("dd,MMMM,yyyy"), item[7], item[8], item[9], Math.Round(Convert.ToDouble(item[10]), 2), item[12], Math.Round(Convert.ToDouble(item[13]), 2));
            }
            tbxCount.Text = count.ToString();
        }
예제 #4
0
        private void FillGrid(DateTime Start, DateTime End)
        {
            dsSalary ds = new dsSalary();

            dsSalaryTableAdapters.SalaryTableAdapter taSalary = new dsSalaryTableAdapters.SalaryTableAdapter();
            DataTable dt = taSalary.GetDataByDates(Start.ToString(), End.ToString());

            grdSalary.Rows.Clear();
            grdSalary.AutoGenerateColumns = false;
            int SrNo = 0;

            foreach (DataRow item in dt.Rows)
            {
                SrNo++;
                DateTime date  = Convert.ToDateTime(item[1].ToString());
                string   Year  = date.Year.ToString();
                string   Month = date.ToString("MMMM");
                grdSalary.Rows.Add(item[0], SrNo, Month, Year, item[2].ToString());
            }
            tbxCount.Text = SrNo.ToString();
        }
예제 #5
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            dsSalary ds = new dsSalary();

            dsSalaryTableAdapters.vSalaryFormTableAdapter tasalaryDetail = new dsSalaryTableAdapters.vSalaryFormTableAdapter();
            tasalaryDetail.FillByDetailId(ds.vSalaryForm, detailId);
            var salaryDetail = ds.vSalaryForm.NewvSalaryFormRow();

            if (ds.vSalaryForm.Rows.Count > 0)
            {
                int leaves;
                salaryDetail    = ds.vSalaryForm[0];
                leaves          = salaryDetail.Leaves;
                tbxPresent.Text = tasalaryDetail.GetPresents(salaryDetail.EmployeeId, SalaryList.FirstOfMonth(salaryDetail.SalaryDate).ToString(), SalaryList.LastOfMonth(salaryDetail.SalaryDate).ToString()).ToString();
                tbxAbsents.Text = tasalaryDetail.GetAbsents(salaryDetail.EmployeeId, SalaryList.FirstOfMonth(salaryDetail.SalaryDate).ToString(), SalaryList.LastOfMonth(salaryDetail.SalaryDate).ToString()).ToString();
                leaves          = Convert.ToInt32(tasalaryDetail.GetAL(salaryDetail.EmployeeId, SalaryList.FirstOfMonth(salaryDetail.SalaryDate).ToString(), SalaryList.LastOfMonth(salaryDetail.SalaryDate).ToString()));
                leaves          = leaves + Convert.ToInt32(tasalaryDetail.GetCL(salaryDetail.EmployeeId, SalaryList.FirstOfMonth(salaryDetail.SalaryDate).ToString(), SalaryList.LastOfMonth(salaryDetail.SalaryDate).ToString()));
                leaves          = leaves + Convert.ToInt32(tasalaryDetail.GetSL(salaryDetail.EmployeeId, SalaryList.FirstOfMonth(salaryDetail.SalaryDate).ToString(), SalaryList.LastOfMonth(salaryDetail.SalaryDate).ToString()));
                tbxLeaves.Text  = leaves.ToString();
                saveValues();
            }
        }
예제 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            dsSalary ds = new dsSalary();

            dsSalaryTableAdapters.SalaryDetailTableAdapter taSalryDetail = new dsSalaryTableAdapters.SalaryDetailTableAdapter();
            taSalryDetail.FillById(ds.SalaryDetail, detailId);
            var salarydetail = ds.SalaryDetail.NewSalaryDetailRow();

            if (ds.SalaryDetail.Rows.Count > 0)
            {
                salarydetail            = ds.SalaryDetail[0];
                salarydetail.Presents   = Convert.ToInt32(tbxPresent.Text);
                salarydetail.Absents    = Convert.ToInt32(tbxAbsents.Text);
                salarydetail.Leaves     = Convert.ToInt32(tbxLeaves.Text);
                salarydetail.Deductions = Convert.ToDouble(tbxOtherDeductions.Text);
                salarydetail.Total      = Convert.ToDouble(tbxTotalSalary.Text);

                taSalryDetail.Update(salarydetail);
            }
            MessageBox.Show("Record Updated Successfully!");
            this.Close();
        }