private void btnBack_Click(object sender, EventArgs e) { Admin_Page admin = new Admin_Page(); this.Hide(); admin.Show(); }
private void btnBack_Click(object sender, EventArgs e) { GlobalVariables.NewSessions_Search_Flag = 0; Admin_Page admin_page = new Admin_Page(); this.Hide(); admin_page.Show(); }
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 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();*/ } }
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(); } } } }