public order(string id, dataBase _connector, int _type) { InitializeComponent(); idPatients = new List <string>(); idDoctors = new List <string>(); connector = _connector; orderData ord = connector.loadOrder(id); idOrder = id; comboBox2.Items.Add(ord.FioPatient); comboBox1.Items.Add(ord.FioDoctor); idDoctors.Add(ord.IdDoctor); idPatients.Add(ord.IdPatient); dateTimePicker1.Value = System.Convert.ToDateTime(ord.DateVisit); needAdd = false; type = _type; if (type == 0) { button2.Visible = false; button1.Visible = false; button4.Visible = true; } else { dateTimePicker1.Enabled = false; comboBox1.Enabled = false; comboBox2.Enabled = false; button1.Visible = false; } }
public orderData loadOrder(string idOrder) { string tmp; orderData ord = new orderData(); command.CommandText = "Select * from [order Запрос] where [order_Код] = " + idOrder; using (OleDbDataReader reader = command.ExecuteReader()) { reader.Read(); tmp = ""; for (int i = 0; i < 3; i++) { tmp += reader.GetValue(i + 2).ToString().Trim() + " "; } ord.FioPatient = tmp; ord.IdPatient = reader.GetValue(1).ToString().Trim(); tmp = ""; for (int i = 0; i < 3; i++) { tmp += reader.GetValue(i + 6).ToString().Trim() + " "; } ord.FioDoctor = tmp; ord.IdDoctor = reader.GetValue(5).ToString().Trim(); ord.DateVisit = reader.GetValue(10).ToString().Trim(); } return(ord); }
public List <string> loadList(string _id) { List <string> data = new List <string>(); data = connector.loadListOrder(_id); return(data); }
public List <string> loadList(int _type) { List <string> data = new List <string>(); data = connector.loadListOrder(_type); return(data); }
public string addOrder(orderData order) { string idOrder = ""; command.CommandText = "Insert into [order] ([idPatient],[idDoctor],[dateOrder],[correct]) Values (" + order.IdPatient + "," + order.IdDoctor + ",#" + getDate(order.DateVisit) + "#,0)"; command.ExecuteNonQuery(); command.CommandText = "Select max(Код) from [order]"; using (OleDbDataReader reader = command.ExecuteReader()) { reader.Read(); idOrder = reader.GetValue(0).ToString().Trim(); } return(idOrder); }
void save() { if (comboBox1.Items.Count > 0 && comboBox2.Items.Count > 0) { orderData order = new orderData(); order.IdDoctor = idDoctors[comboBox1.SelectedIndex]; order.IdPatient = idPatients[comboBox1.SelectedIndex]; order.DateVisit = dateTimePicker1.Value.ToShortDateString(); if (needAdd) { idOrder = connector.addOrder(order); } else if (type == 0) { connector.updateOrder(order); } } }
public void updateOrder(orderData update) { command.CommandText = "Update [order] set [idPatient] = " + update.IdPatient + ", [idDoctor] = " + update.IdDoctor + ",[dateOrder] = #" + getDate(update.DateVisit) + "# where Код = " + update.ID; command.ExecuteNonQuery(); }
public orderControl() { data = new orderData(); connector = new dataBase(); }