private void ClearFields() { this.p = null; this.c = null; this.m = null; this.pr = null; this.cbxProducto.SelectedIndex = -1; this.cbxComprobante.SelectedIndex = -1; lblCodProd.Text = "Código de producto:"; lblPrecioUni.Text = "Precio unitario:"; lblComposicion.Text = "Composición:"; lblCantUni.Text = "Cantidad por unidad:"; lblCategoria.Text = "Categoría:"; lblMarca.Text = "Marca:"; lblPresentacion.Text = "Presentación:"; lblStock.Text = "Stock:"; //this.cbMarca.SelectedIndex = -1; //this.cbPresentacion.SelectedIndex = -1; //this.cbCategoria.SelectedIndex = -1; //this.cbPrescripcion.Checked = false; //this.txtComposicion.Text = ""; //this.txtNombre.Text = ""; }
public IHttpActionResult PutPresentacion(Presentacion presentacion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (presentacion.ultimoUsr == null || presentacion.ultimoUsr == 0) { return(BadRequest("no hay usuario para guardar")); } presentacion.ultimaFec = DateTime.Now; db.Entry(presentacion).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PresentacionExists(presentacion.idPresentacion)) { return(NotFound()); } else { throw; } } return(Ok(presentacion)); }
public IHttpActionResult PostPresentacion(Presentacion presentacion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Presentacion.Add(presentacion); try { db.SaveChanges(); } catch (DbUpdateException) { if (PresentacionExists(presentacion.idPresentacion)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = presentacion.idPresentacion }, presentacion)); }
public List <Presentacion> allSucursales() { List <Presentacion> lstTipos = null; Presentacion cl = null; Conexion con = new Conexion(); try { string query = "SELECT * FROM Presentacion"; cmd = new SqlCommand(query, con.getConex()); con.Dr = cmd.ExecuteReader(); lstTipos = new List <Presentacion>(); while (con.Dr.Read()) { cl = new Presentacion(); cl.CodPresentacion = con.Dr.GetInt32(0); cl.Descripcion = con.Dr.GetString(1); cl.CantidadUnidad = con.Dr.GetDecimal(2); lstTipos.Add(cl); } } catch (Exception e) { Console.WriteLine("Error: {0}", e); lstTipos = null; } finally { con.close(); } return(lstTipos); }
public Presentacion sucursalByCodigo(int code) { Presentacion cl = null; Conexion con = new Conexion(); try { string query = "SELECT * FROM Presentacion WHERE cod_pre=@cod"; cmd = new SqlCommand(query, con.getConex()); cmd.Parameters.AddWithValue("@cod", code); con.Dr = cmd.ExecuteReader(); while (con.Dr.Read()) { cl = new Presentacion(); cl.CodPresentacion = con.Dr.GetInt32(0); cl.Descripcion = con.Dr.GetString(1); cl.CantidadUnidad = con.Dr.GetDecimal(2); } } catch (Exception e) { Console.WriteLine("Error: {0}", e); cl = null; } finally { con.close(); } return(cl); }
public string update(Presentacion cl) { try { string query = "UPDATE Presentacion SET "; query += "descripcion_pre=@des, con_uni_pre=@can WHERE cod_pre=@id"; cmd = new SqlCommand(query, con.getConex()); cmd.Parameters.AddWithValue("@des", cl.Descripcion); cmd.Parameters.AddWithValue("@can", cl.CantidadUnidad); cmd.Parameters.AddWithValue("@id", cl.CodPresentacion); if (cmd.ExecuteNonQuery() == 1) { return(msj = "Presetación modificada con éxito!"); } } catch (Exception e) { Console.WriteLine("Error: {0}", e); } finally { con.close(); } return(msj); }
// LISTAR PRESENTACION public List <Presentacion> ListPresentacion() { List <Presentacion> list = new List <Presentacion>(); SqlConnection connection = null; SqlCommand command = null; SqlDataReader reader = null; try { connection = Connection.GetInstance().ConnectionDB(); command = new SqlCommand("SP_LISTARPRESENTACION", connection); command.CommandType = CommandType.StoredProcedure; connection.Open(); reader = command.ExecuteReader(); while (reader.Read()) { Presentacion objPresentacion = new Presentacion { idPresentacion = DBHelper.ReadNullSafeInt(reader["idPresentacion"]), tipo = DBHelper.ReadNullSafeString(reader["tipo"]) }; list.Add(objPresentacion); } } catch (Exception e) { throw e; } finally { connection.Close(); } return(list); }
// INSERTAR UNA PRESENTACION public bool InsertPresentacion(Presentacion objPresentacion) { SqlConnection connection = null; SqlCommand command = null; bool response = false; try { connection = Connection.GetInstance().ConnectionDB(); command = new SqlCommand("SP_INSERTPRESENTACION", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@tipo", objPresentacion); connection.Open(); int rows = command.ExecuteNonQuery(); if (rows > 0) { response = true; } } catch (Exception e) { throw e; } finally { connection.Close(); } return(response); }
public bool movimientoAlmacen(Presentacion presentacion, Int32 lIdDocumento, double unidad, string codigoAlmacen) { SDK.tMovimiento ltMovimiento = new SDK.tMovimiento(); int lIdMovimiento = 0; ltMovimiento.aCodAlmacen = codigoAlmacen; ltMovimiento.aConsecutivo = 1; ltMovimiento.aCodProdSer = presentacion.codigo; ltMovimiento.aUnidades = unidad; ltMovimiento.aCosto = 0; int lError = 0; lError = SDK.fAltaMovimiento(lIdDocumento, ref lIdMovimiento, ref ltMovimiento); if (lError != 0) { SDK.rError(lError); return(false); } return(true); }
public JsonResult ModificarPresentacion(Presentacion prese) { var jsonResponse = new JsonResponse(); if (ModelState.IsValid) { try { var presentacionOriginal = Presentaciones.SingleOrDefault(p => p.IdPresentacion == prese.IdPresentacion); var unidadMedida = UnidadMedidaBL.Instancia.Single(prese.IdUnidadMedida); presentacionOriginal.Nombre = unidadMedida.Nombre; presentacionOriginal.Equivalencia = prese.Equivalencia; presentacionOriginal.EsBase = prese.EsBase; presentacionOriginal.IdUnidadMedida = prese.IdUnidadMedida; presentacionOriginal.Peso = prese.Peso; presentacionOriginal.FechaModificacion = FechaModificacion; presentacionOriginal.UsuarioModificacion = UsuarioActual.IdEmpleado; jsonResponse.Success = true; jsonResponse.Message = "Se Proceso con exito"; } catch (Exception ex) { jsonResponse.Message = ex.Message; } } else { jsonResponse.Message = "Por favor ingrese todos los campos requeridos"; } return(Json(jsonResponse, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage Delete(int id) { Presentacion varPresentacion = this.service.GetByKey(id, false); bool result = false; if (varPresentacion == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } try { result = this.service.Delete(id);//, globalData, dataReference); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelPresentacion", new JavaScriptSerializer().Serialize(varPresentacion), result); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelPresentacion", new JavaScriptSerializer().Serialize(varPresentacion), result, ex.Message); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public Presentacion GetByid(int Id_Presentacion) { using (SqlConnection cnx = new SqlConnection(ConfigurationManager.ConnectionStrings["cnnString"].ToString())) { cnx.Open(); const string sqlGetById = "SELECT * FROM Presentacion WHERE Id_Presentacion = @Id_Presentacion"; using (SqlCommand cmd = new SqlCommand(sqlGetById, cnx)) { cmd.Parameters.AddWithValue("@Id_Presentacion", Id_Presentacion); SqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.Read()) { Presentacion Lpresentacion = new Presentacion { Id_presentacion = Convert.ToInt32(dataReader["Id_Presentacion"]), Id_cuestionario = Convert.ToInt32(dataReader["Id_Cuestionario"]), pregunta = Convert.ToString(dataReader["pregunta"]), descripcion = Convert.ToString(dataReader["descripcion"]), imagen = Convert.ToByte(dataReader["Precio"]) }; return(Lpresentacion); } } } return(null); }
public async Task <IActionResult> PutPresentacion([FromRoute] int id, [FromBody] Presentacion presentacion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != presentacion.Id) { return(BadRequest()); } _context.Entry(presentacion).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PresentacionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Calcular Precio Unitario /// </summary> private void calcularPrecioUnitario() { if (cbxCodigoProducto.SelectedIndex == -1 || cbxDescripcion.SelectedIndex == -1) { return; /// Validación } try { if (cbxPresentacion.SelectedIndex == -1) { textPrecioUnidario.Text = currentProducto.precioCompra; } else { // Buscar presentacion elegida int idPresentacion = Convert.ToInt32(cbxPresentacion.SelectedValue); Presentacion findPresentacion = presentaciones.Find(x => x.idPresentacion == idPresentacion); // Realizando el calculo double precioCompra = double.Parse(currentProducto.precioCompra, CultureInfo.GetCultureInfo("en-US")); double cantidadUnitario = double.Parse(findPresentacion.cantidadUnitaria, CultureInfo.GetCultureInfo("en-US")); double precioUnidatio = precioCompra * cantidadUnitario; // Imprimiendo valor textPrecioUnidario.Text = String.Format(CultureInfo.GetCultureInfo("en-US"), "{0}", precioUnidatio); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Calcular total", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { if (_auxiliar == "AGREGAR") { Presentacion pre = obtenerPresentacionFormulario(); Presentacion.agregarPresentacion(pre); } else if (_auxiliar == "EDITAR") { int index = lstPresentaciones.SelectedIndex; //Articulo.listaArticulos[index] = obtenerArticuloFormulario(); Presentacion pre = obtenerPresentacionFormulario(); Presentacion.editarPresentacion(pre, index); } actualizarListadoPresentacion(); limpiarFormulario(); bloquearFormulario(); } catch (Exception ex) { MessageBox.Show("Ha ocurrido un error: " + ex.Message); } }
private void Guardarbutton_Click(object sender, EventArgs e) { Presentacion presentacion = new Presentacion(); presentacionBindingSource.EndEdit(); presentacion = (Presentacion)presentacionBindingSource.Current; //estableciendo las presentaciones inferiores y superiores //presentacion.PresentacionSuperior = ((Presentacion)presentacionBindingSource1.Current).IdPresentacion; //presentacion.PresentacionInferior = ((Presentacion)presentacionBindingSource2.Current).IdPresentacion; cPresentacion.Insertar(presentacion); if (actualizacion) { MessageBox.Show("Presentación actualizada con éxito"); } else { MessageBox.Show("Presentación registrada con éxito"); } actualizacion = false; cargarListado(); activarcontroles(); }
public ActionResult Post(bool IsNew, PresentacionModel varPresentacion) { try { //if (ModelState.IsValid) //{ if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IPresentacionApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var PresentacionInfo = new Presentacion { Clave = varPresentacion.Clave , Descripcion = varPresentacion.Descripcion }; result = !IsNew? _IPresentacionApiConsumer.Update(PresentacionInfo, null, null).Resource.ToString() : _IPresentacionApiConsumer.Insert(PresentacionInfo, null, null).Resource.ToString(); Session["KeyValueInserted"] = result; return(Json(result, JsonRequestBehavior.AllowGet)); //} //return Json(false, JsonRequestBehavior.AllowGet); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Descripción:insertar una nueva Presentacion /// Author: Terceros. /// Fecha Creacion: 01/01/2017 /// Fecha Modificación: 02/02/2017. /// Modificación: Se agregaron comentarios. /// </summary> /// <param name="presenta"></param> public void InsertPresentacion(Presentacion pres) { using (var presentacionDal = new PresentacionDal()) { presentacionDal.InsertPresentacion(pres); } }
/// <summary> /// Descripción: Actualiza una presentacion /// Author: Terceros. /// Fecha Creacion: 01/01/2017 /// Fecha Modificación: 02/02/2017. /// Modificación: Se agregaron comentarios. /// </summary> /// <param name="presenta"></param> public void UpdatePresentacion(Presentacion pres) { using (var presentacionDal = new PresentacionDal()) { presentacionDal.UpdatePresentacion(pres); } }
private void CreatePresentacion() { if (txtNombrePresentacion.Text == "") { MessageBox.Show(this, "Complete los campos requeridos", "Error al eliminar", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } p = null; if (preservice.ReadByNombrePresentacion(txtNombrePresentacion.Text) == null) { p = new Presentacion(); p.NombrePresentacion = txtNombrePresentacion.Text; preservice.Create(p); MessageBox.Show("Presentación registrada"); ClearFields(); FillDataGridViewPresentacion(); return; } else { MessageBox.Show(this, "La presentación que intenta registrar ya existe", "Error al registrar", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void BtnActualizar_Click(object sender, EventArgs e) { BtnEliminar.Enabled = false; BtnActualizar.Enabled = false; BtnAgregar.Enabled = true; try { if (Validar()) { Presentacion modifica = new Presentacion(); modifica.IDPresentacion = ID; modifica.Nombre = txtNombreProducto.Text; modifica.Descripcion = txtDescripcionProducto.Text; PresentacionBL.UpdatePresentacion(modifica); dataGridView1.Update(); LlenarGrid(); MessageBox.Show("Presentacion Modificada Exitosamente", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); Limpiar(txtDescripcionProducto, txtNombreProducto); tabControl1.SelectedIndex = 1; } else { MessageBox.Show("Debe llenar todos los Campos Requeridos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message + " Error Al Modificar Articulo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public HttpResponseMessage Post(Presentacion varPresentacion) { if (ModelState.IsValid) { var data = "-1"; try { data = Convert.ToString(this.service.Insert(varPresentacion)); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsPresentacion", new JavaScriptSerializer().Serialize(varPresentacion), true); serviceBitacora.Insert(bitacora); } catch (ServiceException ex) { var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsPresentacion", new JavaScriptSerializer().Serialize(varPresentacion), true); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter)); } else { var errors = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList(); var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsPresentacion", new JavaScriptSerializer().Serialize(varPresentacion), false, errors.ToString()); serviceBitacora.Insert(bitacora); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } }
public string NuevaPresentacion(string nombre) { RepositorioGenerico <Presentacion> Rep = new RepositorioGenerico <Presentacion>(); Presentacion Nuevo = new Presentacion(); string respuesta = ""; try { IEnumerable busca = BuscarPresentacion(nombre); if (busca.Cast <object>().Any()) { respuesta = "Error ya existe en el registro " + nombre; } else { Nuevo.PresentacionID = Convert.ToInt32(Rep.ListarTodo().Max(m => m.PresentacionID) + 1); Nuevo.NombrePres = nombre; Rep.Agregar(Nuevo); respuesta = "Se agrego correctamente el registro"; } } catch (Exception error) { respuesta = "Error " + error.Message; } return(respuesta); }//fin del metodo NUevoEstado
public DataTable BuscarNombre(Presentacion Presentacion) { DataTable DtResultado = new DataTable("presentacion"); SqlConnection SqlCon = new SqlConnection(); try { SqlCon.ConnectionString = Conexion.Cn; SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.CommandText = "spbuscar_presentacion_nombre"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter ParTextoBuscar = new SqlParameter(); ParTextoBuscar.ParameterName = "@textobuscar"; ParTextoBuscar.SqlDbType = SqlDbType.VarChar; ParTextoBuscar.Size = 50; ParTextoBuscar.Value = Presentacion.TextoBuscar; SqlCmd.Parameters.Add(ParTextoBuscar); SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd); SqlDat.Fill(DtResultado); } catch (Exception ex) { DtResultado = null; } return(DtResultado); }
public Dpresentacion(Presentacion P) { this.Idpresentacion = P.idpresentacion; this.Nombre = P.nombre; this.Descripcion = P.descripcion; this.TextoBuscar = P.textobuscar; }
private void tblPresentaciones_MouseDoubleClick(object sender, MouseButtonEventArgs e) { System.Data.DataRowView seleccion = (System.Data.DataRowView)tblPresentaciones.SelectedItem; if (seleccion != null) { Presentacion nPre = new Presentacion(); nPre = presentacionIns.obtener(int.Parse(seleccion.Row.ItemArray[0].ToString())); title.Text = "En proceso de eliminacion de presentacion '" + seleccion.Row.ItemArray[1].ToString() + "'"; txtCodigoPr.Text = nPre.codigo; txtDescripcion.Text = nPre.descripcion; txtUcosto.Text = nPre.ultimo_costo.ToString(); txtCPromedio.Text = nPre.costo_promedio.ToString(); txtIVA.Text = nPre.IVA.ToString(); txtCCImpuesto.Text = nPre.costo_con_impuesto.ToString(); txtRendimiento.Text = nPre.rendimiento.ToString(); txtCantidad.Text = nPre.cantidad.ToString(); cbxProveedor.SelectedItem = this.presentacionIns.Proveedor.nombre; cbxAlmacen.SelectedItem = this.presentacionIns.Almacen.nombre; SDK.fBuscaProducto(seleccion.Row.ItemArray[5].ToString()); StringBuilder idValorClasificacion = new StringBuilder(5); SDK.fLeeDatoProducto("CIDVALORCLASIFICACION1", idValorClasificacion, 5); SDK.fBuscaIdValorClasif(Convert.ToInt32(idValorClasificacion.ToString())); StringBuilder codValorClasificacion = new StringBuilder(11); StringBuilder nomValorClasificacion = new StringBuilder(30); SDK.fLeeDatoValorClasif("CCODIGOVALORCLASIFICACION", codValorClasificacion, 11); SDK.fLeeDatoValorClasif("CVALORCLASIFICACION", nomValorClasificacion, 30); cbxValoresDeClasificaciones.SelectedItem = codValorClasificacion + " | " + nomValorClasificacion; addPresentacion.IsEnabled = false; txtCodigoPr.IsReadOnly = true; } }
private void presentacionDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { actualizacion = true; activarcontroles(); Presentacion presentacion = new Presentacion(); presentacion = (Presentacion)presentacionBindingSource.Current; }
public void mostrarPresentacion() { for (int i = 0; i < Np; i++) { Presentacion <W> presentacion = P[i]; presentacion.mostrarParejas(); } }
public ActionResult DeleteConfirmed(int id) { Presentacion presentacion = db.Presentacions.Find(id); db.Presentacions.Remove(presentacion); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> InsertarPresentacion(Presentacion request) { await _context.Presentaciones.AddAsync(new Presentacion() { NombrePresentacion = request.NombrePresentacion }); return(await _context.SaveChangesAsync() > 0 ? Ok() : BadRequest()); }
// Inicialización al comenzar la sesión de juego public Juego() { // Inicializo modo grafico 800x600 puntos, 24 bits de color bool pantallaCompleta = false; Hardware.Inicializar(800, 600, 24, pantallaCompleta); // Inicializo componentes del juego presentacion = new Presentacion(); partida = new Partida(); creditos = new Creditos(); opciones = new Opciones(); }