private MainFormSettings CreateMainFormSetttingsFromFile() { XmlSerializer xmlSerializer = new XmlSerializer(typeof(MainFormSettings)); if (!File.Exists(ClinicConstant.MainFormSettings_FileName)) { this.mainFormSettings = new MainFormSettings(); this.mainFormSettings.ShowBigForm = this.checkBoxShowBigForm.Checked; this.mainFormSettings.ShowOneRecord = this.checkBoxShow1Record.Checked; this.mainFormSettings.ShowMedicines = this.checkBoxShowMedicines.Checked; using (StreamWriter sw = new StreamWriter("MainFormSettings.xml")) { XmlSerializer serializer = new XmlSerializer(mainFormSettings.GetType()); serializer.Serialize(sw, mainFormSettings); } } MainFormSettings result; using (StreamReader sr = new StreamReader(ClinicConstant.MainFormSettings_FileName)) { result = xmlSerializer.Deserialize(sr) as MainFormSettings; } return result; }
public Form1(int Authority, string name) { //init MainForm this.TopLevel = true; InitializeComponent(); //init delegate TuThuocForm.refreshMedicines4MainForm = new Clinic.TuThuocForm.RefreshMedicines4MainForm(InitComboboxMedicinesMySql); Services.refreshMedicines4MainForm = new Clinic.Services.RefreshMedicines4MainForm(InitComboboxMedicinesMySql); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Text = "Phòng Khám -" + "User: "******"Loading Database"); //Load Settings if (mainFormSettings == null) { mainFormSettings = CreateMainFormSetttingsFromFile(); } this.checkBoxShowBigForm.Checked = mainFormSettings.ShowBigForm; this.checkBoxShow1Record.Checked = mainFormSettings.ShowOneRecord; this.checkBoxShowMedicines.Checked = mainFormSettings.ShowMedicines; this.Enabled = false; BackgroundWorker backgroundWorkerLoadingDatabase = new BackgroundWorker(); backgroundWorkerLoadingDatabase.WorkerSupportsCancellation = true; backgroundWorkerLoadingDatabase.DoWork += new DoWorkEventHandler(backgroundWorkerLoadingDatabase_DoWork); backgroundWorkerLoadingDatabase.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorkerLoadingDatabase_RunWorkerCompleted); backgroundWorkerLoadingDatabase.RunWorkerAsync(); this.textBoxReason.Visible = false; List<string> listLoaiKham = Helper.GetAllLoaiKham(this.db); this.comboBoxLoaiKham.Items.AddRange(listLoaiKham.ToArray()); comboBoxLoaiKham.Text = "Loại Khám: "; listDiagnosesFromHistory = Helper.GetAllDiagnosesFromHistory(this.db); this.txtBoxClinicRoomDiagnose.AutoCompleteCustomSource.AddRange(listDiagnosesFromHistory.ToArray()); this.StartPosition = FormStartPosition.CenterScreen; //this.WindowState = Clinic.Properties.Settings.Default.State; //if (this.WindowState == FormWindowState.Normal) this.Size = Clinic.Properties.Settings.Default.Size; this.Resize += new System.EventHandler(this.Form1_Resize); try { XmlSerializer xmlSerializer = new XmlSerializer(typeof(InfoClinic)); StreamReader sr = new StreamReader("Information.xml"); infoClinic = xmlSerializer.Deserialize(sr) as InfoClinic; textBoxNameClinic.Text = infoClinic.Name; textBoxAddressClinic.Text = infoClinic.Address; textBoxAdviceClinic.Text = infoClinic.Advice; textBoxSDT.Text = infoClinic.Sdt; textBoxBackupSource.Text = infoClinic.PathData; textBoxBackupTarget.Text = infoClinic.PathTargetBackup; textBoxBackupTimeAuto.Text = infoClinic.TimeBackup; bool temp = bool.Parse(infoClinic.CheckedBackup1.ToLower()); if (temp) { checkBoxAutoCopy.CheckState = CheckState.Checked; } sr.Close(); } catch (Exception exx) { } try { // do any background work //do not change InitComboboxMedicinesMySql(); InitClinicRoom(); dataGridView4.Visible = false; maxIdOfCalendarItem = Helper.SearchMaxValueOfTable(db,"calendar", "IdCalendar", "DESC"); // //Load calendar // List<ADate> listDate = Helper.GetAllDateOfUser(UserName, db); foreach (ADate item in listDate) { CalendarItem cal = new CalendarItem(calendar1, item.StartTime, item.EndTime, item.Text); cal.Tag = item.Id; if (item.color != 0) { cal.ApplyColor(Helper.ConvertCodeToColor(item.color)); } _items.Add(cal); } PlaceItems(); //load lichhen LoadLichHen(DateTime.Now); //xoa listtoday XoaListToday(); } catch (Exception ex) { // log errors } listPatientForm = new Clinic.ListPatientsTodayForm(); listPatientForm.sendCommandKham = new Clinic.ListPatientsTodayForm.SendCommandKham(KhamVaXoa); SearchForm.sendCommand = new Clinic.SearchForm.SendCommandProcessFromSearchForm(this.ProcessWhenUserDoubleClickOnSearch); ///favouriteForm.sendCommand = new Form2.SendCommand(PlayFromFavouriteForm); /// this.ColumnID.Width = 50; this.ColumnNamePatient.Width = 150; this.ColumnNgaySinh.Width = 100; this.ColumnNgayKham.Width = 100; this.ColumnAddress.Width = 100; this.ColumnSymtom.Width = 100; this.ColumnNhietDo.Width = 50; this.ColumnHuyetAp.Width = 50; this.ColumnDiagno.Width = 150; this.ColumnSearchValueMedicines.Width = 250; this.circularProgress1.Hide(); TimerGetId = new System.Windows.Forms.Timer(); TimerGetId.Tick+=new EventHandler(TimerGetId_Tick); TimerGetId.Interval = 2000; TimerGetId.Start(); try { SieuAmManager.Instance.Capture.PreviewWindow = this.panelPreviewVideo; } catch { } }