public List<FinishingShifts> getFinishingShiftsAll() { List<FinishingShifts> finishingShifts = new List<FinishingShifts>(); FinishingShifts f; try { conn = db.openConn(); sb = new StringBuilder(); sb.Remove(0, sb.Length); sb.Append(" SELECT id,name FROM finishing_shifts "); string sql; sql = sb.ToString(); comm = new SqlCommand(); comm.CommandText = sql; comm.CommandType = CommandType.Text; comm.Connection = conn; dr = comm.ExecuteReader(); if (dr.HasRows) { DataTable dt = new DataTable(); dt.Load(dr); foreach (DataRow drw in dt.Rows) { f = new FinishingShifts(); f.ID = Convert.ToInt32(drw["id"].ToString()); f.Name = drw["name"].ToString(); finishingShifts.Add(f); } } } catch (Exception ex) { dr.Close(); conn.Close(); return null; throw ex; } finally { conn.Close(); } return finishingShifts; }
public List<FinishingShifts> GetByShift(string _shift) { List<FinishingShifts> finishingShifts = new List<FinishingShifts>(); FinishingShifts fbl = null; try { conn = db.openConn(); sb = new StringBuilder(); sb.Remove(0, sb.Length); sb.Append(" select name,leader from dbo.finishing_shifts"); sb.Append(" where name ='" + _shift + "'"); string sql; sql = sb.ToString(); comm = new SqlCommand(); comm.CommandText = sql; comm.CommandType = CommandType.Text; comm.Connection = conn; dr = comm.ExecuteReader(); if (dr.HasRows) { DataTable dt = new DataTable(); dt.Load(dr); foreach (DataRow drw in dt.Rows) { fbl = new FinishingShifts(); fbl.Name = drw["name"].ToString(); fbl.Leader = drw["leader"].ToString(); finishingShifts.Add(fbl); } } } catch (Exception ex) { dr.Close(); conn.Close(); return null; throw ex; } finally { conn.Close(); } return finishingShifts; }