public ActionResult Consultar(int IdEmpresa = 0, int IdMotivo_Inv = 0, bool Exito = false) { in_Motivo_Inven_Info model = bus_motivo.get_info(IdEmpresa, IdMotivo_Inv); if (model == null) { return(RedirectToAction("Index")); } #region Permisos seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "Inventario", "MotivoInventario", "Index"); if (model.estado == "I") { info.Modificar = false; info.Anular = false; } model.Nuevo = (info.Nuevo == true ? 1 : 0); model.Modificar = (info.Modificar == true ? 1 : 0); model.Anular = (info.Anular == true ? 1 : 0); #endregion cargar_combos(); if (Exito) { ViewBag.MensajeSuccess = MensajeSuccess; } return(View(model)); }
public in_Motivo_Inven_Info Get_Info_Motivo_Inven(int IdEmpresa, int IdMotivo_Inv) { try { in_Motivo_Inven_Info Obj = new in_Motivo_Inven_Info(); EntitiesInventario oEnti = new EntitiesInventario(); var Query = from q in oEnti.in_Motivo_Inven where q.IdEmpresa == IdEmpresa && q.IdMotivo_Inv == IdMotivo_Inv select q; foreach (var item in Query) { Obj.IdEmpresa = item.IdEmpresa; Obj.IdMotivo_Inv = item.IdMotivo_Inv; Obj.Cod_Motivo_Inv = item.Cod_Motivo_Inv; Obj.Desc_mov_inv = item.Desc_mov_inv; Obj.Genera_Movi_Inven = item.Genera_Movi_Inven; Obj.estado = item.estado; Obj.IdUsuarioUltMod = item.IdUsuarioUltMod; Obj.Tipo_Ing_Egr = (item.Tipo_Ing_Egr == null) ? ein_Tipo_Ing_Egr.ING : (ein_Tipo_Ing_Egr)Enum.Parse(typeof(ein_Tipo_Ing_Egr), item.Tipo_Ing_Egr); } return(Obj); } 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 modificarDB(in_Motivo_Inven_Info info) { try { using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = Context.in_Motivo_Inven.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo_Inv == info.IdMotivo_Inv); if (Entity == null) { return(false); } Entity.Cod_Motivo_Inv = info.Cod_Motivo_Inv; Entity.Desc_mov_inv = info.Desc_mov_inv; Entity.Tipo_Ing_Egr = info.Tipo_Ing_Egr; Entity.Genera_Movi_Inven = info.Genera_Movi_Inven_bool == true ? "S" : "N"; Entity.IdCtaCble = info.IdCtaCble; Entity.IdUsuarioUltMod = info.IdUsuarioUltMod; Entity.Fecha_UltMod = DateTime.Now; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool guardarDB(in_Motivo_Inven_Info info) { try { using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = new in_Motivo_Inven { IdEmpresa = info.IdEmpresa, IdMotivo_Inv = info.IdMotivo_Inv = get_id(info.IdEmpresa), Cod_Motivo_Inv = info.Cod_Motivo_Inv, Desc_mov_inv = info.Desc_mov_inv, estado = info.estado = "A", Genera_Movi_Inven = info.Genera_Movi_Inven_bool == true ? "S" : "N", Tipo_Ing_Egr = info.Tipo_Ing_Egr, IdCtaCble = info.IdCtaCble, Fecha_Transac = DateTime.Now }; Context.in_Motivo_Inven.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public ActionResult Index() { #region Validar Session if (string.IsNullOrEmpty(SessionFixed.IdTransaccionSession)) { return(RedirectToAction("Login", new { Area = "", Controller = "Account" })); } SessionFixed.IdTransaccionSession = (Convert.ToDecimal(SessionFixed.IdTransaccionSession) + 1).ToString(); SessionFixed.IdTransaccionSessionActual = SessionFixed.IdTransaccionSession; #endregion #region Permisos seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "Inventario", "MotivoInventario", "Index"); ViewBag.Nuevo = info.Nuevo; #endregion in_Motivo_Inven_Info model = new in_Motivo_Inven_Info { IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa), IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession), }; var lst = bus_motivo.get_list(model.IdEmpresa, true); Lista_MotivoInv.set_list(lst, model.IdTransaccionSession); return(View(model)); }
public bool anularDB(in_Motivo_Inven_Info info) { try { using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = Context.in_Motivo_Inven.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdMotivo_Inv == info.IdMotivo_Inv); if (Entity == null) { return(false); } Entity.estado = Entity.estado = "I"; Entity.IdUsuarioUltAnu = info.IdUsuarioUltAnu; Entity.FechaHoraAnul = DateTime.Now; Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public Boolean AnularDB(in_Motivo_Inven_Info Info, ref int Id, ref string msg) { try { using (EntitiesInventario context = new EntitiesInventario()) { var contact = context.in_Motivo_Inven.FirstOrDefault(v => v.IdEmpresa == Info.IdEmpresa && v.IdMotivo_Inv == Info.IdMotivo_Inv); if (contact != null) { contact.estado = "I"; contact.FechaHoraAnul = DateTime.Now; contact.MotivoAnulacion = Info.MotivoAnulacion; contact.IdUsuarioUltAnu = Info.IdUsuarioUltAnu; context.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 ModificarDB(in_Motivo_Inven_Info Info, ref int Id, ref string msg) { try { using (EntitiesInventario context = new EntitiesInventario()) { var contact = context.in_Motivo_Inven.FirstOrDefault(v => v.IdEmpresa == Info.IdEmpresa && v.IdMotivo_Inv == Info.IdMotivo_Inv); if (contact != null) { contact.Cod_Motivo_Inv = Info.Cod_Motivo_Inv; contact.Desc_mov_inv = Info.Desc_mov_inv; contact.estado = Info.estado; contact.Genera_Movi_Inven = Info.Genera_Movi_Inven; contact.Fecha_UltMod = DateTime.Now; contact.IdUsuarioUltMod = Info.IdUsuarioUltMod; contact.IdUsuarioUltMod = Info.IdUsuarioUltMod; contact.Tipo_Ing_Egr = Info.Tipo_Ing_Egr.ToString(); context.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 in_Motivo_Inven_Info get_info(int IdEmpresa, int IdMotivo_Inv) { try { in_Motivo_Inven_Info info = new in_Motivo_Inven_Info(); using (Entities_inventario Context = new Entities_inventario()) { in_Motivo_Inven Entity = Context.in_Motivo_Inven.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdMotivo_Inv == IdMotivo_Inv); if (Entity == null) { return(null); } info = new in_Motivo_Inven_Info { IdEmpresa = Entity.IdEmpresa, IdMotivo_Inv = Entity.IdMotivo_Inv, Cod_Motivo_Inv = Entity.Cod_Motivo_Inv, Desc_mov_inv = Entity.Desc_mov_inv, estado = Entity.estado, Genera_Movi_Inven_bool = Entity.Genera_Movi_Inven == "S" ? true : false, Tipo_Ing_Egr = Entity.Tipo_Ing_Egr, IdCtaCble = Entity.IdCtaCble }; } return(info); } catch (Exception) { throw; } }
public ActionResult Nuevo(in_Motivo_Inven_Info model) { if (!bus_motivo.guardarDB(model)) { cargar_combos(); return(View(model)); } return(RedirectToAction("Consultar", new { IdEmpresa = model.IdEmpresa, IdMotivo_Inv = model.IdMotivo_Inv, Exito = true })); }
public ActionResult Nuevo(in_Motivo_Inven_Info model) { if (!bus_motivo.guardarDB(model)) { cargar_combos(); return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Nuevo(int IdEmpresa = 0) { in_Motivo_Inven_Info model = new in_Motivo_Inven_Info { IdEmpresa = IdEmpresa }; cargar_combos(); return(View(model)); }
public ActionResult Modificar(in_Motivo_Inven_Info model) { model.IdUsuarioUltMod = SessionFixed.IdUsuario.ToString(); if (!bus_motivo.modificarDB(model)) { cargar_combos(); return(View(model)); } return(RedirectToAction("Consultar", new { IdEmpresa = model.IdEmpresa, IdMotivo_Inv = model.IdMotivo_Inv, Exito = true })); }
public ActionResult Anular(in_Motivo_Inven_Info model) { model.IdUsuarioUltAnu = SessionFixed.IdUsuario.ToString(); if (!bus_motivo.anularDB(model)) { cargar_combos(); return(View(model)); } return(RedirectToAction("Index")); }
public bool anularDB(in_Motivo_Inven_Info info) { try { return(odata.anularDB(info)); } catch (Exception) { throw; } }
public ActionResult Anular(int IdEmpresa = 0, int IdMotivo_Inv = 0) { in_Motivo_Inven_Info model = bus_motivo.get_info(IdEmpresa, IdMotivo_Inv); if (model == null) { return(RedirectToAction("Index")); } cargar_combos(); return(View(model)); }
public void set_Info(in_Motivo_Inven_Info _Info) { try { Info = _Info; } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void preparar_formulario(Cl_Enumeradores.eTipo_action _Accion) { FrmIn_Motivo_Inven_Mant frm = new FrmIn_Motivo_Inven_Mant(); Info = (in_Motivo_Inven_Info)gridViewTipoInve.GetFocusedRow(); if (_Accion == Cl_Enumeradores.eTipo_action.Anular) { // Info = (com_estado_cierre_Info)gridViewEstado.GetFocusedRow(); if (Info != null) { if (Info.estado == "I") { MessageBox.Show("El registro ya se encuentra Anulado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { frm = new FrmIn_Motivo_Inven_Mant(); frm.set_Accion(Cl_Enumeradores.eTipo_action.Anular); frm.Text = frm.Text + "***ANULAR REGISTRO***"; } } else { MessageBox.Show("Seleccione un Registro a Anular", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } switch (_Accion) { case Cl_Enumeradores.eTipo_action.actualizar: frm.set_Info(Info); break; case Cl_Enumeradores.eTipo_action.grabar: break; case Cl_Enumeradores.eTipo_action.consultar: frm.set_Info(Info); break; case Cl_Enumeradores.eTipo_action.Anular: frm.set_Info(Info); break; } frm.set_Accion(_Accion); frm.MdiParent = this.MdiParent; frm.event_FrmIn_Motivo_Inven_Mant_FormClosing += frm_event_FrmIn_Motivo_Inven_Mant_FormClosing; frm.Show(); }
public Boolean GuardarDB(in_Motivo_Inven_Info Info, ref int Id, ref string msg) { try { using (EntitiesInventario DBInven = new EntitiesInventario()) { var que = from C in DBInven.in_Motivo_Inven where C.IdEmpresa == Info.IdEmpresa && C.IdMotivo_Inv == Info.IdMotivo_Inv select C; if (que.Count() == 0) { var TablaDb = new in_Motivo_Inven(); TablaDb.IdEmpresa = Info.IdEmpresa; TablaDb.IdMotivo_Inv = Info.IdMotivo_Inv = Id = getId(Info.IdEmpresa); TablaDb.Cod_Motivo_Inv = (Info.Cod_Motivo_Inv == "") ? TablaDb.IdMotivo_Inv.ToString() : Info.Cod_Motivo_Inv; TablaDb.Desc_mov_inv = Info.Desc_mov_inv; TablaDb.Genera_Movi_Inven = Info.Genera_Movi_Inven; TablaDb.estado = "A"; TablaDb.Genera_CXP = Info.Genera_CXP; TablaDb.Exigir_Punto_Cargo = Info.Exigir_Punto_Cargo; TablaDb.IdCtaCble_Costo = Info.IdCtaCble_Costo; TablaDb.IdCtaCble_Inven = Info.IdCtaCble_Inven; TablaDb.IdUsuarioUltMod = Info.IdUsuarioUltMod; TablaDb.Fecha_Transac = DateTime.Now; TablaDb.es_Inven_o_Consumo = Info.es_Inven_o_Consumo.ToString(); TablaDb.Tipo_Ing_Egr = Info.Tipo_Ing_Egr.ToString(); DBInven.in_Motivo_Inven.Add(TablaDb); DBInven.SaveChanges(); } else { msg = ""; 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.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
public Boolean AnularDB(in_Motivo_Inven_Info Imfo, ref int Id, ref string msg) { try { Imfo.IdUsuarioUltAnu = param.IdUsuario; Imfo.FechaHoraAnul = param.Fecha_Transac; return(odata.AnularDB(Imfo, ref Id, 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("", "AnularDB", ex.Message), ex) { EntityType = typeof(in_Motivo_Inven_Bus) }; } }
public ActionResult Anular(int IdEmpresa = 0, int IdMotivo_Inv = 0) { #region Permisos seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "Inventario", "MotivoInventario", "Index"); if (!info.Anular) { return(RedirectToAction("Index")); } #endregion in_Motivo_Inven_Info model = bus_motivo.get_info(IdEmpresa, IdMotivo_Inv); if (model == null) { return(RedirectToAction("Index")); } cargar_combos(); return(View(model)); }
public ActionResult Nuevo(int IdEmpresa = 0) { #region Permisos seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "Inventario", "MotivoInventario", "Index"); if (!info.Nuevo) { return(RedirectToAction("Index")); } #endregion in_Motivo_Inven_Info model = new in_Motivo_Inven_Info { IdEmpresa = IdEmpresa, Genera_Movi_Inven_bool = true }; cargar_combos(); return(View(model)); }
Boolean Genera_Inventario(in_Ing_Egr_Inven_Info info, ref decimal IdNumMovi, ref string mensaje) { string msg = ""; try { Boolean res = true; //graba inventario info.IdNumMovi = IdNumMovi; List <in_Ing_Egr_Inven_det_Info> lstIngEgre_MoviInven = new List <in_Ing_Egr_Inven_det_Info>(); in_Motivo_Inven_Bus BusMoti_Inv = new in_Motivo_Inven_Bus(); in_Motivo_Inven_Info info_MotInv = new in_Motivo_Inven_Info(); if (info.IdMotivo_Inv != 0) { info_MotInv = BusMoti_Inv.Get_Info_Motivo_Inven(info.IdEmpresa, Convert.ToInt32(info.IdMotivo_Inv)); } if (info_MotInv.Genera_Movi_Inven == "S") { lstIngEgre_MoviInven = info.listIng_Egr.Where(q => q.IdEstadoAproba == Cl_Enumeradores.eEstadoAprobacion_Ing_Egr.APRO.ToString()).ToList(); if (lstIngEgre_MoviInven.Count() > 0) { info.listIng_Egr = new List <in_Ing_Egr_Inven_det_Info>(); info.listIng_Egr = lstIngEgre_MoviInven; //graba inventario res = Genera_Inventario_x_IngEgr_Inven(info, ref msg); } } else { mensaje = "Se ha guardado la transacción de inventario, pero no se ha generado movimiento de inventario debido a que el motivo seleccionado no genera movimiento."; } 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("", "Genera_Inventario", ex.Message), ex) { EntityType = typeof(in_Ing_Egr_Inven_Bus) }; } }
public in_Motivo_Inven_Info get_MotivoInvInfo() { try { if (cmbMotivoInv.EditValue == null) { return(null); } InfoMotivoInv = listMotivoInv.FirstOrDefault(v => v.IdMotivo_Inv == Convert.ToInt32(cmbMotivoInv.EditValue)); return(InfoMotivoInv); } catch (Exception ex) { string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; MessageBox.Show(NameMetodo + " - " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); return(null); } }
private void LimpiarDatos() { try { txt_id.Text = ""; txt_descripcion.Text = ""; txt_codigo.Text = ""; chk_gen_movi_inv.Checked = false; chk_generacxp.Checked = false; chk_puntocargo.Checked = false; chk_estado.Checked = true; ucCon_CtaCble_Inven.set_PlanCtarInfo(""); ucCon_CtaCbleCosto.set_PlanCtarInfo(""); Info = new in_Motivo_Inven_Info(); } catch (Exception ex) { Log_Error_bus.Log_Error(ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Boolean validarobjeto(in_Motivo_Inven_Info Info, ref string msj) { try { if (Info.IdEmpresa == 0) { msj = "Error Id Empresa = 0"; return(false); } 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("", "validarobjeto", ex.Message), ex) { EntityType = typeof(in_Motivo_Inven_Bus) }; } }
public Boolean ModificarDB(in_Motivo_Inven_Info Imfo, ref int Id, ref string msg) { try { if (validarobjeto(Imfo, ref msg) == false) { return(false); } Imfo.IdUsuarioUltMod = param.IdUsuario; Imfo.Fecha_UltMod = param.Fecha_Transac; return(odata.ModificarDB(Imfo, ref Id, 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("", "ModificarDB", ex.Message), ex) { EntityType = typeof(in_Motivo_Inven_Bus) }; } }
public Boolean AnularDB(in_Ing_Egr_Inven_Info info, ref string msgs) { try { in_Ing_Egr_Inven_det_Bus BusDeta_Ing_Egr_Inven = new in_Ing_Egr_Inven_det_Bus(); Boolean Respuesta_anulacion = false; Boolean Respuesta_anulacion_Inventario = false; in_movi_inven_tipo_Info info_movi_inven_tipo = new in_movi_inven_tipo_Info(); in_movi_inven_tipo_Bus bus_movi_inven_tipo = new in_movi_inven_tipo_Bus(); info_movi_inven_tipo = bus_movi_inven_tipo.Get_Info_movi_inven_tipo(info.IdEmpresa, info.IdMovi_inven_tipo); in_Motivo_Inven_Info info_motivo_inven = new in_Motivo_Inven_Info(); in_Motivo_Inven_Bus bus_motivo_inven = new in_Motivo_Inven_Bus(); info_motivo_inven = bus_motivo_inven.Get_Info_Motivo_Inven(info.IdEmpresa, info.IdMotivo_Inv == null ? 0 : Convert.ToInt32(info.IdMotivo_Inv)); string genero_movi = info_movi_inven_tipo.Genera_Movi_Inven == true && info_motivo_inven.Genera_Movi_Inven == "S" ? "S" : "N"; if (info.listIng_Egr.Count() > 0) { info.IdEstadoAproba = info.listIng_Egr.Max(q => q.IdEstadoAproba); } if (info.IdEstadoAproba == "APRO") { odata.Reversar_Aprobacion(info.IdEmpresa, info.IdSucursal, info.IdMovi_inven_tipo, info.IdNumMovi, genero_movi); } info.IdusuarioUltAnu = param.IdUsuario; Respuesta_anulacion = odata.AnularDB(info, ref msgs); if (Respuesta_anulacion) { Respuesta_anulacion_Inventario = true; } //Agrupo lista de ordenes de compra var lst_oc = (from q in info.listIng_Egr where q.IdOrdenCompra != null group q by new { q.IdEmpresa_oc, q.IdSucursal_oc, q.IdOrdenCompra } into grouping select new { grouping.Key.IdEmpresa_oc, grouping.Key.IdSucursal_oc, grouping.Key.IdOrdenCompra } ).ToList(); BusDeta_Ing_Egr_Inven.Modificar_Enserar_Campos_OC(info.listIng_Egr); foreach (var item in lst_oc) { bus_oc.Modificar_Estado_Cierre(Convert.ToInt32(item.IdEmpresa_oc), Convert.ToInt32(item.IdSucursal_oc), Convert.ToInt32(item.IdOrdenCompra), "ABI"); } return(Respuesta_anulacion && Respuesta_anulacion_Inventario); } 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("", "AnularDB", ex.Message), ex) { EntityType = typeof(in_Ing_Egr_Inven_Bus) }; } }
public List <in_Motivo_Inven_Info> Get_List_Motivo_Inven(int IdEmpresa, string Tipo_Ing_Egr = "") { try { int Id = 0; string msg = ""; List <in_Motivo_Inven_Info> Lst = new List <in_Motivo_Inven_Info>(); EntitiesInventario oEnti = new EntitiesInventario(); var Query = from q in oEnti.in_Motivo_Inven where q.IdEmpresa == IdEmpresa && q.Tipo_Ing_Egr.Contains(Tipo_Ing_Egr) select q; // si no hay en la base creo uno por lo menos if (Query.Count() == 0) { in_Motivo_Inven_Info Info_a_Grabar = new in_Motivo_Inven_Info(); Info_a_Grabar.IdEmpresa = IdEmpresa; Info_a_Grabar.IdMotivo_Inv = 0; Info_a_Grabar.Tipo_Ing_Egr = (Tipo_Ing_Egr == "ING") ? ein_Tipo_Ing_Egr.ING : ein_Tipo_Ing_Egr.EGR; Info_a_Grabar.Genera_CXP = "N"; Info_a_Grabar.Exigir_Punto_Cargo = "N"; Info_a_Grabar.Genera_Movi_Inven = "N"; Info_a_Grabar.Cod_Motivo_Inv = ""; Info_a_Grabar.Desc_mov_inv = "Inventario"; GuardarDB(Info_a_Grabar, ref Id, ref msg); Lst.Add(Info_a_Grabar); return(Lst); } foreach (var item in Query) { in_Motivo_Inven_Info Obj = new in_Motivo_Inven_Info(); Obj.IdEmpresa = item.IdEmpresa; Obj.IdMotivo_Inv = item.IdMotivo_Inv; Obj.Cod_Motivo_Inv = item.Cod_Motivo_Inv; Obj.Desc_mov_inv = item.Desc_mov_inv; Obj.Genera_Movi_Inven = item.Genera_Movi_Inven; Obj.Genera_CXP = item.Genera_CXP; Obj.estado = item.estado; Obj.SEstado = (item.estado == "A") ? "ACTIVO" : "*ANULADO*"; Obj.IdCtaCble_Inven = item.IdCtaCble_Inven; Obj.IdCtaCble_Costo = item.IdCtaCble_Costo; Obj.IdUsuarioUltMod = item.IdUsuarioUltMod; Obj.Exigir_Punto_Cargo = item.Exigir_Punto_Cargo; Obj.es_Inven_o_Consumo = (item.es_Inven_o_Consumo == null) ? ein_Inventario_O_Consumo.TIC_INVEN : (ein_Inventario_O_Consumo)Enum.Parse(typeof(ein_Inventario_O_Consumo), item.es_Inven_o_Consumo); Obj.Tipo_Ing_Egr = (item.Tipo_Ing_Egr == null || item.Tipo_Ing_Egr == "") ? ein_Tipo_Ing_Egr.ING : (ein_Tipo_Ing_Egr)Enum.Parse(typeof(ein_Tipo_Ing_Egr), item.Tipo_Ing_Egr); 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()); } }
private bool grabar_movimientos_x_distribucion(in_Ing_Egr_Inven_distribucion_Info info_distribucion) { try { info_info_distribucion_in = bus_info_distribucion_in.get_info(info_distribucion.IdEmpresa, info_distribucion.IdSucursal, info_distribucion.IdMovi_inven_tipo, info_distribucion.IdNumMovi, (info_distribucion.signo == "+" ? "-" : "+")); lst_motivo_inve = data_motivo.get_list(info_distribucion.IdEmpresa, false); distribucion_sin_lote = oData.get_info(info_distribucion.IdEmpresa, info_distribucion.IdSucursal, info_distribucion.IdMovi_inven_tipo, info_distribucion.IdNumMovi, (info_distribucion.signo == "+" ? "-" : "+")); distribucion_con_lote = oData.get_info(info_distribucion.IdEmpresa, info_distribucion.IdSucursal, info_distribucion.IdMovi_inven_tipo, info_distribucion.IdNumMovi, info_distribucion.signo); #region Crear movimiento sin lote if (info_info_distribucion_in == null) { info_info_distribucion_in = info_distribucion; } #region Cabecera if (distribucion_sin_lote != null) { mov_sin_lote = bus_ing_egr.get_info(distribucion_sin_lote.IdEmpresa_dis, distribucion_sin_lote.IdSucursal_dis, distribucion_sin_lote.IdMovi_inven_tipo_dis, distribucion_sin_lote.IdNumMovi_dis); } else { info_motivo = lst_motivo_inve.FirstOrDefault(q => q.Genera_Movi_Inven == "S" && q.Tipo_Ing_Egr == (info_distribucion.signo == "+" ? "EGR" : "ING")); if (info_motivo == null) { return(false); } mov_sin_lote = new in_Ing_Egr_Inven_Info { IdEmpresa = info_distribucion.IdEmpresa, IdSucursal = info_distribucion.IdSucursal, IdMovi_inven_tipo = info_distribucion.signo == "+" ? Convert.ToInt32(info_info_distribucion_in.IdMovi_inven_tipo) : Convert.ToInt32(info_info_distribucion_in.IdMovi_inven_tipo), IdNumMovi = 0, IdBodega = info_distribucion.IdBodega, signo = (info_distribucion.signo == "+" ? "-" : "+"), CodMoviInven = "Dis_" + info_distribucion.IdEmpresa.ToString("00") + "_" + info_distribucion.IdSucursal.ToString("00") + "_" + info_distribucion.IdMovi_inven_tipo.ToString("00") + "_" + info_distribucion.IdNumMovi.ToString("000000000"), cm_observacion = "Dis. x lote ", cm_fecha = DateTime.Now.Date, IdUsuario = info_distribucion.IdUsuario, Estado = "A", Fecha_Transac = DateTime.Now, IdMotivo_Inv = info_motivo.IdMotivo_Inv }; } #endregion #region Detalle foreach (var item in info_distribucion.lst_x_distribuir) { if (item.can_distribuida > 0) { in_Ing_Egr_Inven_det_Info info_det = new in_Ing_Egr_Inven_det_Info { IdEmpresa = mov_sin_lote.IdEmpresa, IdSucursal = mov_sin_lote.IdSucursal, IdMovi_inven_tipo = mov_sin_lote.IdMovi_inven_tipo, IdNumMovi = mov_sin_lote.IdNumMovi, IdBodega = (int)mov_sin_lote.IdBodega, IdProducto = item.IdProducto, dm_observacion = "", dm_cantidad = item.can_distribuida == null ? 0 : Convert.ToDouble(item.can_distribuida) * (info_distribucion.signo == "+" ? -1 : 1), dm_cantidad_sinConversion = item.can_distribuida == null ? 0 : Convert.ToDouble(item.can_distribuida), mv_costo = item.mv_costo, mv_costo_sinConversion = item.mv_costo, IdUnidadMedida = item.IdUnidadMedida, IdUnidadMedida_sinConversion = item.IdUnidadMedida, }; mov_sin_lote.lst_in_Ing_Egr_Inven_det.Add(info_det); } } #endregion #endregion #region Crear movimiento con lote in_Ing_Egr_Inven_Info mov_con_lote = new in_Ing_Egr_Inven_Info(); #region Cabecera if (distribucion_con_lote != null) { mov_con_lote = bus_ing_egr.get_info(distribucion_con_lote.IdEmpresa_dis, distribucion_con_lote.IdSucursal_dis, distribucion_con_lote.IdMovi_inven_tipo_dis, distribucion_con_lote.IdNumMovi_dis); } else { info_motivo = lst_motivo_inve.FirstOrDefault(q => q.Genera_Movi_Inven == "S" && q.Tipo_Ing_Egr == (info_distribucion.signo == "+" ? "ING" : "EGR")); if (info_motivo == null) { return(false); } mov_con_lote = new in_Ing_Egr_Inven_Info { IdEmpresa = info_distribucion.IdEmpresa, IdSucursal = info_distribucion.IdSucursal, IdMovi_inven_tipo = info_distribucion.signo == "+" ? Convert.ToInt32(info_info_distribucion_in.IdMovi_inven_tipo) : Convert.ToInt32(info_info_distribucion_in.IdMovi_inven_tipo), IdNumMovi = 0, IdBodega = info_distribucion.IdBodega, signo = info_distribucion.signo, CodMoviInven = "Dis_" + info_distribucion.IdEmpresa.ToString("00") + "_" + info_distribucion.IdSucursal.ToString("00") + "_" + info_distribucion.IdMovi_inven_tipo.ToString("00") + "_" + info_distribucion.IdNumMovi.ToString("000000000"), cm_observacion = "Dis. x lote - Sucursal: ", cm_fecha = DateTime.Now.Date, IdUsuario = info_distribucion.IdUsuario, Estado = "A", Fecha_Transac = DateTime.Now, nom_pc = "", ip = "", IdMotivo_Inv = info_motivo.IdMotivo_Inv }; } #endregion #region Detalle foreach (var item in info_distribucion.lst_distribuido) { in_Ing_Egr_Inven_det_Info info_det = new in_Ing_Egr_Inven_det_Info { IdEmpresa = mov_sin_lote.IdEmpresa, IdSucursal = mov_sin_lote.IdSucursal, IdMovi_inven_tipo = mov_sin_lote.IdMovi_inven_tipo, IdNumMovi = mov_sin_lote.IdNumMovi, IdBodega = (int)info_distribucion.IdBodega, IdProducto = item.IdProducto, dm_observacion = "", dm_cantidad = item.dm_cantidad * (info_distribucion.signo == "+" ? 1 : -1), dm_cantidad_sinConversion = item.dm_cantidad, mv_costo = item.mv_costo, mv_costo_sinConversion = item.mv_costo, IdUnidadMedida = item.IdUnidadMedida, IdUnidadMedida_sinConversion = item.IdUnidadMedida, }; mov_con_lote.lst_in_Ing_Egr_Inven_det.Add(info_det); } #endregion #endregion #region guardar movimientos y distribucion if (distribucion_sin_lote == null) { if (!bus_ing_egr.guardarDB(mov_sin_lote, "")) { return(false); } distribucion_sin_lote = new in_Ing_Egr_Inven_distribucion_Info { IdEmpresa = info_distribucion.IdEmpresa, IdSucursal = info_distribucion.IdSucursal, IdMovi_inven_tipo = info_distribucion.IdMovi_inven_tipo, IdNumMovi = info_distribucion.IdNumMovi, IdEmpresa_dis = mov_sin_lote.IdEmpresa, IdSucursal_dis = mov_sin_lote.IdSucursal, IdMovi_inven_tipo_dis = mov_sin_lote.IdMovi_inven_tipo, IdNumMovi_dis = mov_sin_lote.IdNumMovi, signo = mov_sin_lote.signo, estado = true, }; if (!oData.guardarDB(distribucion_sin_lote)) { return(false); } } else { /* if (!bus_ing_egr.Reversar_Aprobacion(distribucion_sin_lote.IdEmpresa_dis, distribucion_sin_lote.IdSucursal_dis, distribucion_sin_lote.IdMovi_inven_tipo_dis, distribucion_sin_lote.IdNumMovi_dis, "S")) * return false; */ if (!bus_ing_egr.modificarDB(mov_sin_lote)) { return(false); } } if (distribucion_con_lote == null) { if (!bus_ing_egr.guardarDB(mov_con_lote, mov_con_lote.signo)) { return(false); } distribucion_con_lote = new in_Ing_Egr_Inven_distribucion_Info { IdEmpresa = info_distribucion.IdEmpresa, IdSucursal = info_distribucion.IdSucursal, IdMovi_inven_tipo = info_distribucion.IdMovi_inven_tipo, IdNumMovi = info_distribucion.IdNumMovi, IdEmpresa_dis = mov_con_lote.IdEmpresa, IdSucursal_dis = mov_con_lote.IdSucursal, IdMovi_inven_tipo_dis = mov_con_lote.IdMovi_inven_tipo, IdNumMovi_dis = mov_con_lote.IdNumMovi, signo = mov_con_lote.signo, estado = true, }; if (!oData.guardarDB(distribucion_con_lote)) { return(false); } } else { /* * if (!bus_ing_egr.Reversar_Aprobacion(distribucion_con_lote.IdEmpresa_dis, distribucion_con_lote.IdSucursal_dis, distribucion_con_lote.IdMovi_inven_tipo_dis, distribucion_con_lote.IdNumMovi_dis, "S")) * return false; */ if (!bus_ing_egr.modificarDB(mov_con_lote)) { return(false); } } #endregion return(true); } catch (Exception) { return(false); } }