public Proveedor_Info GetInfo(string pv_CedulaRuc) { try { Proveedor_Info info = new Proveedor_Info(); using (EntitiesGeneral db = new EntitiesGeneral()) { Proveedor Entity = db.Proveedor.Where(q => q.pv_CedulaRuc == pv_CedulaRuc).FirstOrDefault(); if (Entity == null) { return(null); } info = new Proveedor_Info { IdProveedor = Entity.IdProveedor, pv_CedulaRuc = Entity.pv_CedulaRuc, pv_Codigo = Entity.pv_Codigo, pv_Correo = Entity.pv_Correo, pv_Descripcion = Entity.pv_Descripcion, pv_Direccion = Entity.pv_Direccion, pv_Estado = Entity.pv_Estado, pv_Plazo = Entity.pv_Plazo, pv_Telefono = Entity.pv_Telefono, pv_TipoDoc = Entity.pv_TipoDoc }; } return(info); } catch (Exception) { throw; } }
public bool GuardarDB(Proveedor_Info info) { try { using (EntitiesGeneral db = new EntitiesGeneral()) { db.Proveedor.Add(new Proveedor { IdProveedor = info.IdProveedor = GetID(), pv_CedulaRuc = info.pv_CedulaRuc, pv_Codigo = info.pv_Codigo, pv_Correo = info.pv_Correo, pv_Descripcion = info.pv_Descripcion, pv_Direccion = info.pv_Direccion, pv_Estado = true, pv_Plazo = info.pv_Plazo, pv_Telefono = info.pv_Telefono, pv_TipoDoc = info.pv_TipoDoc }); db.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public Proveedor_Info get_info_Nexpirion(string Tipo, string Codigo) { try { Proveedor_Info info = new Proveedor_Info(); using (EntitiesNexpirion Context = new EntitiesNexpirion()) { fcclient Entity = Context.fcclient.Where(q => q.tipo == Tipo && q.codigo.Trim() == Codigo).FirstOrDefault(); if (Entity == null) { return(null); } info = new Proveedor_Info { Tipo = Entity.tipo, Codigo = Entity.codigo, Nombre = Entity.nombre.Trim(), Ruc = Entity.ruc.Trim() }; } return(info); } catch (Exception EX) { data_log.GuardarDB(new LogError_Info { Controlador = "Proveedor_Data", Error = "Error: " + EX.ToString() + " " + string.Format("get_info_Nexpirion: " + Tipo + " " + Codigo), IdUsuario = "" }); return(null); } }
public bool EliminarBD(Proveedor_Info info) { try { using (EntitiesGeneral db = new EntitiesGeneral()) { var sql_det = "delete from ProveedorProducto where Tipo = '" + info.Tipo + "' and Codigo = '" + info.Codigo + "'"; db.Database.ExecuteSqlCommand(sql_det); var sql = "delete from Proveedor where Tipo = '" + info.Tipo + "' and Codigo = '" + info.Codigo + "'"; db.Database.ExecuteSqlCommand(sql); } using (EntitiesNexpirion db_nx = new EntitiesNexpirion()) { var sql_nx = "delete from FX_ProveedorMigrado where Tipo = '" + info.Tipo + "' and Codigo = '" + info.Codigo + "'"; db_nx.Database.ExecuteSqlCommand(sql_nx); } return(true); } catch (Exception EX) { data_log.GuardarDB(new LogError_Info { Controlador = "Proveedor_Data", Error = "Error: " + EX.ToString() + " " + string.Format("EliminarBD: {0}", JsonConvert.SerializeObject(info)), IdUsuario = "" }); return(false); } }
public bool ModificarDB(Proveedor_Info info) { try { using (EntitiesGeneral db = new EntitiesGeneral()) { Proveedor Entity = db.Proveedor.Where(q => q.IdProveedor == info.IdProveedor).FirstOrDefault(); if (Entity == null) { return(false); } Entity.pv_CedulaRuc = info.pv_CedulaRuc; Entity.pv_Codigo = info.pv_Codigo; Entity.pv_Correo = info.pv_Correo; Entity.pv_Descripcion = info.pv_Descripcion; Entity.pv_Direccion = info.pv_Direccion; Entity.pv_Plazo = info.pv_Plazo; Entity.pv_Telefono = info.pv_Telefono; Entity.pv_TipoDoc = info.pv_TipoDoc; db.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public bool GuardarBD(Proveedor_Info info) { try { using (EntitiesGeneral db = new EntitiesGeneral()) { db.Proveedor.Add(new Proveedor { Tipo = info.Tipo, Codigo = info.Codigo, Nombre = info.Nombre, Ruc = info.Ruc, ConceptoCompra = info.ConceptoCompra }); //detalle if (info.ListaProveedorProductoDetalle != null) { int Secuencia = 1; foreach (var item in info.ListaProveedorProductoDetalle) { db.ProveedorProducto.Add(new ProveedorProducto { Tipo = info.Tipo, Codigo = info.Codigo, Secuencia = Secuencia++, IdProducto = item.IdProducto }); } } db.SaveChanges(); } using (EntitiesNexpirion db_nx = new EntitiesNexpirion()) { db_nx.FX_ProveedorMigrado.Add(new FX_ProveedorMigrado { Tipo = info.Tipo, Codigo = info.Codigo, Nombre = info.Nombre, Ruc = info.Ruc }); db_nx.SaveChanges(); } return(true); } catch (Exception EX) { data_log.GuardarDB(new LogError_Info { Controlador = "Proveedor_Data", Error = "Error: " + EX.ToString() + " " + string.Format("GuardarBD: {0}", JsonConvert.SerializeObject(info)), IdUsuario = "" }); return(false); } }
public ActionResult Anular(Proveedor_Info model) { if (!bus_proveedor.AnularDB(model)) { return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Nuevo(Proveedor_Info model) { if (!bus_proveedor.GuardarDB(model)) { return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult EditingDelete(int Secuencia) { Lista_ProveedorProductoDetalle.DeleteRow(Secuencia, Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual)); Proveedor_Info model = new Proveedor_Info(); model.ListaProveedorProductoDetalle = Lista_ProveedorProductoDetalle.get_list(Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual)); cargar_combos_detalle(); return(PartialView("_GridViewPartial_ProveedorProductoDetalle", model.ListaProveedorProductoDetalle)); }
public ActionResult Anular(decimal IdProveedor = 0) { Proveedor_Info model = bus_proveedor.GetInfo(IdProveedor); if (model == null) { return(RedirectToAction("Index")); } return(View(model)); }
public bool AnularDB(Proveedor_Info info) { try { return(odata.AnularDB(info)); } catch (Exception) { throw; } }
private bool Validar(Proveedor_Info i_validar, ref string msg) { i_validar.ListaProveedorProductoDetalle = Lista_ProveedorProductoDetalle.get_list(i_validar.IdTransaccionSession); if (i_validar.ListaProveedorProductoDetalle.Count == 0) { mensaje = "Debe ingresar al menos un registro en el detalle"; return(false); } return(true); }
public ActionResult Nuevo(string Tipo = "", string Codigo = "") { #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 Proveedor_Info model = data_Proveedor.get_info_Nexpirion(Tipo, Codigo); model.IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession); Lista_ProveedorProductoDetalle.set_list(new List <ProveedorProducto_Info>(), model.IdTransaccionSession); cargar_combos(); return(View(model)); }
public ActionResult Modificar(Proveedor_Info model) { model.ListaProveedorProductoDetalle = Lista_ProveedorProductoDetalle.get_list(model.IdTransaccionSession); if (!Validar(model, ref mensaje)) { ViewBag.mensaje = mensaje; cargar_combos(); return(View(model)); } if (!data_Proveedor.ModificarBD(model)) { cargar_combos(); return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Nuevo(Proveedor_Info model) { model.ListaProveedorProductoDetalle = Lista_ProveedorProductoDetalle.get_list(model.IdTransaccionSession); if (!Validar(model, ref mensaje)) { ViewBag.mensaje = mensaje; SessionFixed.IdTransaccionSessionActual = model.IdTransaccionSession.ToString(); cargar_combos(); return(View(model)); } if (!data_Proveedor.GuardarBD(model)) { SessionFixed.IdTransaccionSessionActual = model.IdTransaccionSession.ToString(); cargar_combos(); return(View(model)); } return(RedirectToAction("Index")); }
public ActionResult Eliminar(string Tipo = "", string Codigo = "") { #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 Proveedor_Info model = data_Proveedor.get_info(Tipo, Codigo); if (!data_Proveedor.EliminarBD(model)) { cargar_combos(); ViewBag.mensaje = "No se ha podido eliminar el registro"; } ; return(RedirectToAction("Index")); }
public bool AnularDB(Proveedor_Info info) { try { using (EntitiesGeneral db = new EntitiesGeneral()) { Proveedor Entity = db.Proveedor.Where(q => q.IdProveedor == info.IdProveedor).FirstOrDefault(); if (Entity == null) { return(false); } Entity.pv_Estado = false; db.SaveChanges(); } return(true); } catch (Exception) { throw; } }
public Proveedor_Info get_info(string Tipo, string Codigo) { try { Proveedor_Info info = new Proveedor_Info(); using (EntitiesGeneral Context = new EntitiesGeneral()) { Context.SetCommandTimeOut(3000); Proveedor Entity = Context.Proveedor.Where(q => q.Tipo == Tipo && q.Codigo == Codigo).FirstOrDefault(); if (Entity == null) { return(null); } info = new Proveedor_Info { Tipo = Entity.Tipo, Codigo = Entity.Codigo, Nombre = Entity.Nombre, Ruc = Entity.Ruc, ConceptoCompra = Entity.ConceptoCompra }; } return(info); } catch (Exception EX) { data_log.GuardarDB(new LogError_Info { Controlador = "Proveedor_Data", Error = "Error: " + EX.ToString() + " " + string.Format("get_info: " + Tipo + " " + Codigo), IdUsuario = "" }); return(null); } }
public ActionResult Modificar(string Tipo = "", string Codigo = "") { #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 Proveedor_Info model = data_Proveedor.get_info(Tipo, Codigo); if (model == null) { return(RedirectToAction("Index")); } model.IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession); model.ListaProveedorProductoDetalle = data_ProveedorProducto.GetList(Convert.ToString(model.Codigo)); Lista_ProveedorProductoDetalle.set_list(model.ListaProveedorProductoDetalle, model.IdTransaccionSession); cargar_combos(); return(View(model)); }
public ActionResult Index2() { var model = new Proveedor_Info(); return(View(model)); }
public bool ModificarBD(Proveedor_Info info) { try { using (EntitiesGeneral db = new EntitiesGeneral()) { Proveedor entity = db.Proveedor.Where(q => q.Tipo == info.Tipo && q.Codigo == info.Codigo).FirstOrDefault(); if (entity == null) { return(false); } entity.Tipo = info.Tipo; entity.Codigo = info.Codigo; entity.Ruc = info.Ruc; entity.ConceptoCompra = info.ConceptoCompra; var lst_detalle = db.ProveedorProducto.Where(q => q.Tipo == info.Tipo && q.Codigo == info.Codigo).ToList(); db.ProveedorProducto.RemoveRange(lst_detalle); if (info.ListaProveedorProductoDetalle != null) { int Secuencia = 1; foreach (var item in info.ListaProveedorProductoDetalle) { db.ProveedorProducto.Add(new ProveedorProducto { Tipo = info.Tipo, Codigo = info.Codigo, Secuencia = Secuencia++, IdProducto = item.IdProducto }); } } db.SaveChanges(); } using (EntitiesNexpirion db_nx = new EntitiesNexpirion()) { FX_ProveedorMigrado entity_nx = db_nx.FX_ProveedorMigrado.Where(q => q.Tipo == info.Tipo && q.Codigo == info.Codigo).FirstOrDefault(); if (entity_nx == null) { return(false); } entity_nx.Tipo = info.Tipo; entity_nx.Codigo = info.Codigo; entity_nx.Ruc = info.Ruc; db_nx.SaveChanges(); } return(true); } catch (Exception EX) { data_log.GuardarDB(new LogError_Info { Controlador = "Proveedor_Data", Error = "Error: " + EX.ToString() + " " + string.Format("Modificar: {0}", JsonConvert.SerializeObject(info)), IdUsuario = "" }); return(false); } }
public ActionResult Nuevo() { Proveedor_Info model = new Proveedor_Info(); return(View(model)); }