public Boolean AnularDB(imp_ordencompra_ext_x_imp_gastosxImport_Info info) { try { using (EntitiesImportacion Contex = new EntitiesImportacion()) { var contact = Contex.imp_ordencompra_ext_x_imp_gastosxImport.FirstOrDefault(obj => obj.IdEmpresa == info.IdEmpresa && obj.IdSucusal == info.IdSucusal && obj.IdOrdenCompraExt == info.IdOrdenCompraExt && obj.IdRegistroGasto == info.IdRegistroGasto); if (contact != null) { contact.Estado = "I"; contact.IdUsuarioUltAnu = info.IdUsuarioUltAnu; contact.Fecha_UltAnu = info.Fecha_UltAnu; contact.IdTipoCbte_Anu = info.IdTipoCbte_Anul; Contex.SaveChanges(); Contex.Dispose(); } } return(true); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public bool EliminarDB(imp_ordencompra_ext_x_imp_gastosxImport_Info Info, ref string msg) { try { using (EntitiesImportacion oEnt = new EntitiesImportacion()) { var a = Get_List_ordencompra_ext_x_imp_gastosxImport_Det(Info); if (a != null) { foreach (var item in a) { imp_ordencompra_ext_x_imp_gastosxImport_det contact = oEnt. imp_ordencompra_ext_x_imp_gastosxImport_det.FirstOrDefault(q => q.IdEmpresa == item.IdEmpresa && q.IdSucursal == item.IdSucusal && q.IdOrdenCompraExt == item.IdOrdenCompraExt && q.IdRegistroGasto == item.IdRegistroGasto); if (contact != null) { oEnt.imp_ordencompra_ext_x_imp_gastosxImport_det.Remove(contact); } } oEnt.SaveChanges(); } } return(true); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public Boolean ActualizarAnulado(imp_ordencompra_ext_x_imp_gastosxImport_Info info, decimal IdCbteCble) { try { using (EntitiesImportacion Contex = new EntitiesImportacion()) { var contact = Contex.imp_ordencompra_ext_x_imp_gastosxImport.FirstOrDefault(var => var.IdEmpresa == info.IdEmpresa && var.IdSucusal == info.IdSucusal && var.IdRegistroGasto == info.IdRegistroGasto); if (contact != null) { contact.IdCbteCble_Anu = IdCbteCble; Contex.SaveChanges(); } } return(true); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public Boolean GuardarDB(imp_ordencompra_ext_x_imp_gastosxImport_Info info) { try { using (EntitiesImportacion Contex = new EntitiesImportacion()) { imp_ordencompra_ext_x_imp_gastosxImport address = new imp_ordencompra_ext_x_imp_gastosxImport(); address.IdEmpresa = info.IdEmpresa; address.IdRegistroGasto = info.IdRegistroGasto = GetId(info); address.IdSucusal = info.IdSucusal; address.IdOrdenCompraExt = info.IdOrdenCompraExt; address.Fecha = info.Fecha; address.Observacion = info.Observacion; address.IdProveedor = info.IdProveedor; if (info.IdBanco == 0) { address.IdBanco = null; } else { address.IdBanco = info.IdBanco; } address.IdTipoCbte = info.IdTipoCbte; address.CodDocu_Pago = info.CodDocu_Pago; address.Estado = "A"; address.IdUsuario = info.IdUsuario; address.Fecha_Transac = info.Fecha_Transac; address.Fecha_UltMod = info.Fecha_UltMod; address.IdUsuarioUltMod = info.IdUsuarioUltMod; //contac = address; Contex.imp_ordencompra_ext_x_imp_gastosxImport.Add(address); Contex.SaveChanges(); info.ListaGastos.ForEach(var => var.IdRegistroGasto = address.IdRegistroGasto); BusDetalle.GuardarDB(info.ListaGastos); Contex.Dispose(); } return(true); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public void Get() { try { // var imp = busImpOrdenExt.obtenerOrdenCompra(param.IdEmpresa,txtImportacion.Text,(int)cmbSucursal.SelectedValue); _Info = new imp_ordencompra_ext_x_imp_gastosxImport_Info(); _Info.IdEmpresa = param.IdEmpresa; _Info.IdOrdenCompraExt = Convert.ToDecimal(searchLookUpEditImportacion.EditValue); _Info.IdBanco = Convert.ToInt32(cmbBanco.EditValue); _Info.IdTipoCbte = tipocbte.IdTipoCbte; //_Info.IdSucusal = 1; // imp_ordencompra_ext_Info imp = (imp_ordencompra_ext_Info)searchLookUpEditImportacion.GetSelectedDataRow(); var idSucursa = Importaciones.Find(var => var.IdOrdenCompraExt == _Info.IdOrdenCompraExt).IdSucusal; _Info.IdSucusal = idSucursa; _Info.Fecha = Convert.ToDateTime(dtpFecha.Value.ToShortDateString()); _Info.CodDocu_Pago = cmbTipoPagos.SelectedValue.ToString(); _Info.Observacion = txtObservacion.Text; for (int i = 0; i < gridViewGastos.RowCount; i++) { imp_ordencompra_ext_x_imp_gastosxImport_Det_Info asd = (imp_ordencompra_ext_x_imp_gastosxImport_Det_Info)gridViewGastos.GetRow(i); if (asd != null) { asd.Secuencia = i + 1; asd.IdEmpresa = param.IdEmpresa; asd.IdOrdenCompraExt = _Info.IdOrdenCompraExt; asd.IdSucusal = _Info.IdSucusal; _Info.ListaGastos.Add(asd); } } if (_Info.CodDocu_Pago != "PROVI") { _Info.IdProveedor = Convert.ToDecimal(this.searchLookUpEdit_Proveedor.EditValue); } else { _Info.IdProveedor = null; } //_Info.IdRegistroGasto = Convert.ToDecimal(txtIdRegistroGasto.Text); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); } }
private void gridViewPedidos_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { try { Info = (imp_ordencompra_ext_x_imp_gastosxImport_Info)gridViewGastos.GetFocusedRow(); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString()); } }
public List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Get_List_ordencompra_ext_x_imp_gastosxImport_Para_Contabilizar(int IdEmpresa, int IdSucursal, decimal IdRegistro) { List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Lst = new List <imp_ordencompra_ext_x_imp_gastosxImport_Info>(); EntitiesImportacion oEnti = new EntitiesImportacion(); try { var Consult = from q in oEnti.vwImp_GastosImportacionCabYDet where q.IdEmpresa == IdEmpresa && q.IdSucusal == IdSucursal && q.IdRegistroGasto == IdRegistro && q.Estado == "A" select q; foreach (var item in Consult) { imp_ordencompra_ext_x_imp_gastosxImport_Info _Info = new imp_ordencompra_ext_x_imp_gastosxImport_Info(); _Info.IdEmpresa = item.IdEmpresa; _Info.IdRegistroGasto = item.IdRegistroGasto; _Info.IdSucusal = item.IdSucusal; _Info.IdOrdenCompraExt = item.IdOrdenCompraExt; _Info.Fecha = item.Fecha; _Info.Observacion = item.Observacion; _Info.IdProveedor = item.IdProveedor; _Info.IdBanco = item.IdBanco; _Info.CodDocu_Pago = item.CodDocu_Pago; _Info.Estado = item.Estado; _Info.IdGastoImp = item.IdGastoImp; _Info.Valor = item.Valor; _Info.IdCtaCble_Banco = item.IdCtaCble_Banco; _Info.IdCtaCble = item.IdCtaCble_Gaso; _Info.IdCtaCble_Importacion = item.IdCtaCble_import; _Info.IdTipoCbte = Convert.ToInt32((item.IdTipoCbte == null) ? 0 : item.IdTipoCbte); _Info.CodDocu_Pago = item.CodDocu_Pago; _Info.CodOrdenCompraExt = item.CodOrdenCompraExt; _Info.debcre_DebBanco = item.debcre_DebBanco; _Info.debCre_Provicion = item.debCre_Provicion; Lst.Add(_Info); } return(Lst); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public Boolean EliminarDB(imp_ordencompra_ext_x_imp_gastosxImport_Info Info, ref string msg) { try { return(data.EliminarDB(Info, ref msg)); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "EliminarLista", ex.Message), ex) { EntityType = typeof(imp_ordencompra_ext_x_imp_gastosxImport_Det_Bus) }; } }
public Boolean ACtualizarAnulado(imp_ordencompra_ext_x_imp_gastosxImport_Info info, decimal IdCbteCble) { try { return(oData.ActualizarAnulado(info, IdCbteCble)); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "ACtualizarAnulado", ex.Message), ex) { EntityType = typeof(imp_ordencompra_ext_x_imp_gastosxImport_Bus) }; } }
public List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Get_List_ordencompra_ext_x_imp_gastosxImpor(int IdEmpresa, int IdSucursal, DateTime FechaIni, DateTime FechaFin) { List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Lst = new List <imp_ordencompra_ext_x_imp_gastosxImport_Info>(); EntitiesImportacion oEnti = new EntitiesImportacion(); try { var Consulta = from q in oEnti.vwImp_GastosImportacion where q.IdEmpresa == IdEmpresa && q.Fecha >= FechaIni && q.Fecha <= FechaFin && q.IdSucusal == IdSucursal select q; foreach (var item in Consulta) { imp_ordencompra_ext_x_imp_gastosxImport_Info _Info = new imp_ordencompra_ext_x_imp_gastosxImport_Info(); _Info.IdEmpresa = item.IdEmpresa; _Info.IdRegistroGasto = item.IdRegistroGasto; _Info.IdSucusal = item.IdSucusal; _Info.IdOrdenCompraExt = item.IdOrdenCompraExt; _Info.Fecha = item.Fecha; _Info.Observacion = item.Observacion; _Info.IdProveedor = Convert.ToDecimal((item.IdProveedor == null) ? 0 : item.IdProveedor); _Info.IdBanco = item.IdBanco; _Info.Sucursal = item.Su_Descripcion; _Info.CodDocu_Pago = item.CodDocu_Pago; _Info.Estado = item.Estado; _Info.IdTipoCbte = Convert.ToInt16((item.IdTipoCbte == null) ? 0 : item.IdTipoCbte); _Info.IdCbteCble = Convert.ToDecimal((item.IdCbteCble == null) ? 0 : item.IdCbteCble); _Info.IdTipoCbte_Anul = Convert.ToInt16((item.IdTipoCbte_Anu == null) ? 0 : item.IdTipoCbte_Anu); _Info.IdCbteCble_Anulado = Convert.ToDecimal((item.IdCbteCble_Anu == null) ? 0 : item.IdCbteCble_Anu); _Info.CodOrdenCompraExt = item.CodOrdenCompraExt; _Info.Tipo_Importacion = item.Tipo_Importacion; Lst.Add(_Info); } return(Lst); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public Boolean AnularDB(imp_ordencompra_ext_x_imp_gastosxImport_Info info) { try { info.IdUsuarioUltAnu = param.IdUsuario; info.Fecha_UltAnu = param.Fecha_Transac; return(oData.AnularDB(info)); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "Anular", ex.Message), ex) { EntityType = typeof(imp_ordencompra_ext_x_imp_gastosxImport_Bus) }; } }
public List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Get_List_ordencompra_ext_x_imp_gastosxImport(int IdEmpresa, int IdSucursa, Decimal IdOrdenCompraExterna) { List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Lst = new List <imp_ordencompra_ext_x_imp_gastosxImport_Info>(); EntitiesImportacion oEnti = new EntitiesImportacion(); try { var Query = from q in oEnti.imp_ordencompra_ext_x_imp_gastosxImport where q.IdEmpresa == IdEmpresa && q.IdSucusal == IdSucursa && q.IdOrdenCompraExt == IdOrdenCompraExterna select q; foreach (var item in Query) { imp_ordencompra_ext_x_imp_gastosxImport_Info Obj = new imp_ordencompra_ext_x_imp_gastosxImport_Info(); Obj.IdEmpresa = item.IdEmpresa; Obj.IdRegistroGasto = item.IdRegistroGasto; Obj.IdSucusal = item.IdSucusal; Obj.IdOrdenCompraExt = item.IdOrdenCompraExt; Obj.Fecha = item.Fecha; Obj.Observacion = item.Observacion; Obj.IdProveedor = item.IdProveedor; Obj.IdBanco = Convert.ToInt32(item.IdBanco); Obj.CodDocu_Pago = item.CodDocu_Pago; Obj.Estado = item.Estado; Obj.IdTipoCbte = Convert.ToInt32(item.IdTipoCbte); Obj.IdCbteCble = Convert.ToDecimal(item.IdCbteCble); Lst.Add(Obj); } return(Lst); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
public imp_ordencompra_ext_x_imp_gastosxImport_Info Get_Info_ordencompra_ext_x_imp_gastosxImpor(int IdEmpresa, int IdSucursa, Decimal IdRegistroGasto) { imp_ordencompra_ext_x_imp_gastosxImport_Info _Info = new imp_ordencompra_ext_x_imp_gastosxImport_Info(); EntitiesImportacion IMP = new EntitiesImportacion(); try { var item = IMP.imp_ordencompra_ext_x_imp_gastosxImport.FirstOrDefault(var => var.IdEmpresa == IdEmpresa && var.IdSucusal == IdSucursa && var.IdRegistroGasto == IdRegistroGasto); if (item != null) { _Info.IdEmpresa = item.IdEmpresa; _Info.IdRegistroGasto = item.IdRegistroGasto; _Info.IdSucusal = item.IdSucusal; _Info.IdOrdenCompraExt = item.IdOrdenCompraExt; _Info.Fecha = item.Fecha; _Info.Observacion = item.Observacion; _Info.IdProveedor = item.IdProveedor; _Info.IdBanco = Convert.ToInt32(item.IdBanco); _Info.CodDocu_Pago = item.CodDocu_Pago; _Info.Estado = item.Estado; _Info.IdTipoCbte = Convert.ToInt16((item.IdTipoCbte == null) ? 0 : item.IdTipoCbte); _Info.IdCbteCble = Convert.ToDecimal((item.IdCbteCble == null) ? 0 : item.IdCbteCble); _Info.IdTipoCbte_Anul = Convert.ToInt16((item.IdTipoCbte_Anu == null) ? 0 : item.IdTipoCbte_Anu); _Info.IdCbteCble_Anulado = Convert.ToDecimal((item.IdCbteCble_Anu == null) ? 0 : item.IdCbteCble_Anu); } return(_Info); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public decimal GetId(imp_ordencompra_ext_x_imp_gastosxImport_Info info) { try { decimal ID = 0; EntitiesImportacion oEntities = new EntitiesImportacion(); var select = from q in oEntities.imp_ordencompra_ext_x_imp_gastosxImport where q.IdEmpresa == info.IdEmpresa && q.IdSucusal == info.IdSucusal //&& q.IdOrdenCompraExt == info.IdOrdenCompraExt select q; if (select.ToList().Count < 1) { ID = 1; } else { var GetiD = (from q in oEntities.imp_ordencompra_ext_x_imp_gastosxImport where q.IdEmpresa == info.IdEmpresa && q.IdSucusal == info.IdSucusal select q.IdRegistroGasto).Max(); ID = Convert.ToDecimal(GetiD.ToString()) + 1; } return(ID); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info> Get_List_ordencompra_ext_x_imp_gastosxImport_Det(imp_ordencompra_ext_x_imp_gastosxImport_Info Info) { try { return(data.Get_List_ordencompra_ext_x_imp_gastosxImport_Det(Info)); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "Consulta", ex.Message), ex) { EntityType = typeof(imp_ordencompra_ext_x_imp_gastosxImport_Det_Bus) }; } }
public List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info> Get_List_ordencompra_ext_x_imp_gastosxImport_Det(imp_ordencompra_ext_x_imp_gastosxImport_Info Info) { List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info> lst = new List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info>(); EntitiesImportacion IMP = new EntitiesImportacion(); try { var Consu = from q in IMP.imp_ordencompra_ext_x_imp_gastosxImport_det where q.IdEmpresa == Info.IdEmpresa && q.IdSucursal == Info.IdSucusal && q.IdRegistroGasto == Info.IdRegistroGasto && q.IdOrdenCompraExt == Info.IdOrdenCompraExt select q; foreach (var item in Consu) { imp_ordencompra_ext_x_imp_gastosxImport_Det_Info obj = new imp_ordencompra_ext_x_imp_gastosxImport_Det_Info(); obj.IdEmpresa = item.IdEmpresa; obj.IdRegistroGasto = item.IdRegistroGasto; obj.IdSucusal = item.IdSucursal; obj.IdOrdenCompraExt = item.IdOrdenCompraExt; obj.Secuencia = item.Secuencia; obj.IdGastoImp = item.IdGastoImp; obj.Valor = item.Valor; lst.Add(obj); } return(lst); } catch (Exception ex) { string arreglo = ToString(); tb_sis_Log_Error_Vzen_Data oDataLog = new tb_sis_Log_Error_Vzen_Data(); tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now); oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); mensaje = ex.ToString() + " " + ex.Message; throw new Exception(ex.ToString()); } }
public Boolean GenerarDiario(int IdEmpresa, int IdSucursal, decimal IdRegistroGasto, ref string msg, ref decimal idCbteCble, ref string CodTipod) { try{ #region Declaracion ct_Periodo_Info Per_I = new ct_Periodo_Info(); ct_Cbtecble_Info CbteCble_I = new ct_Cbtecble_Info(); List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info> ListaDetalle = new List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info>(); imp_gastosximport_x_empresa_Data BusGastosXEmpresa = new imp_gastosximport_x_empresa_Data(); List <imp_gastosximport_x_empresa_Info> lstGastosXEmpresa = new List <imp_gastosximport_x_empresa_Info>(); List <imp_ordencompra_ext_x_imp_gastosxImport_Info> Lst = new List <imp_ordencompra_ext_x_imp_gastosxImport_Info>(); imp_ordencompra_ext_x_imp_gastosxImport_Info _Info = new imp_ordencompra_ext_x_imp_gastosxImport_Info(); int IdTipoCbte = 0; ba_Cbte_Ban_Bus BusCbteBanco = new ba_Cbte_Ban_Bus(); ct_Periodo_Data Per_B = new ct_Periodo_Data(); List <ct_Cbtecble_det_Info> LstCbteCble = new List <ct_Cbtecble_det_Info>(); cl_parametrosGenerales_Bus param = cl_parametrosGenerales_Bus.Instance; ba_Cbte_Ban_Info CbteBan_I = new ba_Cbte_Ban_Info(); string MensajeError = ""; #endregion #region ObtenerGastoImportacion Lst = Get_List_ordencompra_ext_x_imp_gastosxImport_Para_Contabilizar(IdEmpresa, IdSucursal, IdRegistroGasto); foreach (var item in Lst) { _Info.IdOrdenCompraExt = item.IdOrdenCompraExt; _Info.IdProveedor = item.IdProveedor; _Info.IdEmpresa = item.IdEmpresa; _Info.IdSucusal = item.IdSucusal; _Info.IdRegistroGasto = item.IdRegistroGasto; _Info.Observacion = item.Observacion; _Info.IdCtaCble_Banco = item.IdCtaCble_Banco; _Info.IdBanco = item.IdBanco; _Info.CodOrdenCompraExt = item.CodOrdenCompraExt; IdTipoCbte = item.IdTipoCbte; _Info.Fecha = item.Fecha; _Info.IdCtaCble_Importacion = item.IdCtaCble_Importacion; imp_ordencompra_ext_x_imp_gastosxImport_Det_Info Det = new imp_ordencompra_ext_x_imp_gastosxImport_Det_Info(); Det.IdGastoImp = item.IdGastoImp; Det.Valor = item.Valor; _Info.ListaGastos.Add(Det); } #endregion Per_I = Per_B.Get_Info_Periodo(_Info.IdEmpresa, _Info.Fecha, ref MensajeError); lstGastosXEmpresa = BusGastosXEmpresa.Get_List_gastosximport_x_empresa(IdEmpresa); var DatosDiario = from p in _Info.ListaGastos join w in lstGastosXEmpresa on new { p.IdGastoImp } equals new { w.IdGastoImp } select new { p.IdGastoImp, w.IdCtaCble, p.Valor, w.debCre_Provicion, w.debcre_DebBanco }; if (DatosDiario.ToList().Count != _Info.ListaGastos.Count) { msg = "No existen parametros contables verifique que los parametros Contables Esten Llenados correctametne /n Comunicarce Cons sistemas"; return(false); } #region CbteCble_Detalle foreach (var item in DatosDiario) { ct_Cbtecble_det_Info obj = new ct_Cbtecble_det_Info(); obj.dc_Observacion = "Cont. X gastos De Imp " + _Info.CodOrdenCompraExt + " / " + _Info.IdOrdenCompraExt + " / " + _Info.Observacion + " / " + Get_Descripcion(item.IdGastoImp); obj.IdCtaCble = item.IdCtaCble; obj.IdTipoCbte = IdTipoCbte; obj.IdEmpresa = _Info.IdEmpresa; if (CodTipod == "DEBBAN") { if (item.debcre_DebBanco == "C") { obj.dc_Valor = item.Valor * -1; } else { obj.dc_Valor = item.Valor; } } if (CodTipod == "PROVI") { if (item.debcre_DebBanco == "D") { obj.dc_Valor = item.Valor * -1; } else { obj.dc_Valor = item.Valor; } } LstCbteCble.Add(obj); } ct_Cbtecble_det_Info obj2 = new ct_Cbtecble_det_Info(); double Valor = 0; foreach (var item in _Info.ListaGastos) { Valor = Valor + item.Valor; } obj2.dc_Observacion = "Cont. X gastos De Imp " + _Info.CodOrdenCompraExt + " / " + _Info.IdOrdenCompraExt + " / " + _Info.Observacion + " / Importacion"; obj2.IdCtaCble = _Info.IdCtaCble_Banco; obj2.IdTipoCbte = IdTipoCbte; obj2.IdEmpresa = _Info.IdEmpresa; ba_Banco_Cuenta_Bus B_banco = new ba_Banco_Cuenta_Bus(); var Banco = B_banco.Get_Info_Banco_Cuenta(param.IdEmpresa, _Info.IdBanco); if (CodTipod == "DEBBAN") { obj2.IdCtaCble = Banco.IdCtaCble; obj2.dc_Valor = Valor * -1; } if (CodTipod == "PROVI") { obj2.IdCtaCble = _Info.IdCtaCble_Importacion; obj2.dc_Valor = Valor; } LstCbteCble.Add(obj2); #endregion #region CbteCble CbteCble_I.IdEmpresa = _Info.IdEmpresa; CbteCble_I.IdTipoCbte = IdTipoCbte; CbteCble_I.IdPeriodo = Per_I.IdPeriodo; CbteCble_I.cb_Fecha = Convert.ToDateTime(_Info.Fecha.ToShortDateString()); CbteCble_I.cb_Valor = Valor; if (CodTipod == "DEBBAN") { CbteCble_I.CodCbteCble = "DEBBAN"; } if (CodTipod == "PROVI") { CbteCble_I.CodCbteCble = "PROVI"; } CbteCble_I.cb_Observacion = "Cont. X Imp. " + _Info.CodOrdenCompraExt + " / " + _Info.IdOrdenCompraExt + "Gastos de Importacion. / " + _Info.Observacion; CbteCble_I.Secuencia = 0; CbteCble_I.Estado = "A"; CbteCble_I.Anio = _Info.Fecha.Year; CbteCble_I.Mes = _Info.Fecha.Month; CbteCble_I.IdUsuario = param.IdUsuario; CbteCble_I.IdUsuarioUltModi = param.IdUsuario; CbteCble_I.cb_FechaTransac = param.GetDateServer(); CbteCble_I.cb_FechaUltModi = param.GetDateServer(); CbteCble_I.Mayorizado = "N"; CbteCble_I._cbteCble_det_lista_info = LstCbteCble; // decimal idCbteCble = 0; string cod_CbteCble = ""; ct_Cbtecble_Bus CbteCble_B = new ct_Cbtecble_Bus(); if (CbteCble_B.GrabarDB(CbteCble_I, ref idCbteCble, ref msg) == false) { return(false); } oData.ModificarDB(_Info, idCbteCble); #endregion if (CodTipod == "DEBBAN") { #region CbteBan_I CbteBan_I.IdEmpresa = param.IdEmpresa; CbteBan_I.IdTipocbte = IdTipoCbte; CbteBan_I.IdCbteCble = idCbteCble; CbteBan_I.Cod_Cbtecble = cod_CbteCble; CbteBan_I.IdPeriodo = Per_I.IdPeriodo; CbteBan_I.IdBanco = _Info.IdBanco; CbteBan_I.cb_Fecha = Convert.ToDateTime(_Info.Fecha.ToShortDateString()); CbteBan_I.cb_Observacion = _Info.Observacion.Trim(); CbteBan_I.cb_Valor = Valor; CbteBan_I.Estado = "A"; CbteBan_I.IdUsuario = param.IdUsuario; CbteBan_I.IdUsuario_Anu = param.IdUsuario; CbteBan_I.FechaAnulacion = param.Fecha_Transac; CbteBan_I.Fecha_Transac = param.Fecha_Transac; CbteBan_I.Fecha_UltMod = param.Fecha_Transac; CbteBan_I.IdUsuarioUltMod = param.IdUsuario; CbteBan_I.ip = param.ip; CbteBan_I.nom_pc = param.nom_pc; if (BusCbteBanco.GrabarDB(CbteBan_I, ref MensajeError) == false) { return(false); } #endregion } imp_ordencompra_ext_x_ct_cbtecble_Data DataOrdxCbt = new imp_ordencompra_ext_x_ct_cbtecble_Data(); imp_ordencompra_ext_x_ct_cbtecble_Info ordCompraxCbte_info = new imp_ordencompra_ext_x_ct_cbtecble_Info(); ordCompraxCbte_info.ct_IdEmpresa = ordCompraxCbte_info.imp_IdEmpresa = _Info.IdEmpresa; ordCompraxCbte_info.imp_IdOrdenCompraExt = _Info.IdOrdenCompraExt; ordCompraxCbte_info.imp_IdSucusal = _Info.IdSucusal; ordCompraxCbte_info.ct_IdTipoCbte = IdTipoCbte; ordCompraxCbte_info.ct_IdCbteCble = idCbteCble; ordCompraxCbte_info.TipoReg = "Gast"; DataOrdxCbt.GuardarDB(ordCompraxCbte_info, ref mensaje); return(true); } catch (Exception ex) { Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message); throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "GenerarDiario", ex.Message), ex) { EntityType = typeof(imp_ordencompra_ext_x_imp_gastosxImport_Bus) }; } }