public static List <EmployeeSalary> FindByEmployee(decimal Id) { List <EmployeeSalary> list = new List <EmployeeSalary>(); string cmdText = "FindEmployeeSalaryByEmployee_sp"; SqlConnection con = new SqlConnection(CommonConstant.CONNECTIONSTRING); SqlCommand cmd = new SqlCommand(cmdText, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("EmpSal_Employee", Id); SqlDataReader dr; con.Open(); dr = cmd.ExecuteReader(); while (dr.Read()) { EmployeeSalary obj = new EmployeeSalary(); obj.EmpSal_Id = Convert.ToDecimal(dr.GetValue(dr.GetOrdinal("EmpSal_Id"))); obj.EmpSal_Employee = Convert.ToDecimal(dr.GetValue(dr.GetOrdinal("EmpSal_Employee"))); obj.EmpSal_EmployeeName = Convert.ToString(dr.GetValue(dr.GetOrdinal("EmpSal_EmployeeName"))); obj.EmpSal_Salary = Convert.ToDecimal(dr.GetValue(dr.GetOrdinal("EmpSal_Salary"))); obj.EmpSal_StartDate = Convert.ToDateTime(dr.GetValue(dr.GetOrdinal("EmpSal_StartDate"))); obj.EmpSal_EndDate = Convert.ToDateTime(dr.GetValue(dr.GetOrdinal("EmpSal_EndDate"))); list.Add(obj); } if (!dr.IsClosed) { dr.Close(); } con.Close(); return(list); }
public static decimal Add(EmployeeSalary obj) { decimal Id = 0; string cmdText = "AddEmployeeSalary_sp"; SqlConnection con = new SqlConnection(CommonConstant.CONNECTIONSTRING); SqlCommand cmd = new SqlCommand(cmdText, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("EmpSal_Employee", obj.EmpSal_Employee); cmd.Parameters.AddWithValue("EmpSal_Salary", obj.EmpSal_Salary); cmd.Parameters.AddWithValue("EmpSal_StartDate", obj.EmpSal_StartDate); cmd.Parameters.AddWithValue("EmpSal_EndDate", obj.EmpSal_EndDate); con.Open(); Id = Convert.ToDecimal(cmd.ExecuteScalar()); con.Close(); return(Id); }
public static int Update(EmployeeSalary obj) { int count = 0; string cmdText = "UpdateEmployeeSalary_sp"; SqlConnection con = new SqlConnection(CommonConstant.CONNECTIONSTRING); SqlCommand cmd = new SqlCommand(cmdText, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("EmpSal_Id", obj.EmpSal_Id); cmd.Parameters.AddWithValue("EmpSal_Employee", obj.EmpSal_Employee); cmd.Parameters.AddWithValue("EmpSal_Salary", obj.EmpSal_Salary); cmd.Parameters.AddWithValue("EmpSal_StartDate", obj.EmpSal_StartDate); cmd.Parameters.AddWithValue("EmpSal_EndDate", obj.EmpSal_EndDate); con.Open(); count = cmd.ExecuteNonQuery(); con.Close(); return(count); }