/// <summary> /// Makes an update in database and in form fields with entered data /// </summary> private void UpdateProfessorDetails() { try { _currentProfessor.Ime = txtIme.Text; _currentProfessor.Prezime = txtPrezime.Text; _currentProfessor.KorisnickoIme = txtKorisnickoIme.Text; _currentProfessor.Lozinka = txtLozinka.Text; _currentProfessor.DatumRodjenja = txtDatumRodjenja.Text; _currentProfessor.DatumZaposlenja = txtDatumZaposlenja.Text; _currentProfessor.Email = txtEmail.Text; _currentProfessor.JMBG = txtJMBG.Text; _currentProfessor.Ucionica = txtUcionica.Text; _currentProfessor.RadnaPozicija = txtRadnaPozicija.Text; _currentProfessor.BrojTelefona = txtBrojTelefona.Text; if (rbMale.Checked) { _currentProfessor.Spol = "Musko"; } else { _currentProfessor.Spol = "Zensko"; } _currentProfessor.Slika = ImageConventer.FromImageToByte(pbSlikaProfesora.Image); databaseConnection.Entry(_currentProfessor).State = EntityState.Modified; databaseConnection.SaveChanges(); MessageBox.Show($"Data successfully changed!"); } catch (Exception ex) { MessageBox.Show($"Greska u povezivanju sa bazom -> {ex.Message} {ex.InnerException?.Message}"); } }
private void FuncCommandExecute() { //runflag = true; //stepnum = 0; //System.Diagnostics.Process[] myProcesses = System.Diagnostics.Process.GetProcessesByName("USBKB");//获取指定的进程名 //if (myProcesses.Length >= 1) //如果可以获取到知道的进程名则说明已经启动 //{ // var image = screenCapture.CaptureWindow(myProcesses[0].MainWindowHandle); var image = screenCapture.CaptureScreen(); var bitmap = new System.Drawing.Bitmap(image); CameraIamge = ImageConventer.ConvertBitmapToHalconImage(bitmap); //} }
public void SaveMacroPlanTest(string imagepath) { //assign var shapemodelpath = "filepath"; var note = "note"; var exportUnit = "mm"; var image = new HImage(imagepath); var imageBinData = new Binary(ImageConventer.ConvertHalconImageToByteArray(image, false)); var matchingParam = new MatchingParam(); var matchingParamByteArray = ModelSerializer.DoSerialize(matchingParam); var matchingParamBinData = new Binary(matchingParamByteArray); BindingList <GeoDataGridViewModel> a = new BindingList <GeoDataGridViewModel>(); a.Add(new GeoDataGridViewModel() { RecordID = "aaa" }); var measureBinData = ModelSerializer.DoSerialize(a); //BindingList a; var ma = new MeasureAssistant(); var maParam = ma.GetMeasureAssistantParam(); var maParamBin = ModelSerializer.DoSerialize(maParam); LightChannel upper = new LightChannel() { Channel = "00", Intensity = 100, OnOff = LightSwitch.On }; LightChannel bottom = new LightChannel() { Channel = "01", Intensity = 200, OnOff = LightSwitch.OFF }; //act var success = SDMSRepo.SaveMacroPlan("Test", Guid.NewGuid().ToString(), shapemodelpath, note, imageBinData, exportUnit, matchingParamBinData, measureBinData, maParamBin, upper, bottom, new ShapeViewModel() { }, "system", ""); //assert Assert.True(success); }
private void UcitajPodatke(Student student) { lblStudentHeader.Text = student.Ime + " " + student.Prezime + " details"; lblBrojIndeksa.Text = student.BrojIndeksa; lblIme.Text = student.Ime; lblPrezime.Text = student.Prezime; lblDatumRodjenja.Text = student.DatumRodjenja; lblSpol.Text = student.Spol; lblEmail.Text = student.Email; lblGodinaStudija.Text = student.GodinaStudija; lblGodine.Text = student.Godine.ToString(); lblImeOca.Text = student.ImeOca; if (ImageConventer.FromByteToImage(student.Slika) != null) { pbSlikaStudenta.Image = ImageConventer.FromByteToImage(student.Slika); } else { pbSlikaStudenta.Image = null; } }
/// <summary> /// Adds new subject with all his data in DB /// </summary> private void btnAddSubject_Click(object sender, EventArgs e) { if (ValidirajPolja()) { konekcijaNaBazu.Predmeti.Add(new Predmet() { PredmetCode = txtSubjectCode.Text, NazivPredmeta = txtSubjectName.Text, GodinaStudija = cmbYearOfStudy.SelectedItem.ToString(), ECTS = int.Parse(txtECTS.Text), BrojSatiPredavanja = int.Parse((cmbLessonHours.SelectedItem).ToString()), BrojSatiVjezbi = int.Parse((cmbPracticeHours.SelectedItem).ToString()), Profesor = (cmbProfesori.SelectedItem as Profesor).ToString(), Dogadjaj = txtAction.Text, Syllabus = ImageConventer.FromImageToByte(pbSyllabusPic.Image) }); konekcijaNaBazu.SaveChanges(); MessageBox.Show($"Subject {txtSubjectName.Text} successfully added!"); DialogResult = DialogResult.OK; Close(); } }
private void UcitajPolja() { if (_currentProfessor != null) { txtIme.Text = _currentProfessor.Ime; txtPrezime.Text = _currentProfessor.Prezime; txtKorisnickoIme.Text = _currentProfessor.KorisnickoIme; txtLozinka.Text = _currentProfessor.Lozinka; txtDatumRodjenja.Text = _currentProfessor.DatumRodjenja; if (_currentProfessor.Spol == "Musko") { rbMale.Checked = true; } else { rbFemale.Checked = true; } txtEmail.Text = _currentProfessor.Email; txtJMBG.Text = _currentProfessor.JMBG; txtBrojTelefona.Text = _currentProfessor.BrojTelefona; txtUcionica.Text = _currentProfessor.Ucionica; txtRadnaPozicija.Text = _currentProfessor.RadnaPozicija; if (_currentProfessor.Slika.Length != 0) { pbSlikaProfesora.Image = ImageConventer.FromByteToImage(_currentProfessor.Slika); } else { pbSlikaProfesora.Image = null; } txtDatumZaposlenja.Text = _currentProfessor.DatumZaposlenja; } else { MessageBox.Show($"Nije moguce ucitati podatke!"); } }
/// <summary> /// Validates and saves all data from input fields to a new student and adds him to DB /// </summary> private void btnSaveStudent_Click(object sender, EventArgs e) { if (ValidinaPolja()) { string godina = cmbGodine.SelectedItem.ToString(); konekcijaNaBazu.Studenti.Add(new Student() { BrojIndeksa = txtBrojIndeksa.Text, Ime = txtIme.Text, Prezime = txtPrezime.Text, ImeOca = txtImeOca.Text, DatumRodjenja = dtmDatumRodjenja.Value.ToShortDateString(), Email = txtEmail.Text, Spol = ProvjeraChecked(), GodinaStudija = cmbGodinaStudija.SelectedItem.ToString(), Godine = int.Parse(godina), Slika = ImageConventer.FromImageToByte(pbSlikaStudenta.Image) }); konekcijaNaBazu.SaveChanges(); MessageBox.Show($"Student successfully added!"); DialogResult = DialogResult.OK; Close(); } }