public ActionResult TjQxYWpE(string sid) { CustomJSON globalResponse = new CustomJSON(); BEPais Pais = new BEPais(); string _err = string.Empty; if (User != null) { try { string Id = Peach.DecriptText(sid); Pais = new BLPais().Listar_byId(Convert.ToInt16(Id)); globalResponse.DATA = Pais; } catch (Exception ex) { globalResponse.ERR = ex.Message; } } else { return(RedirectToAction("Index", "Account", new { act = "timeout" })); } return(Json(globalResponse, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Graba o actualiza los datos de un pais /// </summary> /// <param name="model">modelo</param> /// <returns>ResponserData</returns> public ResponserData Grabar(BEPais model) { ResponserData Responser = new ResponserData(); try { using (SqlConnection oConexion = new SqlConnection(DBConexion)) { SqlCommand oComando = new SqlCommand(sp_grabar, oConexion); oComando.CommandType = CommandType.StoredProcedure; oComando.Parameters.Add("@p_idp", SqlDbType.Int).Value = model.Id; oComando.Parameters.Add("@p_nom", SqlDbType.VarChar, 40).Value = model.Nombre; oComando.Parameters.Add("@p_ofi", SqlDbType.VarChar, 60).Value = model.Oficial; oComando.Parameters.Add("@p_gen", SqlDbType.VarChar, 40).Value = model.Gentilicio; oComando.Parameters.Add("@p_m49", SqlDbType.VarChar, 3).Value = model.M49; oComando.Parameters.Add("@p_iso", SqlDbType.VarChar, 3).Value = model.ISOA3; oComando.Parameters.Add("@p_reg", SqlDbType.Int).Value = model.Region.Id; oComando.Parameters.Add("@p_usr", SqlDbType.VarChar, 12).Value = model.RowAudit.IUsr; oComando.Parameters.Add("@p_ipc", SqlDbType.VarChar, 15).Value = model.RowAudit.IP; oConexion.Open(); using (SqlDataReader dr = oComando.ExecuteReader()) { while (dr.Read()) { Responser.XID = DataUtil.ObjectToInt16(dr["i_id"]); Responser.Mensaje = DataUtil.ObjectToString(dr["s_msg"]); Responser.Estado = (ResponserEstado)DataUtil.ObjectToInt(dr["i_est"]); Responser.TipoAlerta = (BootstrapAlertType)DataUtil.ObjectToInt(dr["i_btp"]); } } oComando.Dispose(); } if (Responser.XID > 0 && Responser.Estado == ResponserEstado.Ok) { model.Id = Responser.XID; foreach (BEMoneda moneda in model.Monedas) { model.Moneda = new BEMoneda { Id = moneda.Id }; this.VincularMoneda(model); } } } catch (Exception ex) { throw ex; } return(Responser); }
/// <summary> /// Graba o actualiza los datos de un pais /// </summary> /// <param name="model">modelo</param> /// <returns>ResponserData</returns> public ResponserData Grabar(BEPais model) { try { return(DA.Grabar(model)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Devuelve los datos de un Pais /// </summary> /// <param name="sid">Id del País</param> /// <returns></returns> public BEPais Listar_byId(int sid) { BEPais Pais = new BEPais(); try { using (SqlConnection oConexion = new SqlConnection(DBConexion)) { SqlCommand oComando = new SqlCommand(sp_listar_byId, oConexion); oComando.CommandType = CommandType.StoredProcedure; oComando.Parameters.Add("@p_sid", SqlDbType.Int).Value = sid; oConexion.Open(); using (SqlDataReader dr = oComando.ExecuteReader()) { while (dr.Read() && dr.HasRows) { Pais.CID = Peach.EncriptText(DataUtil.ObjectToString(dr["i_sid"])); Pais.Nombre = DataUtil.ObjectToString(dr["s_pai"]); Pais.Oficial = DataUtil.ObjectToString(dr["s_nof"]); Pais.Gentilicio = DataUtil.ObjectToString(dr["s_gen"]); Pais.M49 = DataUtil.ObjectToString(dr["s_m49"]); Pais.ISOA3 = DataUtil.ObjectToString(dr["s_iso"]); Pais.Region = new BERegion { CID = Peach.EncriptText(DataUtil.ObjectToString(dr["i_rid"])), Nombre = DataUtil.ObjectToString(dr["s_rnm"]), Continente = new BEContinente { CID = Peach.EncriptText(DataUtil.ObjectToString(dr["i_cid"])), Nombre = DataUtil.ObjectToString(dr["s_cnm"]) } }; } } Pais.Monedas = new DAMoneda().Listar_byPais(sid); oComando.Dispose(); } } catch (Exception ex) { throw ex; } return(Pais); }
/// <summary> /// Asocia una moneda a un pais. /// </summary> /// <param name="BEPais">País</param> private void VincularMoneda(BEPais Pais) { try { using (SqlConnection oConexion = new SqlConnection(DBConexion)) { using (SqlCommand oComando = new SqlCommand(sp_grabar_detalle_moneda, oConexion)) { oComando.CommandType = CommandType.StoredProcedure; oComando.Parameters.Add("@p_pai", SqlDbType.TinyInt).Value = Pais.Id; oComando.Parameters.Add("@p_mnd", SqlDbType.SmallInt).Value = Pais.Moneda.Id; oComando.Parameters.Add("@p_usr", SqlDbType.VarChar, 12).Value = Pais.RowAudit.IUsr; oComando.Parameters.Add("@p_ipc", SqlDbType.VarChar, 15).Value = Pais.RowAudit.IP; oConexion.Open(); oComando.ExecuteNonQuery(); } } } catch (Exception ex) { throw ex; } }
public ActionResult bi8wZz09(List <string> dat, string[] mnd) { CustomJSON globalResponse = new CustomJSON(); ResponserData oResponse = new ResponserData(); List <BEMoneda> Monedas = new List <BEMoneda>(); BEPais Pais = new BEPais(); if (User != null) { try { var nom = dat[0].Trim().ToUpper(); var ofi = dat[1].Trim().ToUpper(); var gen = dat[2].Trim().ToUpper(); var m49 = dat[3].Trim().ToUpper(); var iso = dat[4].Trim().ToUpper(); var reg = dat[5]; var sid = (dat[6] == "0") ? dat[6] : Peach.DecriptText(dat[6]); Pais.Nombre = nom; Pais.Oficial = ofi; Pais.Gentilicio = gen; Pais.M49 = m49; Pais.ISOA3 = iso; Pais.Region = new BERegion { Id = Convert.ToInt16(Peach.DecriptText(reg)) }; Pais.Id = Convert.ToInt16(sid); if (mnd != null) { foreach (var m in mnd) { string sidm = Peach.DecriptText(m); Monedas.Add(new BEMoneda { Id = Convert.ToInt16(sidm) }); } } Pais.Monedas = Monedas; Pais.RowAudit = new IRowAudit { IUsr = Convert.ToInt16(Peach.DecriptText(User.CID)), IP = Common.PageUtility.GetUserIpAddress() }; oResponse = new BLPais().Grabar(Pais); globalResponse.DATA = oResponse; } catch (Exception ex) { globalResponse.ERR = ex.Message; } } else { return(RedirectToAction("Index", "Account", new { act = "timeout" })); } return(Json(globalResponse, JsonRequestBehavior.AllowGet)); }