// สถานะภาพการสมรส private void _loadPersonStatus() { List <Base_Person_Status> list_data = new Base_Person_Status_Manager().getPersonStatus(); Cust_status_DDL.Items.Add(new ListItem("--------กรุณาเลือก--------", "0")); for (int i = 0; i < list_data.Count; i++) { Base_Person_Status data = list_data[i]; Cust_status_DDL.Items.Add(new ListItem(data.person_status_name, data.person_status_id.ToString())); } }
public List <Base_Person_Status> getPersonStatus() { MySqlConnection con = MySQLConnection.connectionMySQL(); try { con.Open(); string sql = "SELECT * FROM base_person_status"; MySqlCommand cmd = new MySqlCommand(sql, con); MySqlDataReader reader = cmd.ExecuteReader(); int defaultNum = 0; string defaultString = ""; List <Base_Person_Status> list_bs_ps_st = new List <Base_Person_Status>(); while (reader.Read()) { Base_Person_Status bs_ps_st = new Base_Person_Status(); bs_ps_st.person_status_id = reader.IsDBNull(0) ? defaultNum : reader.GetInt32(0); bs_ps_st.person_status_name = reader.IsDBNull(1) ? defaultString : reader.GetString(1); list_bs_ps_st.Add(bs_ps_st); } return(list_bs_ps_st); } catch (MySqlException ex) { error = "MysqlException ==> Managers_Base --> Base_Person_Status_Manager --> getPersonStatus() "; Log_Error._writeErrorFile(error, ex); return(null); } catch (Exception ex) { error = "Exception ==> Managers_Base --> Base_Person_Status_Manager --> getPersonStatus() "; Log_Error._writeErrorFile(error, ex); return(null); } finally { con.Close(); con.Dispose(); } }