//ACTUALIZAR public void actualizarFormulario_anticipo(int indice, FORMULARIO__ANTICIPO formulario_anticipo) { using (TransactionScope transaction = new TransactionScope()) { var objFormulario_anticipo = modeloEntidades.FORMULARIO__ANTICIPO.Where(qq => qq.IDFORMANTICIPO == indice).Single(); modeloEntidades.Entry(objFormulario_anticipo).CurrentValues.SetValues(formulario_anticipo); modeloEntidades.SaveChanges(); transaction.Complete(); } }
//INSERTAR public void insertarFormulario_anticipo(FORMULARIO__ANTICIPO formulario_anticipo) { using (TransactionScope transaction = new TransactionScope()) { using (modeloEntidades) { modeloEntidades.FORMULARIO__ANTICIPO.Add(formulario_anticipo); modeloEntidades.SaveChanges(); transaction.Complete(); } } }
private void btnGuardar_Click(object sender, EventArgs e) { String strError = ""; Boolean bolError = false; if (mskNumeroSolicitud.Text == "") { strError += "El numero de Solicitud es obligatorio\n"; bolError = true; } if (txtCiudad.Text == "") { strError += "La Ciudad es Obligatoria\n"; bolError = true; } if (txtDetalleActividades.Text == "") { strError += "El Detalle es Obligatorio\n"; bolError = true; } if (txtNombreBanco.Text == "") { strError += "El Nombre del Banco es Obligatorio\n"; bolError = true; } if (txtNumCuenta.Text == "") { strError += "El Numero de Cuenta es Obligatorio\n"; bolError = true; } if (cmbEmpleados.SelectedIndex == -1) { strError += "El Tipo de Cuenta es Obligatoria\n"; bolError = true; } //if (DateTime.Compare(dtpFechaSalidaGen.Value, DateTime.Now) < 0 ) //{ // strError += "La Fecha de Salida no es valida\n"; // bolError = true; //} //if (DateTime.Compare(dtpFechaLlegadaGen.Value, dtpFechaSalidaGen.Value) < 0) //{ // strError += "La Fecha de Llegada no puede se antes de la de Salida\n"; // bolError = true; //} if (cmbCombinacionViaticos.SelectedIndex == 0 && ((Int32)(dtpFechaLlegadaGen.Value).Subtract(dtpFechaSalidaGen.Value).TotalHours) > 8) { strError += "La Subsistencia solo puede durar menos de 8 Horas\n"; bolError = true; } if (cmbCombinacionViaticos.SelectedIndex == 1 && ((Int32)(dtpFechaLlegadaGen.Value).Subtract(dtpFechaSalidaGen.Value).TotalHours) > 8) { strError += "La Subsistencia/Movilizacion solo puede durar menos de 8 Horas\n"; bolError = true; } if (!bolError) { FORMULARIO__ANTICIPO formularioAnticipo = new FORMULARIO__ANTICIPO(); formularioAnticipo.BANCOFORMANTICIPO = txtNombreBanco.Text; formularioAnticipo.CIUDADFORMANTICIPO = txtCiudad.Text; formularioAnticipo.IDCOMBINACION = Convert.ToInt32(cmbCombinacionViaticos.SelectedValue); formularioAnticipo.DESCRIPCIONFORMANTICIPO = txtDetalleActividades.Text; formularioAnticipo.IDEMP = Convert.ToInt32(cmbEmpleados.SelectedValue); formularioAnticipo.NUMCUENTAFORMANTICIPO = txtNumCuenta.Text; formularioAnticipo.NUMFORMANTICIPO = mskNumeroSolicitud.Text; formularioAnticipo.TIPOCUENTAFORMANTICIPO = cmbTipoCuenta.SelectedItem.ToString(); formularioAnticipo.UNIDADFORMANTICIPO = cmbUnidad.SelectedItem.ToString(); formularioAnticipo.ESTADOFORMANTICIPO = "EMITIDO"; formularioAnticipo.FECFORMANTICIPO = DateTime.Now; DateTime llegada = dtpFechaLlegadaGen.Value.Date + dtpHoraLlegadaGen.Value.TimeOfDay; formularioAnticipo.LLEGADAFORMANTICIPO = llegada; DateTime salida = dtpFechaSalidaGen.Value.Date + dtpHoraSalidaGen.Value.TimeOfDay; formularioAnticipo.SALIDAFORMANTICIPO = salida; if (listaDetalleFormulario.Any()) { formularioAnticipo.DETALLE_FORMULARIO = listaDetalleFormulario; } Form frmCalculo = new frmCalculoMontoAnticipo(formularioAnticipo); frmCalculo.ShowDialog(this); } else { MessageBox.Show(strError); } }
public frmCalculoMontoAnticipo(FORMULARIO__ANTICIPO formulario) { InitializeComponent(); this.formularioAnticipo = formulario; }