public void InsertRegenerationLine(LINEAREGENERACION RegenerationLine) { try { this.sifcaRepository.LINEAREGENERACION.Add(RegenerationLine); } catch (Exception ex) { throw ex; } }
private void guardarRegenBtn_Click(object sender, EventArgs e) { try { bool error = false; if (especieRegenCbx.SelectedItem == null) { controladorErrores.SetError(especieRegenCbx, "Seleccione una especie."); error = true; } if (decimal.Parse(latizalTxt.Text) < 0) { controladorErrores.SetError(latizalTxt, "El valor del latizal debe ser mayor que cero."); error = true; } if (decimal.Parse(brinzalTxt.Text) < 0) { controladorErrores.SetError(brinzalTxt, "El valor del brinzal debe ser mayor que cero."); error = true; } if (error) return; controladorErrores.Clear(); LINEAREGENERACION currentLine = (LINEAREGENERACION)regeneracionBS.Current; FORMULARIO f = form.GetForm(newForm.NROFORMULARIO); if (currentLine.LINEAREGEN == Guid.Empty) { LINEAREGENERACION newLine =new LINEAREGENERACION(); newLine.LINEAREGEN = Guid.NewGuid(); newLine.FORMULARIO = f; newLine.ESPECIE = (ESPECIE)especieRegenCbx.SelectedItem; newLine.LATIZAL = decimal.Parse(latizalTxt.Text); newLine.BRINZAL = decimal.Parse(brinzalTxt.Text); lineRegen.InsertRegenerationLine(newLine); string resultSaveChangues = lineRegen.SaveChanges(); if (resultSaveChangues == string.Empty) { f = form.GetForm(newForm.NROFORMULARIO); regeneracionBS.DataSource = f.LINEAREGENERACION.ToList(); regeneracionBN.Refresh(); regeneracionBS.AddNew(); MessageBox.Show("Los datos fueron almacenados de manera exitosa.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Error_Form errorForm = new Error_Form(resultSaveChangues); errorForm.MdiParent = ParentForm; errorForm.Show(); } } else { currentLine.ESPECIE = (ESPECIE)especieRegenCbx.SelectedItem; currentLine.LATIZAL = decimal.Parse(latizalTxt.Text); currentLine.BRINZAL = decimal.Parse(brinzalTxt.Text); lineRegen.UpdateRegenerationLine(currentLine); string resultSaveChangues = lineRegen.SaveChanges(); if (resultSaveChangues == string.Empty) { f = form.GetForm(newForm.NROFORMULARIO); regeneracionBS.DataSource = f.LINEAREGENERACION.ToList(); regeneracionBN.Refresh(); MessageBox.Show("Los datos fueron Actualizados de manera exitosa.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Error_Form errorForm = new Error_Form(resultSaveChangues); errorForm.MdiParent = ParentForm; errorForm.Show(); } } PROYECTO result = project.GetProject(newForm.PROYECTO.NROPROY); Program.Cache.Add("project", result, new CacheItemPolicy()); } catch (Exception ex) { Error_Form errorForm = new Error_Form(ex.Message); errorForm.MdiParent = ParentForm; errorForm.Show(); } }
public void UpdateRegenerationLine(LINEAREGENERACION RegenerationLine) { try { this.sifcaRepository.Entry(RegenerationLine).State = EntityState.Modified; } catch (Exception ex) { throw ex; } }