public bool updatePayroll(Payroll obj) { string insertCommand = "update payroll set SalaryAmount=@SalaryAmount,BonusAmount=@BonusAmount " + " where EmployeeId=@EmployeeId and departmentId=@departmentId "; SqlCommand command = new SqlCommand(insertCommand); SqlParameter idParameter = new SqlParameter("@EmployeeId", SqlDbType.NVarChar, 50); idParameter.Value = obj.employeeId; SqlParameter SalaryAmountParameter = new SqlParameter("@SalaryAmount", SqlDbType.Int); SalaryAmountParameter.Value = obj.SalaryAmount; SqlParameter BonusAmountParameter = new SqlParameter("@BonusAmount", SqlDbType.Int); BonusAmountParameter.Value = obj.bonusAmount; SqlParameter departmentIdParameter = new SqlParameter("@departmentId", SqlDbType.NVarChar, 50); departmentIdParameter.Value = obj.departmentId; command.Parameters.Add(idParameter); command.Parameters.Add(SalaryAmountParameter); command.Parameters.Add(BonusAmountParameter); command.Parameters.Add(departmentIdParameter); if (da.Execution(command)) { return true; } else { return false; } }
public bool insertPayroll(Payroll obj) { string insertCommand = "INSERT INTO payroll (EmployeeId,SalaryAmount,BonusAmount,departmentId) " + "VALUES (@EmployeeId,@SalaryAmount,@BonusAmount,@departmentId)"; SqlCommand command = new SqlCommand(insertCommand); SqlParameter idParameter = new SqlParameter("@EmployeeId", SqlDbType.NVarChar, 50); idParameter.Value = obj.employeeId; SqlParameter SalaryAmountParameter = new SqlParameter("@SalaryAmount", SqlDbType.Int); SalaryAmountParameter.Value = obj.SalaryAmount; SqlParameter BonusAmountParameter = new SqlParameter("@BonusAmount", SqlDbType.Int); BonusAmountParameter.Value = obj.bonusAmount; SqlParameter departmentIdParameter = new SqlParameter("@departmentId", SqlDbType.NVarChar, 50); departmentIdParameter.Value = obj.departmentId; command.Parameters.Add(idParameter); command.Parameters.Add(SalaryAmountParameter); command.Parameters.Add(BonusAmountParameter); command.Parameters.Add(departmentIdParameter); if (da.Execution(command)) { return true; } else { return false; } }
public bool deletePayroll(Payroll obj) { string insertCommand = "delete from payroll " + "where EmployeeId= @EmployeeId and departmentId=@departmentId "; SqlCommand command = new SqlCommand(insertCommand); SqlParameter employeeIdParameter = new SqlParameter("@EmployeeId", SqlDbType.NVarChar, 50); employeeIdParameter.Value = obj.employeeId; SqlParameter departmentIdParameter = new SqlParameter("@departmentId", SqlDbType.NVarChar, 50); departmentIdParameter.Value = obj.departmentId; command.Parameters.Add(employeeIdParameter); command.Parameters.Add(departmentIdParameter); if (da.Execution(command)) { return true; } else { return false; } }
public Payroll GetAllPayroll(string eid,string did) { Payroll pn=new Payroll(); string query = "select SalaryAmount,BonusAmount from payroll where EmployeeId='" + eid + "' and DepartmentId='"+ did + "'"; SqlCommand cmd = da.GetCommand(query); cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { pn.SalaryAmount = reader.GetInt32(0); pn.bonusAmount = reader.GetInt32(1); } return pn; }
public List<Payroll> GetAllPayrollListEmployee(string eid) { List<Payroll> payrollList = new List<Payroll>(); string query = "select employeeId,SalaryAmount,BonusAmount,departmentId from payroll where employeeID='"+ eid +"'"; SqlCommand cmd = da.GetCommand(query); cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Payroll p = new Payroll(); p.employeeId = reader.GetString(0); p.SalaryAmount = reader.GetInt32(1); p.bonusAmount = reader.GetInt32(2); p.departmentId = reader.GetString(3); payrollList.Add(p); } return payrollList; }