public EmployeeSalaryPayment GetLastEmployeeSalary() { SqlConnection connection = new SqlConnection(connectionString); string query = "SELECT TOP 1 * FROM tbl_employeeSalaryPayment ORDER BY id DESC"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); EmployeeSalaryPayment employeeSalaryPayment = new EmployeeSalaryPayment(); while (reader.Read()) { employeeSalaryPayment.EmployeeSalaryPaymentId = int.Parse(reader["id"].ToString()); employeeSalaryPayment.EmployeeDate = reader["date"].ToString(); employeeSalaryPayment.EmployeeYear = Convert.ToDouble(reader["year"].ToString()); employeeSalaryPayment.EmployeeMonth = reader["month"].ToString(); employeeSalaryPayment.EmployeeName = reader["employee_id"].ToString(); employeeSalaryPayment.PaymentMode = reader["payment_mode"].ToString(); employeeSalaryPayment.BankName = reader["bank_id"].ToString(); employeeSalaryPayment.CheckNo = reader["check_no"].ToString(); employeeSalaryPayment.CheckDate = reader["check_date"].ToString(); employeeSalaryPayment.Amount = Convert.ToDouble(reader["amount"].ToString()); employeeSalaryPayment.Remarks = reader["remarks"].ToString(); } reader.Close(); connection.Close(); return(employeeSalaryPayment); }
protected void saveButton_Click(object sender, EventArgs e) { EmployeeSalaryPayment employeeSalaryPayment = new EmployeeSalaryPayment(); employeeSalaryPayment.EmployeeDate = employeeDateTextBox.Value; string year = yearTextBox.Text; employeeSalaryPayment.EmployeeMonth = monthTypeDropDownList.SelectedValue; employeeSalaryPayment.EmployeeId = int.Parse(employeeNameDropDownList.SelectedValue); employeeSalaryPayment.PaymentMode = paymentModeDropDownList.SelectedValue; employeeSalaryPayment.BankId = int.Parse(bankNameDropDownList.SelectedValue); employeeSalaryPayment.CheckNo = checkNoTextBox.Text; employeeSalaryPayment.CheckDate = checkDateTextBox.Value; string amount = amountTextBox.Text; employeeSalaryPayment.Remarks = remarksDropDownList.SelectedValue; if (employeeDateTextBox.Value == "" || yearTextBox.Text == "" || monthTypeDropDownList.Text == "" || paymentModeDropDownList.Text == "" || checkNoTextBox.Text == "" || checkDateTextBox.Value == "" || amountTextBox.Text == "" || remarksDropDownList.Text == "") { messageLabel.InnerText = "All Fields are Required!!"; } else { employeeSalaryPayment.EmployeeYear = Convert.ToDouble(year); employeeSalaryPayment.Amount = Convert.ToDouble(amount); messageLabel.InnerText = employeeSalaryPaymentManager.Save(employeeSalaryPayment); } ClearTextBoxes(); }
public string Save(EmployeeSalaryPayment employeeSalaryPayment) { if (employeeSalaryPaymentGateway.Insert(employeeSalaryPayment) > 0) { return("Saved Successfully!!"); } return("Could Not Save Data in Database!!"); }
protected void lastButton_Click(object sender, EventArgs e) { EmployeeSalaryPayment employeeSalaryPayment = employeeSalaryPaymentManager.GetLastEmployeeSalary(); employeeDateTextBox.Value = employeeSalaryPayment.EmployeeDate; yearTextBox.Text = employeeSalaryPayment.EmployeeYear.ToString(); monthTypeDropDownList.Text = employeeSalaryPayment.EmployeeMonth; employeeNameDropDownList.Text = employeeSalaryPayment.EmployeeName; paymentModeDropDownList.Text = employeeSalaryPayment.PaymentMode; bankNameDropDownList.Text = employeeSalaryPayment.BankName; checkNoTextBox.Text = employeeSalaryPayment.CheckNo; checkDateTextBox.Value = employeeSalaryPayment.CheckDate; amountTextBox.Text = employeeSalaryPayment.Amount.ToString(); remarksDropDownList.Text = employeeSalaryPayment.Remarks; }
public int Insert(EmployeeSalaryPayment employeeSalaryPayment) { SqlConnection connection = new SqlConnection(connectionString); string query = "INSERT INTO tbl_employeeSalaryPayment VALUES('" + employeeSalaryPayment.EmployeeDate + "','" + employeeSalaryPayment.EmployeeYear + "','" + employeeSalaryPayment.EmployeeMonth + "','" + employeeSalaryPayment.EmployeeId + "','" + employeeSalaryPayment.PaymentMode + "','" + employeeSalaryPayment.BankId + "','" + employeeSalaryPayment.CheckNo + "','" + employeeSalaryPayment.CheckDate + "','" + employeeSalaryPayment.Amount + "','" + employeeSalaryPayment.Remarks + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); return(rowAffected); }