public void fill_datagrid() { using (VivosEntities db = new VivosEntities()) { commands_datagrid.Rows.Clear(); commands_datagrid.ColumnCount = 2; commands_datagrid.Columns[1].Width = 515; commands_datagrid.Columns[0].Visible = false; commands_datagrid.Columns[1].Name = resourceManager.GetString("headerStep", GlobalVariables.uiLanguage); commands_datagrid.RowTemplate.Height = 30; commands_datagrid.BorderStyle = BorderStyle.None; commands_datagrid.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249); commands_datagrid.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal; commands_datagrid.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise; commands_datagrid.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke; commands_datagrid.BackgroundColor = Color.White; commands_datagrid.EnableHeadersVisualStyles = false; commands_datagrid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; commands_datagrid.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72); commands_datagrid.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; add_button(); for (int i = 0; i < commands_datagrid.ColumnCount - 1; i++) { commands_datagrid.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; commands_datagrid.Columns[i].DefaultCellStyle.Font = new Font("Times New Roman", 12, FontStyle.Regular); } List <AssetCommand> commandlist = (from x in db.AssetCommands where x.AssetId == GlobalVariables.Asset_Start_ID orderby x.Step select x).ToList(); Asset asset = (from x in db.Assets where x.Id == GlobalVariables.Asset_Start_ID select x).SingleOrDefault(); if (asset != null) { if (asset.Exe == "Class_Ideasis.exe") { lblPresentationName.Visible = true; txtPresentationName.Visible = true; btnPresentationSave.Visible = true; } } for (int i = 0; i < commandlist.Count; i++) { i = commands_datagrid.Rows.Add(); commands_datagrid.Rows[i].Cells[0].Value = commandlist[i].Id; if (Convert.ToString(GlobalVariables.uiLanguage) == "en-US") { commands_datagrid.Rows[i].Cells[1].Value = commandlist[i].EnDescription; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "tr-TR") { commands_datagrid.Rows[i].Cells[1].Value = commandlist[i].Description; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "ar-SA") { commands_datagrid.Rows[i].Cells[1].Value = commandlist[i].ArabicDescription; } } } }
private void newsession_datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 4) { try { GlobalVariables.Asset_Start_ID = Guid.Parse(newsession_datagrid.Rows[e.RowIndex].Cells[1].Value.ToString()); using (VivosEntities db = new VivosEntities()) { List <Asset> assets = (from x in db.Assets select x).ToList(); for (int i = 0; i < assets.Count; i++) { if (GlobalVariables.Asset_Start_ID == assets[i].Id) { try { GlobalVariables.neulogProcess = System.Diagnostics.Process.Start(VivoosVR.Properties.Settings.Default.neulog_dizin); } catch (Exception) { MessageBox.Show("Neulog" + " " + VivoosVR.Properties.Settings.Default.neulog_dizin + " " + resourceManager.GetString("msgCannotFound", GlobalVariables.uiLanguage)); } try { if (Convert.ToString(GlobalVariables.uiLanguage) == "en-US") { GlobalVariables.Asset_Start_name = assets[i].EnName; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "tr-TR") { GlobalVariables.Asset_Start_name = assets[i].Name; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "ar-SA") { GlobalVariables.Asset_Start_name = assets[i].ArabicName; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "fr-FR") { GlobalVariables.Asset_Start_name = assets[i].FrName; } GlobalVariables.sessionProcess = System.Diagnostics.Process.Start(@assets[i].Url); GlobalVariables.processURL = @assets[i].Url; New_Session_Controls_Page new_session_controls = new New_Session_Controls_Page(); new_session_controls.Show(); this.Hide(); } catch (Exception) { MessageBox.Show(resourceManager.GetString("headerScenario", GlobalVariables.uiLanguage) + assets[i].Url + " " + resourceManager.GetString("msgCannotFound", GlobalVariables.uiLanguage)); } break; } } } } catch (Exception) { } } }
private void commands_datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { /*try * {*/ DialogResult delete = new DialogResult(); delete = MessageBox.Show(resourceManager.GetString("msgIscommandDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (delete == DialogResult.Yes) { GlobalVariables.Command_ID = Guid.Parse(commands_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); using (VivosEntities db = new VivosEntities()) { AssetCommand command = db.AssetCommands.First(x => x.Id == GlobalVariables.Command_ID); db.AssetCommands.Remove(command); db.SaveChanges(); //string key = null; fill_datagrid(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgCommandDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } } //} /*catch (Exception) * { * * * }*/ } }
private void btnSave_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtUser.Text) || String.IsNullOrEmpty(txtNewPassword.Text) || String.IsNullOrEmpty(txtNewPasswordAgain.Text)) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgFields", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { using (VivosEntities db = new VivosEntities()) { int flag = 0; List <Consumer> consumerList = (from x in db.Consumers select x).ToList(); Consumer new_consumer = new Consumer(); User new_user = new User(); for (int i = 0; i < consumerList.Count; i++) { if (consumerList[i].Email == txtUser.Text) { flag = 1; break; } } if (flag == 0) { if (txtNewPassword.Text == txtNewPasswordAgain.Text) { Guid consumer_id = Guid.NewGuid(); new_consumer.Id = consumer_id; new_consumer.Code = Guid.NewGuid().ToString(); new_consumer.Description = txtNameSurname.Text; new_consumer.Email = txtUser.Text; new_consumer.EntryDate = DateTime.Now; Consumer consumer = (from x in db.Consumers where x.Code == "admin" select x).SingleOrDefault(); User user = (from x in db.Users where x.Id == consumer.Id select x).SingleOrDefault(); new_user.Id = consumer_id; new_user.GroupId = user.GroupId; new_user.Password = txtNewPassword.Text; db.Consumers.Add(new_consumer); db.Users.Add(new_user); db.SaveChanges(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgUserAdded", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(resourceManager.GetString("msgNewPasswordTwice", GlobalVariables.uiLanguage)); } } else if (flag == 1) { MessageBox.Show(resourceManager.GetString("msgUserExists", GlobalVariables.uiLanguage)); } } } }
private void btnSave_Click(object sender, EventArgs e) { try { try { if (GlobalVariables.neulogProcess.HasExited == false) { GlobalVariables.neulogProcess.Kill(); } } catch (Exception) { } try { if (GlobalVariables.sessionProcess.HasExited == false) { var simProc = Process.GetProcesses().Where(pr => pr.ProcessName.Contains(GlobalVariables.sessionProcess.ProcessName)); foreach (var procs in simProc) { procs.Kill(); } } } catch (Exception) { } using (VivosEntities db = new VivosEntities()) { List <Session> sessionList = (from x in db.Sessions select x).ToList(); Session new_session = new Session(); new_session.Id = Guid.NewGuid(); new_session.AssetId = GlobalVariables.Asset_Start_ID; new_session.PatientId = GlobalVariables.Session_ID; new_session.Notes = null; new_session.SessionDateTime = DateTime.Now; new_session.SensorData = data; db.Sessions.Add(new_session); db.SaveChanges(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgSessionAdded", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } GlobalVariables.NewSessions_Search_Flag = 0; Sessions_Page sessions = new Sessions_Page(); this.Hide(); sessions.Show(); } catch (Exception) { } }
public void find_notes(Guid id) { using (VivosEntities db = new VivosEntities()) { List <Patient> patientlist = (from x in db.Patients select x).ToList(); for (int i = 0; i < patientlist.Count; i++) { if (patientlist[i].Id == id) { MessageBox.Show(patientlist[i].Notes, patientlist[i].Code + " " + resourceManager.GetString("headerNotes", GlobalVariables.uiLanguage)); } } } }
private void btnLogin_Click(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtPassword.Text)) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgFields", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { using (VivosEntities db = new VivosEntities()) { Consumer consumer = (Consumer)(from x in db.Consumers where x.Email.Equals(txtUsername.Text) select x).FirstOrDefault(); if (consumer != null) { User user = (User)(from x in db.Users where consumer.Id.Equals(x.Id) && x.Password.Equals(txtPassword.Text) select x).FirstOrDefault(); if (user != null) { GlobalVariables.LoginID = consumer.Id; if (consumer.Code.Equals("admin")) { Admin_Page admin = new Admin_Page(); this.Hide(); admin.Show(); } else { Patients_Page patients = new Patients_Page(); this.Hide(); patients.Show(); } return; } } } DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgWrong", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { } }
private void btnSave_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtOldPassword.Text) || String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtNewPassword.Text) || String.IsNullOrEmpty(txtNewPasswordAgain.Text)) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgFields", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { using (VivosEntities db = new VivosEntities()) { Consumer consumer = (from x in db.Consumers where x.Email==txtUsername.Text select x).SingleOrDefault(); if (consumer != null) { User user = (from x in db.Users where x.Id == consumer.Id select x).SingleOrDefault(); if (user!=null) { if (user.Password==txtOldPassword.Text) { if (txtNewPassword.Text==txtNewPasswordAgain.Text) { user.Password = txtNewPassword.Text; db.SaveChanges(); MessageBox.Show(resourceManager.GetString("msgPasswordChanged", GlobalVariables.uiLanguage)); } else { MessageBox.Show(resourceManager.GetString("msgNewPasswordTwice", GlobalVariables.uiLanguage)); } } else { MessageBox.Show(resourceManager.GetString("msgOldPasswordWrong", GlobalVariables.uiLanguage)); } } } else { MessageBox.Show(resourceManager.GetString("msgUserNotFound", GlobalVariables.uiLanguage)); } } } }
private void commands_datagrid_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 1) { try { if (GlobalVariables.sessionProcess.HasExited == false) { GlobalVariables.Command_Start_ID = Guid.Parse(commands_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); using (VivosEntities db = new VivosEntities()) { List <AssetCommand> commandList = (from x in db.AssetCommands where x.Id == GlobalVariables.Command_Start_ID select x).ToList(); if (Convert.ToString(GlobalVariables.uiLanguage) == "en-US") { komut = commandList[0].EnDescription; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "tr-TR") { komut = commandList[0].Description; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "ar-SA") { komut = commandList[0].ArabicDescription; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "fr-FR") { komut = commandList[0].FrDescription; } komut_adımı = commandList[0].Step; new_socket.Send(commandList[0].CommandText + "\r"); new_socket.WaitForSendComplete(); } } } catch (Exception) { } } }
public void edit_start() { if (GlobalVariables.Is_Edit == true) { using (VivosEntities db = new VivosEntities()) { List <Patient> patientlist = (from x in db.Patients select x).ToList(); for (int i = 0; i < patientlist.Count; i++) { if (patientlist[i].Id == GlobalVariables.Edit_ID) { txtPatientCode.Text = patientlist[i].Code; txtDescription.Text = patientlist[i].Notes; if (patientlist[i].DateOfBirth != null) { string[] datetime = ((patientlist[i].DateOfBirth).ToString()).Split(' '); clndrBirthday.Value = Convert.ToDateTime(datetime[0]); } } } } } }
public void add_scenarios(string file, Image image) { try { using (VivosEntities db = new VivosEntities()) { string asset_imformation1 = null; string[] asset_imformation = null; asset_imformation1 = file; asset_imformation = asset_imformation1.Split(new char[] { '\n' }); for (int i = 0; i < asset_imformation.Length - 1; i++) { asset_imformation[i] = asset_imformation[i].Remove(asset_imformation[i].Length - 1); } List <Asset> AssetList = (from x in db.Assets select x).ToList(); List <AssetThumbnail> AssetThumbnailList = (from x in db.AssetThumbnails select x).ToList(); List <AssetCommand> AssetCommandList = (from x in db.AssetCommands select x).ToList(); int command_count = 0; for (int i = 0; i < asset_imformation.Length; i++) { var splitted = asset_imformation[i].Split(new char[] { ',' }); if (splitted[0].Contains("Komutlar") == true) { command_count++; } } Asset new_asset = new Asset(); AssetThumbnail new_asset_thumbnail = new AssetThumbnail(); AssetCommand[] new_asset_command = new AssetCommand[command_count]; for (int i = 0; i < new_asset_command.Length; i++) { new_asset_command[i] = new AssetCommand(); } Guid new_asset_id = Guid.NewGuid(); new_asset.Id = new_asset_id; new_asset.GroupId = new Guid("00000000-0000-0000-0000-000000000000"); new_asset.EntryDate = DateTime.Now; int command_add_number = 0; for (int i = 0; i < asset_imformation.Length; i++) { var splitted = asset_imformation[i].Split(new char[] { ',' }); if (splitted[0].Contains("Ad") == true) { new_asset.Name = splitted[1]; new_asset.EnName = splitted[2]; new_asset.ArabicName = splitted[3]; } else if (splitted[0].Contains("Açıklama") == true) { new_asset.Description = splitted[1]; new_asset.EnDescription = splitted[2]; new_asset.ArabicDescription = splitted[3]; } else if (splitted[0].Contains("Aktif") == true) { if (splitted[1].Contains("True") == true) { new_asset.Available = true; } else { new_asset.Available = false; } } else if (splitted[0].Contains("Senaryo Dizini") == true) { new_asset.Url = splitted[1]; } else if (splitted[0].Contains("Senaryo Exe") == true) { new_asset.Exe = splitted[1]; } else if (splitted[0].Contains("Komutlar") == true) { Guid new_asset_command_id = Guid.NewGuid(); new_asset_command[command_add_number].Id = new_asset_command_id; new_asset_command[command_add_number].AssetId = new_asset_id; new_asset_command[command_add_number].Description = splitted[1]; new_asset_command[command_add_number].EnDescription = splitted[2]; new_asset_command[command_add_number].ArabicDescription = splitted[3]; new_asset_command[command_add_number].CommandText = splitted[4]; try { new_asset_command[command_add_number].Step = Convert.ToByte(splitted[5]); } catch (Exception) { new_asset_command[command_add_number].Step = Convert.ToByte(0); } db.AssetCommands.Add(new_asset_command[command_add_number]); command_add_number++; } } try { Image img = image; Bitmap bmp = new Bitmap(img); ImageConverter converter = new ImageConverter(); new_asset_thumbnail.Thumbnail = (byte[])converter.ConvertTo(img, typeof(byte[])); new_asset_thumbnail.AssetId = new_asset_id; } catch (Exception) { } db.Assets.Add(new_asset); db.AssetThumbnails.Add(new_asset_thumbnail); db.SaveChanges(); } } catch (Exception) { } }
public void fill_datagrid(string key) { using (VivosEntities db = new VivosEntities()) { patients_datagrid.Rows.Clear(); patients_datagrid.ColumnCount = 4; patients_datagrid.Columns[0].Visible = false; patients_datagrid.Columns[1].Name = resourceManager.GetString("headerPatient", GlobalVariables.uiLanguage); patients_datagrid.Columns[2].Name = resourceManager.GetString("headerBirthday", GlobalVariables.uiLanguage); patients_datagrid.Columns[3].Name = resourceManager.GetString("headerRegistration", GlobalVariables.uiLanguage); patients_datagrid.RowTemplate.Height = 30; patients_datagrid.BorderStyle = BorderStyle.None; patients_datagrid.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249); patients_datagrid.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal; patients_datagrid.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise; patients_datagrid.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke; patients_datagrid.BackgroundColor = Color.White; patients_datagrid.EnableHeadersVisualStyles = false; patients_datagrid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; patients_datagrid.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72); patients_datagrid.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; add_button(); for (int i = 0; i < patients_datagrid.ColumnCount - 3; i++) { patients_datagrid.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; patients_datagrid.Columns[i].DefaultCellStyle.Font = new Font("Times New Roman", 12, FontStyle.Regular); } List <Patient> patientlist = (from x in db.Patients where x.DoctorId == GlobalVariables.LoginID select x).ToList(); List <Patient> patientlist1 = patientlist.OrderBy(o => o.Code).ToList(); List <Patient> patientlist02 = (from x in db.Patients where x.Code.StartsWith(key) && x.DoctorId == GlobalVariables.LoginID select x).ToList(); List <Patient> patientlist2 = patientlist02.OrderBy(o => o.Code).ToList(); List <Patient> keyList = null; if (GlobalVariables.Patients_Search_Flag == 0) { keyList = patientlist1; } else { keyList = patientlist2; } for (int i = 0; i < keyList.Count; i++) { i = patients_datagrid.Rows.Add(); patients_datagrid.Rows[i].Cells[0].Value = keyList[i].Id; patients_datagrid.Rows[i].Cells[1].Value = keyList[i].Code; if (keyList[i].DateOfBirth != null) { patients_datagrid.Rows[i].Cells[2].Value = Convert.ToDateTime(keyList[i].DateOfBirth).ToString("dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); } else { patients_datagrid.Rows[i].Cells[2].Value = null; } if (keyList[i].EntryDate != null) { patients_datagrid.Rows[i].Cells[3].Value = Convert.ToDateTime(keyList[i].EntryDate).ToString("dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture); } else { patients_datagrid.Rows[i].Cells[3].Value = null; } } } }
private void patients_datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 4) { try { Guid id = Guid.Parse(patients_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); find_notes(id); } catch (Exception) { } } else if (e.ColumnIndex == 5) { try { GlobalVariables.Session_ID = Guid.Parse(patients_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); GlobalVariables.Is_Session = true; using (VivosEntities db = new VivosEntities()) { List <Patient> patientlist1 = (from x in db.Patients where x.Id == GlobalVariables.Session_ID select x).ToList(); GlobalVariables.Session_ID_name = patientlist1[0].Code; } GlobalVariables.Sessions_Search_Flag = 0; Sessions_Page sessions = new Sessions_Page(); this.Hide(); sessions.Show(); } catch (Exception) { } } else if (e.ColumnIndex == 6) { try { GlobalVariables.Edit_ID = Guid.Parse(patients_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); GlobalVariables.Is_Edit = true; New_Patient_Page yeni_danısan = new New_Patient_Page(); this.Hide(); yeni_danısan.Show(); } catch (Exception) { } } else if (e.ColumnIndex == 7) { try { DialogResult delete = new DialogResult(); delete = MessageBox.Show(resourceManager.GetString("msgIsPatientDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (delete == DialogResult.Yes) { GlobalVariables.Edit_ID = Guid.Parse(patients_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); using (VivosEntities db = new VivosEntities()) { List <Session> sessionList = (from x in db.Sessions where x.PatientId == GlobalVariables.Edit_ID select x).ToList(); Session[] sessions = new Session[sessionList.Count]; for (int i = 0; i < sessions.Length; i++) { sessions[i] = sessionList[i]; db.Sessions.Remove(sessions[i]); } Patient patient = db.Patients.First(x => x.Id == GlobalVariables.Edit_ID); db.Patients.Remove(patient); db.SaveChanges(); GlobalVariables.Patients_Search_Flag = 0; string key = null; fill_datagrid(key); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgPatientDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("mesajBilgilendirme", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception) { } } }
private void btnSave_Click(object sender, EventArgs e) { if (GlobalVariables.Is_Edit == false) { using (VivosEntities db = new VivosEntities()) { List <Asset> AssetList = (from x in db.Assets select x).ToList(); List <AssetThumbnail> AssetThumbnailList = (from x in db.AssetThumbnails select x).ToList(); List <AssetCommand> AssetCommandList = (from x in db.AssetCommands select x).ToList(); Asset new_asset = new Asset(); AssetThumbnail new_asset_thumbnail = new AssetThumbnail(); AssetCommand[] new_asset_command = new AssetCommand[commandsLayout.RowCount - 1]; for (int i = 0; i < new_asset_command.Length; i++) { new_asset_command[i] = new AssetCommand(); } Guid new_asset_id = Guid.NewGuid(); new_asset.Id = new_asset_id; new_asset.GroupId = new Guid("00000000-0000-0000-0000-000000000000"); new_asset.Name = txtTurkishName.Text; new_asset.EnName = txtEnglishName.Text; new_asset.ArabicName = txtArabicName.Text; new_asset.Description = txtTurkishDescription.Text; new_asset.EnDescription = txtEnglishDescription.Text; new_asset.ArabicDescription = txtArabicDescription.Text; if (cbAvaliable.Checked == true) { new_asset.Available = true; } else { new_asset.Available = false; } new_asset.Url = txtScenarioPath.Text; new_asset.Exe = txtScenarioExe.Text; new_asset.EntryDate = DateTime.Now; try { if (pictureBox2.Image != null) { Image img = pictureBox2.Image; Bitmap bmp = new Bitmap(img); ImageConverter converter = new ImageConverter(); new_asset_thumbnail.Thumbnail = (byte[])converter.ConvertTo(img, typeof(byte[])); new_asset_thumbnail.AssetId = new_asset_id; } else { new_asset_thumbnail.Thumbnail = null; new_asset_thumbnail.AssetId = new_asset_id; } } catch (Exception) { } for (int i = 0; i < commandsLayout.RowCount - 2; i++) { Guid new_asset_command_id = Guid.NewGuid(); new_asset_command[i].Id = new_asset_command_id; new_asset_command[i].AssetId = new_asset_id; new_asset_command[i].CommandText = txtCommand[i].Text; new_asset_command[i].Description = txtTurkishExplanation[i].Text; new_asset_command[i].EnDescription = txtEnglishExplanation[i].Text; new_asset_command[i].ArabicDescription = txtArabicExplanation[i].Text; try { new_asset_command[i].Step = Convert.ToByte(txtStep[i].Text); } catch (Exception) { new_asset_command[i].Step = Convert.ToByte(0); } db.AssetCommands.Add(new_asset_command[i]); } db.Assets.Add(new_asset); db.AssetThumbnails.Add(new_asset_thumbnail); db.SaveChanges(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgScenarioAdded", GlobalVariables.uiLanguage)); if (information == DialogResult.OK) { Admin_Page admin_page = new Admin_Page(); this.Hide(); admin_page.Show(); } } } else { using (VivosEntities db = new VivosEntities()) { List <Asset> AssetList = (from x in db.Assets select x).ToList(); List <AssetThumbnail> AssetThumbnailList = (from x in db.AssetThumbnails select x).ToList(); List <AssetCommand> AssetCommandList = (from x in db.AssetCommands select x).ToList(); AssetCommand[] new_asset_command = new AssetCommand[commandsLayout.RowCount - 1]; for (int i = 0; i < new_asset_command.Length; i++) { new_asset_command[i] = new AssetCommand(); } Asset edit_asset = (from x in db.Assets where x.Id == GlobalVariables.Asset_Start_ID select x).SingleOrDefault(); if (edit_asset != null) { edit_asset.Name = txtTurkishName.Text; edit_asset.EnName = txtEnglishName.Text; edit_asset.ArabicName = txtArabicName.Text; edit_asset.Description = txtTurkishDescription.Text; edit_asset.EnDescription = txtEnglishDescription.Text; edit_asset.ArabicDescription = txtArabicDescription.Text; edit_asset.Url = txtScenarioPath.Text; edit_asset.Exe = txtScenarioExe.Text; edit_asset.ModifyDate = DateTime.Now; if (cbAvaliable.Checked == true) { edit_asset.Available = true; } else { edit_asset.Available = false; } } AssetThumbnail edit_asset_thumbnail = (from x in db.AssetThumbnails where x.AssetId == GlobalVariables.Asset_Start_ID select x).SingleOrDefault(); if (edit_asset_thumbnail != null) { if (pictureBox2.Image != null) { Image img = pictureBox2.Image; Bitmap bmp = new Bitmap(img); ImageConverter converter = new ImageConverter(); try { edit_asset_thumbnail.Thumbnail = (byte[])converter.ConvertTo(img, typeof(byte[])); } catch { } } } for (int i = 0; i < commandsLayout.RowCount - 2; i++) { int flag = 0; for (int j = 0; j < AssetCommandList.Count; j++) { if (AssetCommandList[j].Id == Guid.Parse(txtID[i].Text)) { AssetCommandList[j].CommandText = txtCommand[i].Text; AssetCommandList[j].Description = txtTurkishExplanation[i].Text; AssetCommandList[j].EnDescription = txtEnglishExplanation[i].Text; AssetCommandList[j].ArabicDescription = txtArabicExplanation[i].Text; AssetCommandList[j].Step = Convert.ToByte(txtStep[i].Text); flag = 1; break; } } if (flag == 0) { Guid new_asset_command_id = Guid.NewGuid(); new_asset_command[i].Id = new_asset_command_id; new_asset_command[i].AssetId = GlobalVariables.Asset_Start_ID; new_asset_command[i].CommandText = txtCommand[i].Text; new_asset_command[i].Description = txtTurkishExplanation[i].Text; new_asset_command[i].EnDescription = txtEnglishExplanation[i].Text; new_asset_command[i].ArabicDescription = txtArabicExplanation[i].Text; new_asset_command[i].Step = Convert.ToByte(txtStep[i].Text); db.AssetCommands.Add(new_asset_command[i]); } } db.SaveChanges(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgScenarioEdited", GlobalVariables.uiLanguage)); if (information == DialogResult.OK) { Admin_Page admin_page = new Admin_Page(); this.Hide(); admin_page.Show(); } } } }
public void fill_datagrid(string key) { using (VivosEntities db = new VivosEntities()) { scenarios_datagrid.Rows.Clear(); scenarios_datagrid.ColumnCount = 4; scenarios_datagrid.Columns[0].Width = 300; scenarios_datagrid.Columns[1].Visible = false; scenarios_datagrid.Columns[2].Name = resourceManager.GetString("headerScenario", GlobalVariables.uiLanguage); scenarios_datagrid.Columns[3].Width = 400; scenarios_datagrid.Columns[3].Name = resourceManager.GetString("headerExplanation", GlobalVariables.uiLanguage); scenarios_datagrid.Columns[3].Width = 800; scenarios_datagrid.RowTemplate.Height = 100; scenarios_datagrid.BorderStyle = BorderStyle.None; scenarios_datagrid.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249); scenarios_datagrid.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal; scenarios_datagrid.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise; scenarios_datagrid.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke; scenarios_datagrid.BackgroundColor = Color.White; scenarios_datagrid.EnableHeadersVisualStyles = false; scenarios_datagrid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; scenarios_datagrid.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72); scenarios_datagrid.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; add_button(); scenarios_datagrid.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; for (int i = 0; i < scenarios_datagrid.ColumnCount - 3; i++) { scenarios_datagrid.Columns[i].DefaultCellStyle.Font = new Font("Times New Roman", 12, FontStyle.Regular); } List <Asset> assetlist = (from x in db.Assets orderby x.Name select x).ToList(); List <Asset> assetlist2 = (from x in db.Assets where x.Name.StartsWith(key) orderby x.Name select x).ToList(); List <AssetThumbnail> assetThumbnail = (from x in db.AssetThumbnails select x).ToList(); List <Asset> keyList = null; if (GlobalVariables.NewSessions_Search_Flag == 0) { keyList = assetlist; } else { keyList = assetlist2; } for (int i = 0; i < keyList.Count; i++) { i = scenarios_datagrid.Rows.Add(); scenarios_datagrid.Rows[i].Cells[1].Value = keyList[i].Id; for (int j = 0; j < assetThumbnail.Count; j++) { if (assetThumbnail[j].AssetId == keyList[i].Id) { if (assetThumbnail[j].Thumbnail != null) { using (MemoryStream memoryStream = new MemoryStream(assetThumbnail[j].Thumbnail)) { Bitmap bmp = new Bitmap(memoryStream); scenarios_datagrid.Rows[i].Cells[0].Value = bmp; } } } } if (Convert.ToString(GlobalVariables.uiLanguage) == "en-US") { scenarios_datagrid.Rows[i].Cells[2].Value = keyList[i].EnName; scenarios_datagrid.Rows[i].Cells[3].Value = keyList[i].EnDescription; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "tr-TR") { scenarios_datagrid.Rows[i].Cells[2].Value = keyList[i].Name; scenarios_datagrid.Rows[i].Cells[3].Value = keyList[i].Description; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "ar-SA") { scenarios_datagrid.Rows[i].Cells[2].Value = keyList[i].ArabicName; scenarios_datagrid.Rows[i].Cells[3].Value = keyList[i].ArabicDescription; } } } }
private void scenarios_datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 4) { try { using (VivosEntities db = new VivosEntities()) { GlobalVariables.Asset_Start_ID = Guid.Parse(scenarios_datagrid.Rows[e.RowIndex].Cells[1].Value.ToString()); Asset exported_asset = (from x in db.Assets where x.Id == GlobalVariables.Asset_Start_ID select x).SingleOrDefault(); List <AssetCommand> exported_asset_commands = (from x in db.AssetCommands where x.AssetId == GlobalVariables.Asset_Start_ID orderby x.Step select x).ToList(); AssetThumbnail exported_asset_thumbnail = (from x in db.AssetThumbnails where x.AssetId == GlobalVariables.Asset_Start_ID select x).SingleOrDefault(); SaveFileDialog file1 = new SaveFileDialog(); file1.InitialDirectory = ".\\desktop"; file1.Filter = "Text|*.txt"; file1.FileName = exported_asset.Name; if (file1.ShowDialog() == DialogResult.OK) { data = data + resourceManager.GetString("lblName", GlobalVariables.uiLanguage) + "," + exported_asset.Name + "," + exported_asset.EnName + "," + exported_asset.ArabicName + Environment.NewLine; data = data + resourceManager.GetString("lblDescription", GlobalVariables.uiLanguage) + "," + exported_asset.Description + "," + exported_asset.EnDescription + "," + exported_asset.ArabicDescription + Environment.NewLine; data = data + resourceManager.GetString("lblScenarioPath", GlobalVariables.uiLanguage) + "," + exported_asset.Url + Environment.NewLine; data = data + resourceManager.GetString("lblScenarioExe", GlobalVariables.uiLanguage) + "," + exported_asset.Exe + Environment.NewLine; data = data + resourceManager.GetString("lblAvailable", GlobalVariables.uiLanguage) + "," + exported_asset.Available + Environment.NewLine; for (int i = 0; i < exported_asset_commands.Count; i++) { data = data + resourceManager.GetString("lblCommands", GlobalVariables.uiLanguage) + i + "," + exported_asset_commands[i].Description + "," + exported_asset_commands[i].EnDescription + "," + exported_asset_commands[i].ArabicDescription + "," + exported_asset_commands[i].CommandText + "," + exported_asset_commands[i].Step + Environment.NewLine; } /*byte[] thumbnail= exported_asset_thumbnail.Thumbnail; * data = data + resourceManager.GetString("headerThumbnail", GlobalVariables.uiLanguage) + ","; * for (int i = 0; i < thumbnail.Length; i++) * { * data = data + thumbnail[i] + "-"; * } * data = data + Environment.NewLine;*/ /* using (MemoryStream memoryStream = new MemoryStream(exported_asset_thumbnail.Thumbnail)) * { * Bitmap bmp = new Bitmap(memoryStream); * data = data + resourceManager.GetString("headerThumbnail", GlobalVariables.uiLanguage) + "," + bmp + Environment.NewLine; * }*/ data = data.Replace("\r\n,", ","); data = data.Replace("\r\n\r\n", "\r\n"); System.IO.File.WriteAllText(file1.FileName, data); MessageBox.Show(resourceManager.GetString("msgScenarioExported", GlobalVariables.uiLanguage)); data = null; } } } catch (Exception) { } } else if (e.ColumnIndex == 5) { try { DialogResult delete = new DialogResult(); delete = MessageBox.Show(resourceManager.GetString("msgIsScenarioDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (delete == DialogResult.Yes) { GlobalVariables.Asset_Start_ID = Guid.Parse(scenarios_datagrid.Rows[e.RowIndex].Cells[1].Value.ToString()); using (VivosEntities db = new VivosEntities()) { List <AssetCommand> AssetCommandList = (from x in db.AssetCommands where x.AssetId == GlobalVariables.Asset_Start_ID select x).ToList(); AssetCommand[] asset_command = new AssetCommand[AssetCommandList.Count]; for (int i = 0; i < asset_command.Length; i++) { asset_command[i] = AssetCommandList[i]; db.AssetCommands.Remove(asset_command[i]); } Asset asset = db.Assets.First(x => x.Id == GlobalVariables.Asset_Start_ID); try { AssetThumbnail asset_thumbnail = db.AssetThumbnails.First(x => x.AssetId == GlobalVariables.Asset_Start_ID); db.AssetThumbnails.Remove(asset_thumbnail); } catch (Exception) { } db.Assets.Remove(asset); db.SaveChanges(); GlobalVariables.NewSessions_Search_Flag = 0; string key = null; fill_datagrid(key); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgScenarioDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception) { } } else if (e.ColumnIndex == 6) { try { GlobalVariables.Asset_Start_ID = Guid.Parse(scenarios_datagrid.Rows[e.RowIndex].Cells[1].Value.ToString()); GlobalVariables.Is_Edit = true; New_Scenario_Page new_scenario = new New_Scenario_Page(); this.Hide(); new_scenario.Show(); } catch (Exception) { } } }
public void edit_start() { if (GlobalVariables.Is_Edit == true) { using (VivosEntities db = new VivosEntities()) { List <Asset> AssetList = (from x in db.Assets where x.Id == GlobalVariables.Asset_Start_ID select x).ToList(); List <AssetThumbnail> AssetThumbnailList = (from x in db.AssetThumbnails where x.AssetId == GlobalVariables.Asset_Start_ID select x).ToList(); txtTurkishName.Text = AssetList[0].Name; txtTurkishDescription.Text = AssetList[0].Description; txtScenarioPath.Text = AssetList[0].Url; txtScenarioExe.Text = AssetList[0].Exe; txtEnglishName.Text = AssetList[0].EnName; txtEnglishDescription.Text = AssetList[0].EnDescription; txtArabicName.Text = AssetList[0].ArabicName; txtArabicDescription.Text = AssetList[0].ArabicDescription; if (AssetList[0].Available == true) { cbAvaliable.Checked = true; } else { cbAvaliable.Checked = false; } try { if (AssetThumbnailList[0].Thumbnail != null) { using (MemoryStream memoryStream = new MemoryStream(AssetThumbnailList[0].Thumbnail)) { Bitmap bmp = new Bitmap(memoryStream); pictureBox2.Image = bmp; } } } catch (Exception) { } List <AssetCommand> AssetCommandList = (from x in db.AssetCommands where x.AssetId == GlobalVariables.Asset_Start_ID orderby x.Step select x).ToList(); for (int i = 0; i < AssetCommandList.Count; i++) { commandsLayout.RowCount = commandsLayout.RowCount + 1; commandsLayout.Controls.Add(new TextBox() { Size = new Size(242, 20), Text = AssetCommandList[i].Description, Name = "txtTurkishExplanations" + (commandsLayout.RowCount - 1) }, 0, commandsLayout.RowCount - 1); commandsLayout.Controls.Add(new TextBox() { Size = new Size(242, 20), Text = AssetCommandList[i].EnDescription, Name = "txtEnglishExplanations" + (commandsLayout.RowCount - 1) }, 1, commandsLayout.RowCount - 1); commandsLayout.Controls.Add(new TextBox() { Size = new Size(242, 20), Text = AssetCommandList[i].ArabicDescription, Name = "txtArabicExplanations" + (commandsLayout.RowCount - 1) }, 2, commandsLayout.RowCount - 1); commandsLayout.Controls.Add(new TextBox() { Size = new Size(242, 20), Text = AssetCommandList[i].CommandText, Name = "txtCommands" + (commandsLayout.RowCount - 1) }, 3, commandsLayout.RowCount - 1); commandsLayout.Controls.Add(new TextBox() { Text = Convert.ToByte(AssetCommandList[i].Step).ToString(), Name = "txtSteps" + (commandsLayout.RowCount - 1) }, 4, commandsLayout.RowCount - 1); commandsLayout.Controls.Add(new TextBox() { Visible = false, Text = AssetCommandList[i].Id.ToString(), Name = "txtID" + (commandsLayout.RowCount - 1) }, 5, commandsLayout.RowCount - 1); txtTurkishExplanation.Add((commandsLayout.Controls.Find(("txtTurkishExplanations" + (commandsLayout.RowCount - 1)), true)[0]) as TextBox); txtEnglishExplanation.Add((commandsLayout.Controls.Find(("txtEnglishExplanations" + (commandsLayout.RowCount - 1)), true)[0]) as TextBox); txtArabicExplanation.Add((commandsLayout.Controls.Find(("txtArabicExplanations" + (commandsLayout.RowCount - 1)), true)[0]) as TextBox); txtCommand.Add((commandsLayout.Controls.Find(("txtCommands" + (commandsLayout.RowCount - 1)), true)[0]) as TextBox); txtStep.Add((commandsLayout.Controls.Find(("txtSteps" + (commandsLayout.RowCount - 1)), true)[0]) as TextBox); txtID.Add((commandsLayout.Controls.Find(("txtID" + (commandsLayout.RowCount - 1)), true)[0]) as TextBox); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (GlobalVariables.Is_Edit == false) { int flag = 0; if (String.IsNullOrEmpty(txtPatientCode.Text)) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgPatient", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (DateTime.Compare(clndrBirthday.Value, DateTime.Now) > 0) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgDate", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { using (VivosEntities db = new VivosEntities()) { List <Patient> patientList = (from x in db.Patients select x).ToList(); Patient new_patient = new Patient(); for (int i = 0; i < patientList.Count; i++) { if (patientList[i].Code == txtPatientCode.Text) { flag = 1; break; } } if (flag == 0) { new_patient.Code = txtPatientCode.Text.ToString(); new_patient.Id = Guid.NewGuid(); new_patient.DoctorId = GlobalVariables.LoginID; new_patient.IsApproved = true; new_patient.EntryDate = DateTime.Now; string[] doğumTarihi = (clndrBirthday.Value.ToString()).Split(' '); string[] sistemTarihi = (DateTime.Now.ToString()).Split(' '); if (doğumTarihi[0] == sistemTarihi[0]) { new_patient.DateOfBirth = null; } else { new_patient.DateOfBirth = clndrBirthday.Value; } new_patient.Notes = txtDescription.Text.ToString(); db.Patients.Add(new_patient); db.SaveChanges(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgPatientAdded", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (flag == 1) { MessageBox.Show(resourceManager.GetString("msgUserExists", GlobalVariables.uiLanguage)); } } } } else { if (String.IsNullOrEmpty(txtPatientCode.Text)) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgPatient", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (DateTime.Compare(clndrBirthday.Value, DateTime.Now) > 0) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgDate", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int flag1 = 0; using (VivosEntities db = new VivosEntities()) { Patient patient = (from x in db.Patients where x.Id == GlobalVariables.Edit_ID select x).SingleOrDefault(); if (patient != null) { if (patient.Code == txtPatientCode.Text) { string[] doğumTarihi = (clndrBirthday.Value.ToString()).Split(' '); string[] sistemTarihi = (DateTime.Now.ToString()).Split(' '); if (doğumTarihi[0] == sistemTarihi[0]) { patient.DateOfBirth = null; } else { patient.DateOfBirth = clndrBirthday.Value; } patient.Notes = txtDescription.Text.ToString(); db.SaveChanges(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgPatientEdited", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { List <Patient> patientList = (from x in db.Patients select x).ToList(); for (int i = 0; i < patientList.Count; i++) { if (patientList[i].Code == txtPatientCode.Text) { flag1 = 1; break; } } if (flag1 == 0) { patient.Code = txtPatientCode.Text; string[] doğumTarihi = (clndrBirthday.Value.ToString()).Split(' '); string[] sistemTarihi = (DateTime.Now.ToString()).Split(' '); if (doğumTarihi[0] == sistemTarihi[0]) { patient.DateOfBirth = null; } else { patient.DateOfBirth = clndrBirthday.Value; } patient.Notes = txtDescription.Text.ToString(); db.SaveChanges(); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgPatientEdited", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (flag1 == 1) { MessageBox.Show(resourceManager.GetString("msgUserExists", GlobalVariables.uiLanguage)); } } } } } } }
private void btnLogin_Click(object sender, EventArgs e) { //Checks the case of all textboxes are filled try { if (String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtPassword.Text)) { DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgFields", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { using (VivosEntities db = new VivosEntities()) { Consumer consumer = (Consumer)(from x in db.Consumers where x.Email.Equals(txtUsername.Text) select x).FirstOrDefault(); if (consumer != null) { User user = (User)(from x in db.Users where consumer.Id.Equals(x.Id) && x.Password.Equals(txtPassword.Text) select x).FirstOrDefault(); if (user != null) { GlobalVariables.LoginID = consumer.Id; if (consumer.Code.Equals("admin")) { Admin_Page admin = new Admin_Page(); this.Hide(); admin.Show(); } else { Patients_Page patients = new Patients_Page(); this.Hide(); patients.Show(); } return; } } } DialogResult error = new DialogResult(); error = MessageBox.Show(resourceManager.GetString("msgWrong", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { /*SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS" + ";" + ";Integrated Security=True"); * con.Open(); * string str = "USE Master;"; * //string str1 = "ALTER DATABASE Vivos SET SINGLE_USER WITH ROLLBACK IMMEDIATE;"; * string str2 = "RESTORE DATABASE Vivos FROM DISK='.\\Vivos.bak' WITH REPLACE"; * SqlCommand cmd = new SqlCommand(str, con); * //SqlCommand cmd1 = new SqlCommand(str1, con); * SqlCommand cmd2 = new SqlCommand(str2, con); * cmd.ExecuteNonQuery(); * // cmd1.ExecuteNonQuery(); * cmd2.ExecuteNonQuery(); * con.Close();*/ } }
public void fill_datagrid(string key) { using (VivosEntities db = new VivosEntities()) { sessions_datagrid.Rows.Clear(); sessions_datagrid.ColumnCount = 3; sessions_datagrid.Columns[0].Visible = false; sessions_datagrid.Columns[1].Name = resourceManager.GetString("headerDateTime", GlobalVariables.uiLanguage); sessions_datagrid.Columns[2].Name = resourceManager.GetString("headerScenario", GlobalVariables.uiLanguage); sessions_datagrid.RowTemplate.Height = 30; sessions_datagrid.BorderStyle = BorderStyle.None; sessions_datagrid.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249); sessions_datagrid.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal; sessions_datagrid.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise; sessions_datagrid.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke; sessions_datagrid.BackgroundColor = Color.White; sessions_datagrid.EnableHeadersVisualStyles = false; sessions_datagrid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; sessions_datagrid.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72); sessions_datagrid.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; add_button(); for (int i = 0; i < sessions_datagrid.ColumnCount - 2; i++) { sessions_datagrid.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; sessions_datagrid.Columns[i].DefaultCellStyle.Font = new Font("Times New Roman", 12, FontStyle.Regular); } List <Session> sessionlist1 = (from x in db.Sessions join s in db.Assets on x.AssetId equals s.Id where x.PatientId == GlobalVariables.Session_ID orderby s.Name select x).ToList(); List <Asset> assetlist = (from x in db.Assets select x).ToList(); List <Session> sessionlist2 = (from x in db.Sessions join s in db.Assets on x.AssetId equals s.Id where s.Name.StartsWith(key) && x.PatientId == GlobalVariables.Session_ID orderby s.Name select x).ToList(); List <Session> keyList = null; if (GlobalVariables.Sessions_Search_Flag == 0) { keyList = sessionlist1; } else { keyList = sessionlist2; } for (int i = 0; i < keyList.Count; i++) { i = sessions_datagrid.Rows.Add(); sessions_datagrid.Rows[i].Cells[0].Value = keyList[i].Id; if (keyList[i].SessionDateTime != null) { sessions_datagrid.Rows[i].Cells[1].Value = Convert.ToDateTime(keyList[i].SessionDateTime).ToString("dd/MM/yyyy HH:mm ", System.Globalization.CultureInfo.InvariantCulture); } else { sessions_datagrid.Rows[i].Cells[1].Value = null; } for (int j = 0; j < assetlist.Count; j++) { if (keyList[i].AssetId == assetlist[j].Id) { if (Convert.ToString(GlobalVariables.uiLanguage) == "en-US") { sessions_datagrid.Rows[i].Cells[2].Value = assetlist[j].EnName; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "tr-TR") { sessions_datagrid.Rows[i].Cells[2].Value = assetlist[j].Name; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "ar-SA") { sessions_datagrid.Rows[i].Cells[2].Value = assetlist[j].ArabicName; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "fr-FR") { sessions_datagrid.Rows[i].Cells[2].Value = assetlist[j].FrName; } break; } } } } }
private void sessions_datagrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 3) { try { DialogResult delete = new DialogResult(); delete = MessageBox.Show(resourceManager.GetString("msgIsSessionDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgWarning", GlobalVariables.uiLanguage), MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (delete == DialogResult.Yes) { GlobalVariables.Session_Data_ID = Guid.Parse(sessions_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); using (VivosEntities db = new VivosEntities()) { List <Session> sessionlist = (from x in db.Sessions where x.Id == GlobalVariables.Session_Data_ID select x).ToList(); Session session = db.Sessions.First(x => x.Id == GlobalVariables.Session_Data_ID); db.Sessions.Remove(session); db.SaveChanges(); GlobalVariables.Sessions_Search_Flag = 0; string key = null; fill_datagrid(key); DialogResult information = new DialogResult(); information = MessageBox.Show(resourceManager.GetString("msgSessionDeleted", GlobalVariables.uiLanguage), resourceManager.GetString("msgInformation", GlobalVariables.uiLanguage), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception) { } } else if (e.ColumnIndex == 4) { try { GlobalVariables.Session_Data_ID = Guid.Parse(sessions_datagrid.Rows[e.RowIndex].Cells[0].Value.ToString()); using (VivosEntities db = new VivosEntities()) { List <Session> sessionlist = (from x in db.Sessions where x.Id == GlobalVariables.Session_Data_ID select x).ToList(); List <Asset> assetlist = (from x in db.Assets select x).ToList(); for (int i = 0; i < assetlist.Count; i++) { if (assetlist[i].Id == sessionlist[0].AssetId) { if (Convert.ToString(GlobalVariables.uiLanguage) == "en-US") { GlobalVariables.Session_Data_name = assetlist[i].EnName; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "tr-TR") { GlobalVariables.Session_Data_name = assetlist[i].Name; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "ar-SA") { GlobalVariables.Session_Data_name = assetlist[i].ArabicName; } else if (Convert.ToString(GlobalVariables.uiLanguage) == "fr-FR") { GlobalVariables.Session_Data_name = assetlist[i].FrName; } break; } } if (sessionlist[0].SessionDateTime != null) { GlobalVariables.Session_Data_date = Convert.ToDateTime(sessionlist[0].SessionDateTime).ToString("dd.MM.yyyy HH.mm ", System.Globalization.CultureInfo.InvariantCulture); } else { GlobalVariables.Session_Data_date = null; } } createDoc(); } catch (Exception) { } } }
public void createDoc() { SaveFileDialog file1 = new SaveFileDialog(); file1.InitialDirectory = ".\\desktop"; file1.Filter = "Excel Dosyası|*.xls"; file1.FileName = GlobalVariables.Session_ID_name + "_" + GlobalVariables.Session_Data_name + "_" + GlobalVariables.Session_Data_date; if (file1.ShowDialog() == DialogResult.OK) { file = file1.FileName.ToString(); Workbook workbook = new Workbook(); Worksheet worksheet = new Worksheet("First Sheet"); using (VivosEntities db = new VivosEntities()) { int k = 0; List <Session> sessionlist = (from x in db.Sessions where x.Id == GlobalVariables.Session_Data_ID select x).ToList(); if (sessionlist == null) { MessageBox.Show(resourceManager.GetString("msgData", GlobalVariables.uiLanguage)); } else { string data = sessionlist[0].SensorData.ToString(); data = data.Replace("\r\n", ","); string[] data1 = (data.Split(',')); worksheet.Cells.ColumnWidth[0, 0] = 4000; worksheet.Cells.ColumnWidth[0, 1] = 4000; worksheet.Cells.ColumnWidth[0, 2] = 4000; worksheet.Cells[0, 0] = new Cell(GlobalVariables.Session_ID_name); worksheet.Cells[0, 1] = new Cell(GlobalVariables.Session_Data_name); worksheet.Cells[0, 2] = new Cell(GlobalVariables.Session_Data_date); int i = 2; for (int a = 0; a < data1.Length / 7; a++) { for (int j = 0; j < 7; j++) { worksheet.Cells[i, j] = new Cell(data1[k].ToString()); k++; } i++; } workbook.Worksheets.Add(worksheet); workbook.Save(file); Workbook book = Workbook.Load(file); Worksheet sheet = book.Worksheets[0]; MessageBox.Show(resourceManager.GetString("msgDataDownloaded", GlobalVariables.uiLanguage)); } } /*Excel.Application xlApp; * Excel.Workbooks xlWorkbooks; * Excel.Workbook xlWorkBook; * Excel.Sheets xlWorksheets; * Excel.Worksheet xlWorkSheet; * * object misValue = Type.Missing; * xlApp = new Excel.Application(); * xlWorkbooks = xlApp.Workbooks; * //xlWorkBook = xlWorkbooks.Open(file, misValue, false, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue); * xlWorkBook = xlWorkbooks.Add(); * xlWorksheets = xlWorkBook.Worksheets; * xlWorkSheet = (Excel.Worksheet)xlWorksheets.get_Item(1); * * * using (VivosEntities db = new VivosEntities()) * { * * int k = 0; * List<Session> sessionlist = (from x in db.Sessions where x.Id == GlobalVariables.Session_Data_ID select x).ToList(); * if (sessionlist == null) * MessageBox.Show(resourceManager.GetString("msgData", GlobalVariables.uiLanguage)); * else * { * string data = sessionlist[0].SensorData.ToString(); * data = data.Replace("\r\n", ","); * string[] data1 = (data.Split(',')); * xlWorkSheet.Columns[1].ColumnWidth = 24; * xlWorkSheet.Columns[2].ColumnWidth = 24; * xlWorkSheet.Columns[3].ColumnWidth = 24; * xlWorkSheet.Cells[1, 1] = GlobalVariables.Session_ID_name; * xlWorkSheet.Cells[1, 2] = GlobalVariables.Session_Data_name; * xlWorkSheet.Cells[1, 3] = GlobalVariables.Session_Data_date; * int i = 3; * for (int a = 0; a < data1.Length / 7; a++) * { * for (int j = 1; j < 8; j++) * { * xlWorkSheet.Cells[i, j] = data1[k].ToString(); * k++; * } * i++; * } * * * Excel.Range chartRange; * Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing); * Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(400, 48, 300, 250); * Excel.Chart chartPage = myChart.Chart; * //chartRange = xlWorkSheet.get_Range("A2", "C" + (1 + data1.Length / 7)); * chartRange = xlWorkSheet.get_Range("A3:A" + ((2 + data1.Length / 7)).ToString() + ", C3:C" + ((2 + data1.Length / 7)).ToString()); * chartPage.SetSourceData(chartRange, misValue); * chartPage.ChartType = Excel.XlChartType.xlLine; * * Excel.Range chartRange1; * Excel.ChartObjects xlCharts1 = xlWorkSheet.ChartObjects(Type.Missing); * Excel.ChartObject myChart1 = xlCharts.Add(400,328, 300, 250); * Excel.Chart chartPage1 = myChart1.Chart; * //chartRange1 = xlWorkSheet.get_Range("A2", "C" + (1 + data1.Length / 7)); * chartRange1 = xlWorkSheet.get_Range("A3:A" + ((2 + data1.Length / 7)).ToString() + ", B3:B" + ((2 + data1.Length / 7)).ToString()); * chartPage1.SetSourceData(chartRange1, misValue); * chartPage1.ChartType = Excel.XlChartType.xlLine; * * xlWorkBook.SaveAs(file, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); * xlWorkBook.Close(false, misValue, misValue); * xlApp.Quit(); * * * * * Marshal.ReleaseComObject(xlCharts); * xlCharts = null; * * Marshal.ReleaseComObject(xlCharts1); * xlCharts1 = null; * * Marshal.ReleaseComObject(myChart); * myChart = null; * * Marshal.ReleaseComObject(myChart1); * myChart1 = null; * * Marshal.ReleaseComObject(chartPage); * chartPage = null; * * Marshal.ReleaseComObject(chartPage1); * chartPage1 = null; * * Marshal.ReleaseComObject(chartRange); * chartRange = null; * * Marshal.ReleaseComObject(chartRange1); * chartRange1 = null; * * Marshal.ReleaseComObject(xlWorkSheet); * xlWorkSheet = null; * * Marshal.ReleaseComObject(xlWorksheets); * xlWorksheets = null; * * Marshal.ReleaseComObject(xlWorkBook); * xlWorkBook = null; * * Marshal.ReleaseComObject(xlWorkbooks); * xlWorkbooks = null; * * xlApp.Quit(); * * Marshal.ReleaseComObject(xlApp); * xlApp = null; * * * releaseObject(xlWorkSheet); * releaseObject(xlWorkBook); * releaseObject(xlApp); * * MessageBox.Show(resourceManager.GetString("msgDataDownloaded", GlobalVariables.uiLanguage)); * * * } * }*/ } }