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)
                 * {
                 *
                 *
                 * }*/
            }
        }
Ejemplo n.º 2
0
        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));
                    }
                }
            }
        }
Ejemplo n.º 3
0
 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)
     {
     }
 }
Ejemplo n.º 4
0
 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));
             }
         }
     }
 }
Ejemplo n.º 5
0
        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)
                {
                }
            }
        }
Ejemplo n.º 6
0
        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)
                {
                }
            }
        }
Ejemplo n.º 7
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)
            {
            }
        }
Ejemplo n.º 8
0
 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)
         {
         }
     }
 }
Ejemplo n.º 9
0
        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));
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        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();
                    }
                }
            }
        }