//Obtiene un registro para mostrarlo en los datos del formulario public Detalle_ST_Entity verUno_Movimiento(int codigo) { Detalle_ST_Entity st = new Detalle_ST_Entity(); Detalle_ST_DAL getst = new Detalle_ST_DAL(); return(getst.getSinge_Movimiento(codigo)); }
public Detalle_ST_Entity validaExistenciaBD(int producto, int bodega) { Detalle_ST_Entity st = new Detalle_ST_Entity(); Detalle_ST_DAL valida = new Detalle_ST_DAL(); return(valida.validaExistencia(producto, bodega)); }
private void btnGuardar_Click(object sender, EventArgs e) { Detalle_ST_Entity st = new Detalle_ST_Entity(); string[] usuario = Globales.Usuario.CapturarUsuario(); string[] moneda = Globales.Usuario.CapturarMoneda(Globales.Conexion); // st.idMoneda = Convert.ToInt32(moneda[1]); st.idMoneda = 1; st.idBodega = Convert.ToInt32(cmbBodega.SelectedValue); st.fecha = dtpFecha.Value.Day + "/" + dtpFecha.Value.Month + "/" + dtpFecha.Value.Year; //st.fecha = dtpFecha.Value.Year + "/" + dtpFecha.Value.Month + "/" + dtpFecha.Value.Day; st.idTipoMov = Convert.ToInt32(cmbTipoMovimiento.SelectedValue); try { if (txtIdMovimiento.Text == "" || txtIdMovimiento.Text == "0") { new BO.Detalle_ST_BO().guardaEncabezado(st); MessageBox.Show("Movimiento Guardado Exitosamente"); } else { st.idMovimiento = Convert.ToInt32(txtIdMovimiento.Text.Trim()); new BO.Detalle_ST_BO().actualizaEncabezado(st); MessageBox.Show("Movimiento Actualizado Exitosamente"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } ActualizaGrid(); }
public DataTable verTodoST(Detalle_ST_Entity st) { DataTable dt = new DataTable(); Detalle_ST_DAL vst = new Detalle_ST_DAL(); dt = vst.todosMovimientos(st); return(dt); }
public void eliminaDetalleST(Detalle_ST_Entity dt) { cnn.deleteSQL("DELETE FROM DETALLEMOVIMIENTOINVENTARIO " + " WHERE idbodega = " + dt.idBodega + " AND idmovimiento = " + dt.idMovimiento + " AND idproducto = " + dt.idProducto); ajustaExistenciasMovimientos(dt.Cantidad, dt.idProducto, dt.idBodega, 3, dt.CantidadReal); }
public void insertaDetalleST(Detalle_ST_Entity detalle) { //cnn.insertSQL("INSERT INTO DETALLE_SOLIC_TRANSPORTE(idproducto, idsolicitud, cantidad)" + // "VALUES(" + detalle.idProducto + ", " + detalle.idSolicitud + ", " + detalle.Cantidad + ")"); cnn.insertSQL("INSERT INTO DETALLEMOVIMIENTOINVENTARIO (idbodega, idmovimiento, idproducto, cantidad, precio, costo)" + "VALUES(" + detalle.idBodega + ", " + detalle.idMovimiento + ", " + detalle.idProducto + ", " + detalle.Cantidad + " , " + detalle.precio + ", " + detalle.costo + ")"); ajustaExistenciasMovimientos(detalle.Cantidad, detalle.idProducto, detalle.idBodega, 1, detalle.CantidadReal); }
public void actualizaDetalleST(Detalle_ST_Entity dt) { cnn.updateSQL("UPDATE DETALLEMOVIMIENTOINVENTARIO " + " SET cantidad = " + dt.Cantidad + " WHERE idbodega = " + dt.idBodega + " AND idmovimiento = " + dt.idMovimiento + " AND idproducto = " + dt.idProducto); ajustaExistenciasMovimientos(dt.Cantidad, dt.idProducto, dt.idBodega, 2, dt.CantidadReal); }
public void ActualizaGrid() { Detalle_ST_Entity st = new Detalle_ST_Entity(); try { dgvMovimientosEgreso.DataSource = new Detalle_ST_BO().verTodoST(st); dgvMovimientosEgreso.Refresh(); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public Detalle_ST_Entity validaExistencia(int producto, int bodega) { DataTable dtRegistros = new DataTable(); Detalle_ST_Entity st = new Detalle_ST_Entity(); dtRegistros = cnn.getSQL("SELECT cantidad FROM EXISTENCIA WHERE idbodega = " + bodega + " AND idproducto = " + producto); foreach (DataRow row in dtRegistros.Rows) { foreach (DataColumn column in dtRegistros.Columns) { st.Cantidad = Convert.ToInt32(row["cantidad"]); } } return(st); }
public Detalle_ST_Entity getSinge_Movimiento(int codigo) { Detalle_ST_Entity st = new Detalle_ST_Entity(); DataTable dtRegistro = new DataTable(); dtRegistro = cnn.getSQL(" SELECT * FROM MOVIMIENTOSINVENTARIO WHERE idmovimiento = " + codigo); foreach (DataRow row in dtRegistro.Rows) { foreach (DataColumn column in dtRegistro.Columns) { st.idMovimiento = Convert.ToInt32(row["idmovimiento"]); st.idBodega = Convert.ToInt32(row["idbodega"]); st.fecha = row["fecha"].ToString(); st.idTipoMov = Convert.ToInt32(row["idtipomovimiento"]); } } return(st); }
public DataTable todosMovimientos(Detalle_ST_Entity st) { DataTable dtRegistros = new DataTable(); int idempresa = Convert.ToInt32(empresa[0]); dtRegistros = cnn.getSQL("SELECT MI.idmovimiento as CODIGO_MOVIMIENTO, MI.idbodega AS CODIGO_BODEGA, " + // " CASE ST.idmovimiento WHEN ISNULL(ST.idmovimiento, 0) THEN CAST(st.idsolicitud AS VARCHAR) ELSE 'PENDIENTE' END AS CODIGO_SOLICITUD, " + " B.nombre_bodega as NOMBRE_BODEGA, MI.fecha as FECHA_DE_CREACION, TM.descripcion AS TIPO_MOVIMIENTO " + //" , EST.nombreestadost AS ESTADO_ACTUAL" + " FROM MOVIMIENTOSINVENTARIO MI " + " JOIN BODEGA B ON MI.idbodega = B.idbodega " + " JOIN TIPOMOVIMIENTO TM ON MI.idtipomovimiento = TM.idtipomovimiento " + " LEFT JOIN SOLICITUDTRANSPORTE ST ON MI.idmovimiento = ST.idmovimiento " + " LEFT JOIN ESTADOSOLICITUDTRANS EST ON ST.idestadost = EST.idestadost " + " WHERE MI.idtipomovimiento = 3 " + " AND ST.idsolicitud IS NULL " + " AND MI.idmovimiento = CASE " + st.idMovimiento + " WHEN 0 THEN MI.idmovimiento ELSE " + st.idMovimiento + " END" + " AND MI.idbodega = CASE " + st.idBodega + " WHEN 0 THEN MI.idbodega ELSE " + st.idBodega + " END" + " AND MI.idtipomovimiento =CASE " + st.idTipoMov + " WHEN 0 THEN MI.idtipomovimiento ELSE " + st.idTipoMov + " END " + " AND (EST.idestadost <> 4 OR EST.idestadost is null) " + " AND B.idempresa = " + idempresa + " ORDER BY ST.idmovimiento, MI.fecha "); return(dtRegistros); }
private void btnEliminar_Click(object sender, EventArgs e) { if (txtCodProducto.Text == "" || txtCodProducto.Text == "0") { MessageBox.Show("No ha seleccionado ningun producto"); } else { if (MessageBox.Show("Esta seguro de eliminar el registro", "Detalle de Solicitud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Detalle_ST_Entity pDetalle = new Detalle_ST_Entity(); pDetalle.idProducto = Convert.ToInt32(txtCodProducto.Text); pDetalle.idBodega = Convert.ToInt32(txtBodega.Text); pDetalle.idMovimiento = Convert.ToInt32(txtIdSolicitud.Text); pDetalle.Cantidad = Convert.ToInt32(txtCantidad.Text.Trim()); new BO.SolicitudTransporte_BOL().eliminarDetalleST(pDetalle); CargaGridDetalle(); limpiartxt(); CargaGridProductos(0); } } }
//Actualiza encabezado public void actualizaEncabezado(Detalle_ST_Entity st) { Detalle_ST_DAL guardar = new Detalle_ST_DAL(); guardar.actualizaEncabezadoMovimiento(st); }
private void btnGuardar_Click(object sender, EventArgs e) { if (txtCantidad.Text == "" || txtCodProducto.Text == "") { MessageBox.Show("Los valores de codigo de producto y cantidad no pueden estar vacios"); } else {//inicia guardado de la info Detalle_ST_Entity pDetalle = new Detalle_ST_Entity(); pDetalle.idProducto = Convert.ToInt32(txtCodProducto.Text); pDetalle.idMovimiento = Convert.ToInt32(txtEncabezado.Text); pDetalle.idBodega = Convert.ToInt32(txtBodega.Text.Trim()); if (txtPrecio.Text == "" || txtCosto.Text == "") { pDetalle.precio = 0; pDetalle.costo = 0; } else { pDetalle.precio = Convert.ToDecimal(txtPrecio.Text); pDetalle.costo = Convert.ToDecimal(txtCosto.Text.Trim()); } int cantidad1, cantidad2; cantidad1 = Convert.ToInt32(txtCantidad.Text); cantidad2 = Convert.ToInt32(txtCantidadBD.Text); int pivote = 0; if (txtCantidadReal.Text != "") { pivote = Convert.ToInt32(txtCantidadReal.Text); } int dif = cantidad2 - cantidad1; int bd = cantidad1 + cantidad2; int cantidad = cantidad1 + cantidad2; int suma = pivote + cantidad2; if (cantidad1 > suma) { MessageBox.Show("La cantidad ingresada es mayor a la existencia en bodega"); } else { //Valida: //si se escogio el producto desde la busqueda entonces insertara if (txtValida.Text == "1") { try { pDetalle.Cantidad = Convert.ToInt32(txtCantidad.Text); new BO.SolicitudTransporte_BOL().insertaDetalleST(pDetalle); MessageBox.Show("Producto ingresado a la solicitud exitosamente"); limpiartxt(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }//Fin Inserta else {//Inicia Actualizacion try { pDetalle.Cantidad = Convert.ToInt32(txtCantidad.Text); pDetalle.CantidadReal = Convert.ToInt32(txtCantidadReal.Text); new BO.SolicitudTransporte_BOL().actualizarDetalleST(pDetalle); MessageBox.Show("Producto actualizado exitosamente"); limpiartxt(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }//Fin Actualizacion CargaGridDetalle(); CargaGridProductos(0); } //Fin validacion de cantidad ingresada es mayor a la existencia } //Fin validacion cantidades vacias } //Fin Void
//Inserta encabezado public void guardaEncabezado(Detalle_ST_Entity st) { Detalle_ST_DAL guardar = new Detalle_ST_DAL(); guardar.insertarEncabezadoMovimiento(st); }
public void actualizaEncabezadoMovimiento(Detalle_ST_Entity st) { cnn.updateSQL("UPDATE MOVIMIENTOSINVENTARIO SET idbodega = " + st.idBodega + ", fecha = \'" + st.fecha + "\', idtipomovimiento = " + st.idTipoMov + ", idmoneda = " + st.idMoneda + " WHERE idmovimiento = " + st.idMovimiento); }
public void insertarEncabezadoMovimiento(Detalle_ST_Entity st) { cnn.insertSQL("INSERT INTO MOVIMIENTOSINVENTARIO(idbodega, fecha, idtipomovimiento, idmoneda)" + " VALUES(" + st.idBodega + ", \'" + st.fecha + "\', " + st.idTipoMov + ", " + st.idMoneda + ")"); }
public void actualizarDetalleST(Detalle_ST_Entity det) { SolicitudTransporte_DAL detalle = new SolicitudTransporte_DAL(); detalle.actualizaDetalleST(det); }
public void insertaDetalleST(Detalle_ST_Entity det) { SolicitudTransporte_DAL insertarDetalle = new SolicitudTransporte_DAL(); insertarDetalle.insertaDetalleST(det); }
public void eliminarDetalleST(Detalle_ST_Entity det) { SolicitudTransporte_DAL detalle = new SolicitudTransporte_DAL(); detalle.eliminaDetalleST(det); }