public static Church getCurentPastorChurch(Pastor p) { Church church = new Church(); string req = "SELECT * FROM fgm_church WHERE stationCode in( SELECT codeStationTransfer FROM fgm_pastor_transfer WHERE mleTransferedPastor = '" + p.getCode() + "' and statusTransfert = 'Encours')"; cmd = new MySqlCommand(req, DBConnection.con); dr = cmd.ExecuteReader(); if (dr.Read()) { church.setCode(dr["stationCode"].ToString()); church.setName(dr["stationName"].ToString()); church.setDistrict(getDistrictByCode(dr["districtParentReff"].ToString())); church.setSlogang(dr["stationSlogang"].ToString()); church.setIsDelete(Convert.ToInt32(dr["isBaseArea"])); } dr.Close(); return(church); }
public static Church getChurchByCode(string churchCode) { string req = "SELECT * FROM fgm_church WHERE stationCode = '" + churchCode + "' and isDelete = 0"; cmd = new MySqlCommand(req, DBConnection.con); dr = cmd.ExecuteReader(); Church church = new Church(); while (dr.Read()) { church.setCode(dr["stationCode"].ToString()); church.setName(dr["stationName"].ToString()); church.setDistrict(getDistrictByCode(dr["districtParentReff"].ToString())); church.setSlogang(dr["stationSlogang"].ToString()); church.setIsDelete(Convert.ToInt32(dr["isDelete"])); } dr.Close(); return(church); }
//get all the Church Of that district public List <Church> getChurchOfDistrict() { string req = "SELECT * FROM fgm_church WHERE districtParentReff = '" + this.code + "' and isDelete = 0"; cmd = new MySqlCommand(req, DBConnection.con); MySqlDataReader dr = cmd.ExecuteReader(); List <Church> Churchs = new List <Church>(); while (dr.Read()) { Church church = new Church(); church.setCode(dr["stationCode"].ToString()); church.setName(dr["stationName"].ToString()); church.setDistrict(this); church.setSlogang(dr["stationSlogang"].ToString()); church.setIsDelete(Convert.ToInt32(dr["isDelete"])); Churchs.Add(church); } dr.Close(); return(Churchs); }
public static List <Church> getChurchList() { string req = "SELECT * FROM fgm_church WHERE isDelete = 0"; cmd = new MySqlCommand(req, DBConnection.con); dr = cmd.ExecuteReader(); List <Church> churchs = new List <Church>(); while (dr.Read()) { Church church = new Church(); church.setCode(dr["stationCode"].ToString()); church.setName(dr["stationName"].ToString()); church.setPicture(dr["stationPicture"].ToString()); church.setIsDelete((int)dr["isDelete"]); church.setDistrict(new District()); church.setDistrictCode((dr["districtParentReff"].ToString())); churchs.Add(church); } dr.Close(); return(churchs); }