private void ucGe_Menu_event_btnAprobar_Click(object sender, EventArgs e) { try { string mensaje_cbte_cble_ing = ""; string mensaje_cbte_cble_egr = ""; Get_info(); in_AjusteFisico_Detalle_Bus BusAjusDeta = new in_AjusteFisico_Detalle_Bus(); BusAjusDeta.EliminarDB(param.IdEmpresa, Convert.ToDecimal(txtNumAjusteFisico.Text)); int s = 1; ListaAjuste = new List <in_AjusteFisico_Detalle_Info>(); foreach (var item in BindingList_Producto) { in_AjusteFisico_Detalle_Info infoAjusteDetalle = new in_AjusteFisico_Detalle_Info(); infoAjusteDetalle.IdAjusteFisico = Convert.ToDecimal(txtNumAjusteFisico.Text); infoAjusteDetalle.IdEmpresa = param.IdEmpresa; infoAjusteDetalle.Secuencia = s; infoAjusteDetalle.IdProducto = item.IdProducto; infoAjusteDetalle.CantidadAjustada = Convert.ToDouble(item.CantidadAjustada); infoAjusteDetalle.StockFisico = Convert.ToDouble(item.StockFisico); infoAjusteDetalle.StockSistema = item.pr_stock == null ? 0 : Convert.ToDouble(item.pr_stock); s++; ListaAjuste.Add(infoAjusteDetalle); } BusAjusDeta.GuardarDB(ListaAjuste); string mensaje = ""; var TIngreso = (from q in BindingList_Producto where q.CantidadAjustada > 0 select q).Count(); var TEgresos = (from q in BindingList_Producto where q.CantidadAjustada < 0 select q).Count(); HayIngresos = (Convert.ToDouble(TIngreso) > 0) ? true : false; #region HayIngreso if (HayIngresos == true) { in_movi_inve_Info InfoMOviIngreso = new in_movi_inve_Info(); #region InfoMoviIngres InfoMOviIngreso.IdEmpresa = param.IdEmpresa; InfoMOviIngreso.IdSucursal = Info_AjusteFisico.IdSucursal; InfoMOviIngreso.IdBodega = Info_AjusteFisico.IdBodega; InfoMOviIngreso.IdMovi_inven_tipo = Info_AjusteFisico.IdMovi_inven_tipo_Ing; InfoMOviIngreso.cm_tipo = "+"; InfoMOviIngreso.cm_observacion = Info_AjusteFisico.Observacion; InfoMOviIngreso.IdUsuario = param.IdUsuario; InfoMOviIngreso.nom_pc = param.nom_pc; InfoMOviIngreso.ip = param.ip; InfoMOviIngreso.Estado = "A"; InfoMOviIngreso.cm_fecha = dtp_fecha.Value; InfoMOviIngreso.CodMoviInven = "AJU"; #endregion var SelectDetMoviIng = from q in BindingList_Producto where q.CantidadAjustada > 0 select q; int c = 1; foreach (var item in SelectDetMoviIng) { in_movi_inve_detalle_Info detMovInfo = new in_movi_inve_detalle_Info(); detMovInfo.dm_cantidad = Convert.ToDouble(item.CantidadAjustada); detMovInfo.IdProducto = item.IdProducto; detMovInfo.Secuencia = c; detMovInfo.IdEmpresa = param.IdEmpresa; detMovInfo.IdBodega = InfoMOviIngreso.IdBodega; detMovInfo.IdSucursal = InfoMOviIngreso.IdSucursal; detMovInfo.IdMovi_inven_tipo = InfoMOviIngreso.IdMovi_inven_tipo; detMovInfo.IdNumMovi = 0; detMovInfo.mv_tipo_movi = InfoMOviIngreso.cm_tipo; detMovInfo.dm_observacion = Info_AjusteFisico.Observacion; detMovInfo.mv_costo = item.pr_costo_promedio; listDetMoviIngreso.Add(detMovInfo); c++; } InfoMOviIngreso.listmovi_inve_detalle_Info = listDetMoviIngreso; Bus_MoviInven.GrabarDB(InfoMOviIngreso, ref IdNumMovi_Ing, ref mensaje_cbte_cble_ing, ref mensaje); } #endregion #region HayEgreso HayEgresos = (Convert.ToDouble(TEgresos) > 0) ? true : false; if (HayEgresos == true) { #region InfoMoviEgreso in_movi_inve_Info InfoMOviEgres = new in_movi_inve_Info(); InfoMOviEgres.IdEmpresa = param.IdEmpresa; InfoMOviEgres.IdSucursal = Info_AjusteFisico.IdSucursal; InfoMOviEgres.IdBodega = Info_AjusteFisico.IdBodega; InfoMOviEgres.IdMovi_inven_tipo = Info_AjusteFisico.IdMovi_inven_tipo_Egr; InfoMOviEgres.cm_tipo = "-"; InfoMOviEgres.cm_observacion = Info_AjusteFisico.Observacion; InfoMOviEgres.IdUsuario = param.IdUsuario; InfoMOviEgres.nom_pc = param.nom_pc; InfoMOviEgres.ip = param.ip; InfoMOviEgres.Estado = "A"; InfoMOviEgres.cm_fecha = dtp_fecha.Value; InfoMOviEgres.CodMoviInven = "AJU"; #endregion var SelectDetMoviEgre = from q in BindingList_Producto where q.CantidadAjustada < 0 select q; int c = 1; foreach (var item in SelectDetMoviEgre) { in_movi_inve_detalle_Info detMovInfo = new in_movi_inve_detalle_Info(); detMovInfo.IdEmpresa = param.IdEmpresa; detMovInfo.IdBodega = InfoMOviEgres.IdBodega; detMovInfo.IdSucursal = InfoMOviEgres.IdSucursal; detMovInfo.IdMovi_inven_tipo = InfoMOviEgres.IdMovi_inven_tipo; detMovInfo.IdNumMovi = IdNumMovi_Egr; detMovInfo.Secuencia = c; c++; detMovInfo.mv_tipo_movi = InfoMOviEgres.cm_tipo; detMovInfo.IdProducto = item.IdProducto; detMovInfo.dm_cantidad = Convert.ToDouble(item.CantidadAjustada); detMovInfo.dm_observacion = Info_AjusteFisico.Observacion; detMovInfo.mv_costo = item.pr_costo_promedio; listDetMoviEgreso.Add(detMovInfo); } InfoMOviEgres.listmovi_inve_detalle_Info = listDetMoviEgreso; Bus_MoviInven.GrabarDB(InfoMOviEgres, ref IdNumMovi_Egr, ref mensaje_cbte_cble_egr, ref mensaje); //} } #endregion if (Bus_AjustFisico.ModificarDB(param.IdEmpresa, Convert.ToDecimal(txtNumAjusteFisico.Text), "APRO", IdNumMovi_Egr, IdNumMovi_Ing)) { MessageBox.Show("Ajuste Fisico Aprobado Con exito.. Ajuste#:" + Convert.ToDecimal(txtNumAjusteFisico.Text) + " Ingreso Inventario#:" + IdNumMovi_Ing + " Egreso Inventario#:" + IdNumMovi_Egr + " Diarios Contables" + mensaje_cbte_cble_ing + " " + mensaje_cbte_cble_egr); ucGe_Menu.Enabled_btnGuardar = false; ucGe_Menu.Enabled_bntGuardar_y_Salir = false; } else { MessageBox.Show("Error Al Aprobar"); } } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Set_Info() { try { Ctrl_SucBod.cmb_sucursal.EditValue = Info_AjusteFisico.IdSucursal; Ctrl_SucBod.cmb_bodega.EditValue = Info_AjusteFisico.IdBodega; Info_AjusteFisico.IdSucursal = Info_AjusteFisico.IdSucursal; Info_AjusteFisico.IdBodega = Info_AjusteFisico.IdBodega; txtMoviAjustIngreso.Text = Info_AjusteFisico.IdNumMovi_Ing.ToString(); txtNumMoviAjustEgreso.Text = Info_AjusteFisico.IdNumMovi_Egr.ToString(); txtNumAjusteFisico.Text = Info_AjusteFisico.IdAjusteFisico.ToString(); txtObservacion.Text = Info_AjusteFisico.Observacion; Ctrl_MoviIngreso.set_TipoMoviInvInfo(Info_AjusteFisico.IdMovi_inven_tipo_Ing); Ctrl_MoviEgreso.set_TipoMoviInvInfo(Info_AjusteFisico.IdMovi_inven_tipo_Egr); dtp_fecha.Value = Info_AjusteFisico.Fecha; ucIn_Catalogos_Cmb1.set_CatalogosInfo(Info_AjusteFisico.IdEstadoAprobacion); if (Info_AjusteFisico.Estado == "I") { lblAnulado.Visible = true; ucGe_Menu.Visible_bntAprobar = false; ucGe_Menu.Visible_bntGuardar_y_Salir = false; ucGe_Menu.Visible_btnGuardar = false; } else { lblAnulado.Visible = false; } List <in_AjusteFisico_Detalle_Info> listaAjusteFisicoDetalle = new List <in_AjusteFisico_Detalle_Info>(); in_AjusteFisico_Detalle_Bus BusAjusDeta = new in_AjusteFisico_Detalle_Bus(); listaAjusteFisicoDetalle = BusAjusDeta.Get_List_AjusteFisico_Detalle(Info_AjusteFisico.IdEmpresa, Info_AjusteFisico.IdAjusteFisico); var Productos_x_Ajust_Stock = from q in listaAjusteFisicoDetalle select q; foreach (var item in BindingList_Producto) { foreach (var item1 in Productos_x_Ajust_Stock) { if (item.IdProducto == item1.IdProducto) { item.StockFisico = Convert.ToDecimal(item1.StockFisico); item.CantidadAjustada = (decimal)item1.CantidadAjustada; item.pr_stock = Convert.ToDouble(item.StockFisico); } } } //var Consulta = Bus_DetMovi.Get_List_StockAFecha(param.IdEmpresa, // Convert.ToInt32(Ctrl_SucBod.cmb_sucursal.EditValue), // Convert.ToInt32(Ctrl_SucBod.cmb_bodega.EditValue), Convert.ToDateTime(dtp_fecha.Value.ToShortDateString())); gridControl_producto.DataSource = BindingList_Producto; } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }