private void button1_Click(object sender, EventArgs e) { if (!Validate()) { MessageBox.Show("Bạn chưa nhập giá trị", "Thông báo"); } ReasonApointmentModel reason = listReason.Where(m => m.Reason == txt_reason.Text).FirstOrDefault(); if (reason != null) { MessageBox.Show("Lí do này đã tồn tại", "Thông báo"); } else { List <string> columns = new List <string>() { "reason" }; List <string> values = new List <string>() { txt_reason.Text }; db.InsertRowToTable(DatabaseContants.tables.reasonapoinment, columns, values); } LoadData(); }
public override List <ReasonApointmentModel> GetListReason() { List <ReasonApointmentModel> results = new List <ReasonApointmentModel>(); string strCommand = string.Format("SELECT * FROM {0}", DatabaseContants.tables.reasonapoinment); using (DbDataReader reader = ExecuteReader(strCommand, null)) { while (reader.Read()) { ReasonApointmentModel reason = new ReasonApointmentModel(); reason.ID = reader.GetInt32(0); reason.Reason = reader[1].ToString(); results.Add(reason); } } return(results); }