Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using MySql.Data.MySqlClient;
- namespace MedicalCardGenerator
- {
- public partial class Form1 : Form
- {
- private bool OnlineMode;//1-использовать сетевую бд , 0 - локальную
- List<Cabinet> Cabinets = new List<Cabinet>(); //список кабинетов
- List<Client_job> Client_jobs = new List<Client_job>();//список работ пациентов
- List<Company> Companies = new List<Company>();//список компаний
- List<Doctor> Doctors = new List<Doctor>();//список кабинетов с врачами
- List<General_doctor> General_doctors = new List<General_doctor>();//список обследований для осмотров
- List<General_inspection> General_inspections = new List<General_inspection>();//список осмотров
- List<Payment_type> Payment_types = new List<Payment_type>();//типы оплаты
- List<Professional_inspection> Professional_inspections = new List<Professional_inspection>();//список обследований для профосмотров
- List<Profession> Professions = new List<Profession>();//список профессий врачей
- List<Company_payment> Company_payments = new List<Company_payment>();//типы оплаты для компании
- string con_str = @"server=82bc33e8-38bd-43e9-8c56-a64100b14ddc.mysql.sequelizer.com;database=db82bc33e838bd43e98c56a64100b14ddc;uid=dtlolccenqyetewj;pwd=Spzz27Q6g3RnrZxDpGg632i88SqokuYuZKDQUBejdEBGvZ2PpA4mc7AZfAAiQBUT";
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- string cs = con_str;
- MySqlConnection conn = null;
- try
- {
- conn = new MySqlConnection(cs);
- conn.Open();
- OnlineMode = true;
- //MessageBox.Show("Success");
- }
- catch (MySqlException ex)
- {
- OnlineMode = false;
- //MessageBox.Show(ex.ToString());
- }
- finally
- {
- FillLists();
- FillCheckBox();
- FillJobs();
- FillGeneralInspections();
- textBox1.Text = Companies.Count.ToString();
- if (conn != null)
- {
- conn.Close();
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- // FillLists();
- MessageBox.Show("Done");
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (comboBox1.SelectedIndex == 0) return;
- if (comboBox1.SelectedIndex == 1)
- {
- /* for (int i = 0; i < checkedListBox1.Items.Count; ++i)
- {
- string name = checkedListBox1.Items[i].ToString();
- for (int j = 0; j < Professions.Count; ++j)
- {
- if (Professions[j].GetName() == name)
- {
- if (Professions[j].GetFemaleOnly())
- {
- checkedListBox1.SetItemChecked(i, false);
- checkedListBox1.SetItemCheckState(i, CheckState.Indeterminate);
- // MessageBox.Show(checkedListBox1.SelectedItems.Count.ToString());
- }
- if (Professions[j].GetMaleOnly())
- {
- checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
- }
- }
- }
- }*/
- for (int i = 0; i < listView2.Items.Count; ++i)
- {
- string name = listView2.Items[i].Text;
- MessageBox.Show(name);
- for (int j = 0; j < Professions.Count; ++j)
- {
- if (Professions[j].GetName() == name)
- {
- if (Professions[j].GetFemaleOnly())
- {
- listView2.Items[i].Checked = false;
- listView2.Items[i].ForeColor = Color.LightGray;
- //listView2.SetItemCheckState(i, CheckState.Indeterminate);
- // MessageBox.Show(checkedListBox1.SelectedItems.Count.ToString());
- }
- if (Professions[j].GetMaleOnly())
- {
- listView2.Items[i].Checked = false;
- listView2.Items[i].ForeColor = Color.Black;
- //checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
- }
- }
- }
- }
- return;
- }
- if (comboBox1.SelectedIndex == 2)
- {
- for (int i = 0; i < checkedListBox1.Items.Count; ++i)
- {
- string name = checkedListBox1.Items[i].ToString();
- for (int j = 0; j < Professions.Count; ++j)
- {
- if (Professions[j].GetName() == name)
- {
- if (Professions[j].GetMaleOnly())
- {
- checkedListBox1.SetItemChecked(i, false);
- checkedListBox1.SetItemCheckState(i, CheckState.Indeterminate);
- }
- if (Professions[j].GetFemaleOnly())
- {
- checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
- }
- }
- }
- }
- return;
- }
- }
- private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
- {
- if (comboBox1.SelectedIndex == 1)
- {
- for (int i = 0; i < Professions.Count; ++i)
- {
- if (Professions[i].GetFemaleOnly())
- {
- if (Professions[i].GetName() == checkedListBox1.Items[e.Index].ToString())
- {
- e.NewValue = CheckState.Indeterminate;//e.CurrentValue;
- }
- }
- }
- }
- //if (e.NewValue == CheckState.Indeterminate) return;
- if (e.CurrentValue == CheckState.Indeterminate) return;
- if (e.NewValue.ToString() == "Checked")
- {
- double cur = double.Parse(label1.Text);
- int intcur = (int)(cur * 100);
- int curcost = 0;
- for (int i = 0; i < Professions.Count; ++i)
- {
- if (Professions[i].GetName() == checkedListBox1.Items[e.Index].ToString())
- {
- curcost = Professions[i].GetCost();
- }
- }
- intcur += curcost;
- cur = (double)intcur / 100.0;
- label1.Text = cur.ToString();
- }
- else
- {
- double cur = double.Parse(label1.Text);
- int intcur = (int)(cur * 100);
- int curcost = 0;
- for (int i = 0; i < Professions.Count; ++i)
- {
- if (Professions[i].GetName() == checkedListBox1.Items[e.Index].ToString())
- {
- curcost = Professions[i].GetCost();
- }
- }
- intcur -= curcost;
- intcur = Math.Max(intcur, 0);
- cur = (double)intcur / 100.0;
- label1.Text = cur.ToString();
- }
- }
- private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
- {
- bool[] used = new bool[500];
- int ck = comboBox2.SelectedIndex;
- int prof_id = -1;
- for(int i = 0 ; i < Client_jobs.Count ; ++i){
- if(Client_jobs[i].GetName() == comboBox2.Items[ck].ToString()){
- prof_id = Client_jobs[i].GetId();
- break;
- }
- }
- for (int i = 0; i < Professional_inspections.Count; ++i)
- {
- if (Professional_inspections[i].GetClientProfessionId() == prof_id)
- {
- string p = "";
- for(int j = 0 ; j < Professions.Count ; ++j){
- if(Professions[j].GetId() == Professional_inspections[i].GetDoctorProfessionId())
- p = Professions[j].GetName();
- }
- /*
- for (int j = 0; j < checkedListBox1.Items.Count; ++j)
- {
- if (checkedListBox1.Items[j].ToString() == p)
- {
- checkedListBox1.SetItemChecked(j, true);
- used[j] = true;
- }
- }*/
- for (int j = 0; j < listView2.Items.Count; ++j)
- {
- if (listView2.Items[j].Text == p)
- {
- listView2.Items[j].Checked = used[j] = true;
- }
- }
- }
- }
- for (int i = 0; i < listView2.Items.Count; ++i)
- {
- if (used[i] == false)
- {
- listView2.Items[i].Checked = false;
- }
- }
- }
- private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
- {
- bool[] used = new bool[500];
- int ck = comboBox3.SelectedIndex;
- int gen_id = -1;
- for (int i = 0; i < General_inspections.Count; ++i)
- {
- if (General_inspections[i].GetName() == comboBox3.Items[ck].ToString())
- {
- gen_id = General_inspections[i].GetId();
- break;
- }
- }
- for (int i = 0; i < General_doctors.Count; ++i)
- {
- if (General_doctors[i].GetGeneralInspectionId() == gen_id)
- {
- string p = "";
- for (int j = 0; j < Professions.Count; ++j)
- {
- if (Professions[j].GetId() == General_doctors[i].GetProfessionId())
- p = Professions[j].GetName();
- }
- for (int j = 0; j < checkedListBox1.Items.Count; ++j)
- {
- if (checkedListBox1.Items[j].ToString() == p)
- {
- checkedListBox1.SetItemChecked(j, true);
- used[j] = true;
- }
- }
- }
- }
- for (int i = 0; i < checkedListBox1.Items.Count; ++i)
- {
- if (used[i] == false)
- {
- checkedListBox1.SetItemChecked(i, false);
- }
- }
- }
- private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e)
- {
- if (string.IsNullOrEmpty(e.Label))
- {
- e.CancelEdit = true;
- return;
- }
- try
- {
- double nw;
- nw = double.Parse(e.Label);
- nw *= 100;
- int nwi = (int)nw;
- if ((double)nwi == nw) return;
- e.CancelEdit = true;
- MessageBox.Show("Введеное значение неверно!");
- }
- catch
- {
- e.CancelEdit = true;
- MessageBox.Show("Введеное значение неверно!");
- }
- }
- private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void checkedListBox1_SelectedValueChanged(object sender, EventArgs e)
- {
- // listView1.SelectedIndices.Add(checkedListBox1.SelectedIndex);
- }
- bool selectflag = false;
- private void listView2_SelectedIndexChanged(object sender, EventArgs e)
- {
- selectflag = false;
- listView1.SelectedIndices.Clear();
- foreach (int ind in listView2.SelectedIndices)
- {
- listView1.SelectedIndices.Add(ind);
- }
- selectflag = true;
- }
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (selectflag == false) return;
- listView2.SelectedIndices.Clear();
- foreach (int ind in listView1.SelectedIndices)
- {
- listView2.SelectedIndices.Add(ind);
- }
- }
- private void listView2_ItemCheck(object sender, ItemCheckEventArgs e)
- {
- if (listView2.Items[e.Index].ForeColor == Color.LightGray)
- {
- e.NewValue = CheckState.Unchecked;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment