//public static SqlConnection con = new SqlConnection(); //public static SqlCommand cmd = new SqlCommand(); public static List <ENTVWPRJPROJECT> GetAllListProjects() { con = SQL.GetConnection(); cmd = SQL.SetCommand("SELECT * FROM VW_PRJ_Project ORDER BY NAME", con); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); ENTVWPRJPROJECT project = null; List <ENTVWPRJPROJECT> projectlist = new List <ENTVWPRJPROJECT>(); while (dr.Read()) { project = new ENTVWPRJPROJECT(Guid.Parse(dr["ID"].ToString()), dr["NAME"].ToString(), dr["DESCRIPTION"].ToString(), Byte.Parse(dr["TYPEPROJECTSTATUSID"].ToString()), Guid.Parse(dr["FIRMID"].ToString()), bool.Parse(dr["TYPEPROJECTSTATUSISOPEN"].ToString()), dr["TYPEPROJECTSTATUSNAME"].ToString(), dr["FIRMNAME"].ToString(), dr["FIRMDESCRIPTION"].ToString(), byte.Parse(dr["FIRMCITYID"].ToString()), Int16.Parse(dr["FIRMDISTRICTID"].ToString()), dr["FIRMADDRESS"].ToString(), dr["CITYNAME"].ToString(), dr["DISTRICTNAME"].ToString()); projectlist.Add(project); } con.Close(); return(projectlist); }
public static ENTVWPRJPROJECT GetProjectDetail(Guid ID) { con = SQL.GetConnection(); cmd = SQL.SetCommand("SELECT * FROM VW_PRJ_Project WHERE ID=@ID", con); cmd.Parameters.AddWithValue("@ID", ID); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); ENTVWPRJPROJECT prj = null; while (dr.Read()) { prj = new ENTVWPRJPROJECT(Guid.Parse(dr["ID"].ToString()), dr["NAME"].ToString(), dr["DESCRIPTION"].ToString(), Byte.Parse(dr["TYPEPROJECTSTATUSID"].ToString()), Guid.Parse(dr["FIRMID"].ToString()), bool.Parse(dr["TYPEPROJECTSTATUSISOPEN"].ToString()), dr["TYPEPROJECTSTATUSNAME"].ToString(), dr["FIRMNAME"].ToString(), dr["FIRMDESCRIPTION"].ToString(), byte.Parse(dr["FIRMCITYID"].ToString()), Int16.Parse(dr["FIRMDISTRICTID"].ToString()), dr["FIRMADDRESS"].ToString(), dr["CITYNAME"].ToString(), dr["DISTRICTNAME"].ToString()); break; } con.Close(); return(prj); }