public static IList<clsTipoDestinoCarga> ListarTiposDestinoCarga(string descripcion) { IList<clsTipoDestinoCarga> lista = new List<clsTipoDestinoCarga>(); clsTipoDestinoCarga destino; SqlDataReader objReader = null; SqlParameter[] objParams; try { objParams = SqlHelperParameterCache.GetSpParameterSet(BaseDatos.GetConexion(), "SP_C_TIPO_DESTINO_CARGA"); objParams[0].Value = descripcion; objReader = SqlHelper.ExecuteReader(BaseDatos.GetConexion(), "SP_C_TIPO_DESTINO_CARGA", objParams); while (objReader.Read()) { destino = new clsTipoDestinoCarga(); destino.Id = Convert.ToInt64(objReader["Id"]); destino.Nombre = objReader["Descripcion"].ToString(); destino.Usuario.Id = Convert.ToInt64(objReader["IdUsuario"]); destino.Usuario.Nombre = objReader["Nombres"].ToString(); destino.Usuario.ApellidoPaterno = objReader["ApellidoPaterno"].ToString(); destino.Usuario.ApellidoMaterno = objReader["ApellidoMaterno"].ToString(); destino.FechaCreacion = Convert.ToDateTime(objReader["FechaCreacion"]); lista.Add(destino); } } catch (Exception ex) { Base.Log.Log.EscribirLog(ex.Message); return null; } finally { if (objReader != null) objReader.Close(); } return lista; }
public static ResultadoTransaccion AgregarDestinoCarga(clsTipoDestinoCarga destino, SqlConnection conn, SqlTransaction transaction) { ResultadoTransaccion res = new ResultadoTransaccion(); Int64 idOrigenCarga = 0; try { objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_N_TIPO_DESTINO_CARGA"); objParams[0].Value = destino.Nombre; objParams[1].Value = destino.Usuario.Id; SqlCommand command4 = new SqlCommand("SP_N_TIPO_DESTINO_CARGA", conn); command4.Transaction = transaction; command4.Parameters.AddRange(objParams); command4.CommandType = CommandType.StoredProcedure; idOrigenCarga = Convert.ToInt64(command4.ExecuteScalar()); res.Estado = Enums.EstadoTransaccion.Aceptada; res.ObjetoTransaccion = idOrigenCarga; } catch (Exception ex) { res.Estado = Enums.EstadoTransaccion.Rechazada; res.Descripcion = ex.Message; Log.EscribirLog(ex.Message); } return res; }
private void AgregarDestinoCarga() { clsTipoDestinoCarga destino = null; cboDestinoBusqueda.SelectedIndex = 0; if (txtBusquedaDestinos.Text.Trim() == "") { destino = null; } else { for (int i = 0; i < cboDestinoBusqueda.Properties.Items.Count; i++) { if (cboDestinoBusqueda.Properties.Items[i].ToString() == txtBusquedaDestinos.Text) cboDestinoBusqueda.SelectedIndex = i; } if (cboDestinoBusqueda.SelectedIndex != 0) { destino = (clsTipoDestinoCarga)this.cboDestinoBusqueda.SelectedItem; } } if (destino == null) { destino = new clsTipoDestinoCarga(); destino.Nombre = txtBusquedaDestinos.Text; destino.Usuario = Base.Usuario.UsuarioConectado.Usuario; } List<clsTipoDestinoCarga> destinolist = new List<clsTipoDestinoCarga>(TargetAccount.DestinosCarga); clsTipoDestinoCarga foo = destinolist.Find(delegate(clsTipoDestinoCarga var) { return var.Nombre.ToUpper().Trim() == destino.Nombre.ToUpper().Trim(); }); if (foo != null) { dxErrorProvider1.SetError(txtBusquedaDestinos, "El Destino '" + destino.Nombre + "' ya esta ingresado", ErrorType.Critical); return; } TargetAccount.DestinosCarga.Add(destino); lstDestinos.ValueMember = "Id"; lstDestinos.DisplayMember = "Nombre"; lstDestinos.DataSource = TargetAccount.DestinosCarga; lstDestinos.Refresh(); txtBusquedaDestinos.Text = ""; dxErrorProvider1.ClearErrors(); }
public static IList<clsTipoDestinoCarga> ObtenerDestinoCargaTargetAccount(Int64 IdMaster) { IList<clsTipoDestinoCarga> listado = new List<clsTipoDestinoCarga>(); clsTipoDestinoCarga destino = null; try { objParams = SqlHelperParameterCache.GetSpParameterSet(BaseDatos.NuevaConexion(), "SP_C_CLIENTES_MASTER_DESTINOCARGA"); objParams[0].Value = IdMaster; DataSet ds = SqlHelper.ExecuteDataset(BaseDatos.NuevaConexion(), CommandType.StoredProcedure, "SP_C_CLIENTES_MASTER_DESTINOCARGA", objParams); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { destino = new clsTipoDestinoCarga(); destino.Id = Convert.ToInt64(item["IdDestino"]); destino.Nombre = item["Descripcion"].ToString(); listado.Add(destino); } } } catch (Exception ex) { Base.Log.Log.EscribirLog(ex.Message); } finally { BaseDatos.CerrarNuevaCOnexion(); } return listado; }