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); } }
private void grdSalaryDetail_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { try { if (grdSalaryDetail.CurrentCell.RowIndex < Convert.ToInt32(tbxCount.Text)) { DataGridViewRow dr = grdSalaryDetail.SelectedRows[0]; int recordid = Convert.ToInt32(dr.Cells["SalarydetailId"].Value.ToString()); SalaryForm SalaryDetailForm = new SalaryForm(recordid); SalaryDetailForm.ShowDialog(); } FillGrid(selectedRecordId, First, Last); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { SalaryForm slForm = new SalaryForm(); slForm.Show(); }