public override bool MH_NuevoRegistro() { bool resultado = false; string mensaje = ""; VSeleccion vSeleccion = new VSeleccion() { IdSucur = Convert.ToInt32(Cb_Almacen.Value), IdCompraIng = Convert.ToInt32(Tb_IdCompraIngreso.Text), Estado = 1, Cantidad = Convert.ToDecimal(Tb_TCantidad.Value), Precio = Convert.ToDecimal(Tb_TPrecio.Value), Total = Convert.ToDecimal(Tb_Total.Value), Fecha = DateTime.Now.Date, Hora = DateTime.Now.ToString("hh:mm"), Usuario = UTGlobal.Usuario, Merma = Convert.ToDecimal(Tb_MERMA.Value) }; int id = Tb_Id.Text == string.Empty ? 0 : Convert.ToInt32(Tb_Id.Text); int idAux = id; var detalle = ((List <VSeleccion_01>)Dgv_Seleccion.DataSource).ToArray <VSeleccion_01>(); resultado = new ServiceDesktop.ServiceDesktopClient().Seleccion_Guardar(vSeleccion, detalle, ref id, TxtNombreUsu.Text); if (resultado) { if (idAux == 0)//Registar { Tb_NUmGranja.Focus(); MP_CargarEncabezado(); MP_Limpiar(); _Limpiar = true; mensaje = GLMensaje.Nuevo_Exito(_NombreFormulario, id.ToString()); } else//Modificar { MP_Filtrar(1); MP_InHabilitar();//El formulario _Limpiar = true; mensaje = GLMensaje.Modificar_Exito(_NombreFormulario, id.ToString()); MH_Habilitar();//El menu } } //Resultado if (resultado) { ToastNotification.Show(this, mensaje, PRESENTER.Properties.Resources.GRABACION_EXITOSA, (int)GLMensajeTamano.Chico, eToastGlowColor.Green, eToastPosition.TopCenter); } else { mensaje = GLMensaje.Registro_Error(_NombreFormulario); ToastNotification.Show(this, mensaje, PRESENTER.Properties.Resources.CANCEL, (int)GLMensajeTamano.Chico, eToastGlowColor.Green, eToastPosition.TopCenter); } return(resultado); }
public bool Seleccion_Guardar(VSeleccion vSeleccion, List <VSeleccion_01> detalle, ref int id, string usuario) { try { var result = new LSeleccion().Guardar(vSeleccion, detalle, ref id, usuario); return(result); } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool Guardar(VSeleccion vSeleccion, List <VSeleccion_01> detalle, ref int Id, string usuario) { try { using (var scope = new TransactionScope()) { var result = iSeleccion.Guardar(vSeleccion, ref Id); var resultDetalle = new LSeleccion_01().Guardar(detalle, Id); scope.Complete(); return(result); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool Guardar(VSeleccion vSeleccion, ref int id) { try { using (var db = GetEsquema()) { var idAux = id; Seleccion seleccion; if (id > 0) { seleccion = db.Seleccion.Where(a => a.Id == idAux).FirstOrDefault(); if (seleccion == null) { throw new Exception("No existe la seleccion con id " + idAux); } } else { seleccion = new Seleccion(); db.Seleccion.Add(seleccion); } seleccion.IdSucur = vSeleccion.IdSucur; seleccion.IdCompraIng = vSeleccion.IdCompraIng; seleccion.Estado = vSeleccion.Estado; seleccion.Cantidad = vSeleccion.Cantidad; seleccion.Precio = vSeleccion.Precio; seleccion.Total = vSeleccion.Total; seleccion.Fecha = vSeleccion.Fecha; seleccion.Hora = vSeleccion.Hora; seleccion.Usuario = vSeleccion.Usuario; seleccion.Merma = vSeleccion.Merma; db.SaveChanges(); id = seleccion.Id; return(true); } } catch (Exception ex) { throw new Exception(ex.Message); } }