public ct_cbtecble_Plantilla_Info get_info(int IdEmpresa, decimal IdPlantilla) { try { ct_cbtecble_Plantilla_Info info = new ct_cbtecble_Plantilla_Info(); using (Entities_contabilidad Context = new Entities_contabilidad()) { ct_cbtecble_Plantilla Entity = Context.ct_cbtecble_Plantilla.Where(q => q.IdPlantilla == IdPlantilla && q.IdEmpresa == IdEmpresa).FirstOrDefault(); if (Entity == null) { return(null); } info = new ct_cbtecble_Plantilla_Info { IdEmpresa = Entity.IdEmpresa, IdPlantilla = Entity.IdPlantilla, IdTipoCbte = Entity.IdTipoCbte, cb_Observacion = Entity.cb_Observacion, cb_Estado = Entity.cb_Estado }; } return(info); } catch (Exception) { throw; } }
public bool AnularBD(ct_cbtecble_Plantilla_Info info) { try { using (Entities_contabilidad db = new Entities_contabilidad()) { ct_cbtecble_Plantilla entity = db.ct_cbtecble_Plantilla.Where(q => q.IdPlantilla == info.IdPlantilla && q.IdEmpresa == info.IdEmpresa).FirstOrDefault(); if (entity == null) { return(false); } entity.cb_Estado = "I"; entity.IdUsuarioAnulacion = info.IdUsuarioAnulacion; entity.FechaAnulacion = DateTime.Now; entity.MotivoAnulacion = info.MotivoAnulacion; db.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool ModificarBD(ct_cbtecble_Plantilla_Info info) { try { using (Entities_contabilidad db = new Entities_contabilidad()) { ct_cbtecble_Plantilla entity = db.ct_cbtecble_Plantilla.Where(q => q.IdPlantilla == info.IdPlantilla && q.IdEmpresa == info.IdEmpresa).FirstOrDefault(); if (entity == null) { return(false); } entity.IdTipoCbte = info.IdTipoCbte; entity.cb_Observacion = info.cb_Observacion; entity.IdUsuarioModificacion = info.IdUsuarioModificacion; entity.FechaModificacion = DateTime.Now; var lst_det = db.ct_cbtecble_Plantilla_det.Where(q => q.IdEmpresa == info.IdEmpresa && q.IdPlantilla == info.IdPlantilla).ToList(); db.ct_cbtecble_Plantilla_det.RemoveRange(lst_det); if (info.lst_cbtecble_plantilla_det != null) { int secuencia = 1; foreach (var item in info.lst_cbtecble_plantilla_det) { db.ct_cbtecble_Plantilla_det.Add(new ct_cbtecble_Plantilla_det { IdEmpresa = info.IdEmpresa, IdPlantilla = info.IdPlantilla, secuencia = secuencia, IdCtaCble = item.IdCtaCble, dc_Valor = item.dc_Valor, dc_Observacion = item.dc_Observacion, IdPunto_cargo_grupo = item.IdPunto_cargo_grupo, IdPunto_cargo = item.IdPunto_cargo, IdCentroCosto = item.IdCentroCosto }); secuencia++; } } db.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public Boolean GrabarDB(ct_cbtecble_Plantilla_Info Info, ref decimal ID, ref string msg) { try { int IdSecuencia = 0; ID = Get_IdPlantilla(Info.IdEmpresa); Info.IdPlantilla = ID; ct_Cbtecble_tipo_Data data = new ct_Cbtecble_tipo_Data(); string codigo_CbteCble; if (data.Get_Codigo_x_CbtCble_tipo(Info.IdEmpresa, Info.IdTipoCbte, ref msg) == null) { msg = "ID Tipo Comprobante no existe"; return(false); } using (EntitiesDBConta context = new EntitiesDBConta()) { EntitiesDBConta EDB = new EntitiesDBConta(); var Q = from tbCbteCble in EDB.ct_cbtecble_Plantilla where tbCbteCble.IdEmpresa == Info.IdEmpresa && tbCbteCble.IdTipoCbte == Info.IdTipoCbte && tbCbteCble.IdPlantilla == Info.IdPlantilla select tbCbteCble; if (Q.ToList().Count == 0) { var address = new ct_cbtecble_Plantilla(); address.IdPlantilla = ID; address.IdEmpresa = Info.IdEmpresa; address.IdTipoCbte = Info.IdTipoCbte; address.cb_Fecha = Info.cb_Fecha; address.cb_Observacion = Info.cb_Observacion; address.cb_Estado = Info.cb_Estado; address.IdUsuario = Info.IdUsuario; address.IdUsuarioUltModi = Info.IdUsuario; address.cb_FechaTransac = Info.cb_FechaTransac; address.cb_FechaUltModi = Info.cb_FechaTransac; context.ct_cbtecble_Plantilla.Add(address); context.SaveChanges(); ct_cbtecble_Plantilla_det_Data PlaDet_Data = new ct_cbtecble_Plantilla_det_Data(); foreach (var item in Info.LstDet) { item.IdPlantilla = ID; item.IdEmpresa = Info.IdEmpresa; item.IdPlantilla = Info.IdPlantilla; item.IdTipoCbte = Info.IdTipoCbte; PlaDet_Data.GrabarDB(item); } msg = "Se ha procedido a generar el la Plantilla #: " + ID.ToString() + " para el tipo de comprobante #: " + Info.IdTipoCbte + " exitosamente."; } else { msg = "No se pudo guardar la Plantilla debido a que el id de Plantilla existe"; return(false); } } 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(); msg = "Mensaje de error: " + ex.Message; throw new Exception(ex.ToString()); } }