private static void CargaTarifa(ClsTarifa tarifa) { tarifa.Id = Convert.ToInt32(dreader["ctar_ID"]); tarifa.Id32 = Convert.ToInt32(dreader["ctar_ID"]); tarifa.Fecha = Convert.ToDateTime(dreader["Fecha"]); tarifa.FechaValidesInicio = Convert.ToDateTime(dreader["FechaValidezInicio"]); tarifa.FechaValidesFin = Convert.ToDateTime(dreader["FechaValidezFin"]); tarifa.Estado = (ClsEstado.Estado)Convert.ToInt32(dreader["Ctar_IdEstado"]); if (dreader["Agente"] != null) { tarifa.Agente = dreader["Agente"].ToString(); } if (dreader["ComentarioCotizacion"] != null) { tarifa.Comentario = dreader["ComentarioCotizacion"].ToString(); } if (dreader["ComentarioInterno"] != null) { tarifa.ComentarioInterno = dreader["ComentarioInterno"].ToString(); } if (dreader["CreateDate"] != null) { tarifa.FechaCreacion = Convert.ToDateTime(dreader["CreateDate"]); } }
public static ResultadoTransaccion GuardarTarifa(ClsCotizacion cot, ClsTarifa tar) { var res = new ResultadoTransaccion(); IList<ClsItem> listItems = new List<ClsItem>(); try { //Abrir Conexion conn = BaseDatos.Conexion(); objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_N_Cotizacion_Tarifas"); objParams[0].Value = cot.Id; objParams[1].Value = tar.Fecha; objParams[2].Value = tar.FechaValidesInicio; objParams[3].Value = tar.FechaValidesFin; objParams[4].Value = tar.Agente; objParams[5].Value = tar.Comentario; objParams[6].Value = tar.ComentarioInterno; objParams[7].Value = (Int32)tar.Estado; objParams[8].Value = tar.FechaCreacion; objParams[9].Value = tar.Numero; var command = new SqlCommand("SP_N_Cotizacion_Tarifas", conn); command.Transaction = transaction; command.Parameters.AddRange(objParams); command.CommandType = CommandType.StoredProcedure; var comando = command.ExecuteScalar(); if (comando != null) { var id = Convert.ToInt64(comando); tar.Id = id; } //guardo Detalle primero foreach (var listItem in tar.Detalle) { GuardarDetalleTarifa(listItem, conn, tar.Id);//pasarle la conexion, ademas el id. } res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar; res.Descripcion = "Se creo la tarifa Exitosamente"; res.ObjetoTransaccion = listItems; //ClsCotizacionADO.ActualizaEstadoCotizacion(cot); } catch (Exception ex) { Log.EscribirLog(ex.Message); res.Descripcion = ex.Message; res.ArchivoError = "clsTarifaADO"; res.MetodoError = "GuardarTarifa"; } finally { conn.Close(); } return res; }
public DataTable Tarifa_createController(decimal tarifa, int idUsuarioOperador) { ClsTarifa clsTarifa = new ClsTarifa(); clsTarifa.Cantidad = tarifa; clsTarifa.IdUsuarioAlta = idUsuarioOperador; return(clsTarifa.Tarifa_create()); }
public static ResultadoTransaccion ActualizaTarifa(ClsCotizacion cot, ClsTarifa tar) { ResultadoTransaccion res = new ResultadoTransaccion(); IList <ClsItem> listItems = new List <ClsItem>(); try { //Abrir Conexion conn = BaseDatos.Conexion(); SqlCommand command = new SqlCommand("SP_U_Cotizacion_Tarifas", conn); command.Transaction = transaction; command.Parameters.AddWithValue("@IDCotizacion", cot.Id); command.Parameters.AddWithValue("@Fecha", tar.Fecha); command.Parameters.AddWithValue("@FechaValidezInicio", tar.FechaValidesInicio); command.Parameters.AddWithValue("@FechaValidezFin", tar.FechaValidesFin); command.Parameters.AddWithValue("@Agente", tar.Agente); command.Parameters.AddWithValue("@ComentarioCotizacion", tar.Comentario); command.Parameters.AddWithValue("@ComentarioInterno", tar.ComentarioInterno); command.Parameters.AddWithValue("@IdEstado", tar.Estado); command.Parameters.AddWithValue("@CreateDate", tar.FechaCreacion); SqlParameter outParam = command.Parameters.Add("@Id", SqlDbType.BigInt); outParam.Direction = ParameterDirection.Output; command.CommandType = CommandType.StoredProcedure; var id = command.ExecuteScalar(); res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar; res.ObjetoTransaccion = listItems; } catch (Exception ex) { Log.EscribirLog(ex.Message); res.Descripcion = ex.Message; res.ArchivoError = "clsTarifaADO"; res.MetodoError = "ActualizaTarifa"; } finally { conn.Close(); } return(res); }
public static ResultadoTransaccion ActualizaTarifa(ClsCotizacion cot, ClsTarifa tar) { ResultadoTransaccion res = new ResultadoTransaccion(); IList<ClsItem> listItems = new List<ClsItem>(); try { //Abrir Conexion conn = BaseDatos.Conexion(); SqlCommand command = new SqlCommand("SP_U_Cotizacion_Tarifas", conn); command.Transaction = transaction; command.Parameters.AddWithValue("@IDCotizacion", cot.Id); command.Parameters.AddWithValue("@Fecha", tar.Fecha); command.Parameters.AddWithValue("@FechaValidezInicio", tar.FechaValidesInicio); command.Parameters.AddWithValue("@FechaValidezFin", tar.FechaValidesFin); command.Parameters.AddWithValue("@Agente", tar.Agente); command.Parameters.AddWithValue("@ComentarioCotizacion", tar.Comentario); command.Parameters.AddWithValue("@ComentarioInterno", tar.ComentarioInterno); command.Parameters.AddWithValue("@IdEstado", tar.Estado); command.Parameters.AddWithValue("@CreateDate", tar.FechaCreacion); SqlParameter outParam = command.Parameters.Add("@Id", SqlDbType.BigInt); outParam.Direction = ParameterDirection.Output; command.CommandType = CommandType.StoredProcedure; var id = command.ExecuteScalar(); res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar; res.ObjetoTransaccion = listItems; } catch (Exception ex) { Log.EscribirLog(ex.Message); res.Descripcion = ex.Message; res.ArchivoError = "clsTarifaADO"; res.MetodoError = "ActualizaTarifa"; } finally { conn.Close(); } return res; }
private static List <ClsCotizacion> GetFromDataReader(SqlDataReader dreader) { var list = new List <ClsCotizacion>(); Int32 idAnteriorCot = 0; Int32 idAnteriorTar = 0; Int32 idAnteriorDet = 0; while (dreader.Read()) { if (dreader["id"] != null && Convert.ToInt32(dreader["id"]) != idAnteriorCot)//valido para que cargue 1 vez la cabecera { var item = new ClsCotizacion(); item.Tarifas = new List <ClsTarifa>(); item.IncoTerm = new clsIncoTerm(); CargaCotizacion(item); CargaIncoterm(item.IncoTerm); idAnteriorCot = item.Id32; list.Add(item); } //Cargo Tarifas if (!String.IsNullOrEmpty(dreader["ctar_ID"].ToString()) && Convert.ToInt32(dreader["ctar_ID"]) != idAnteriorTar) { var tarifa = new ClsTarifa(); tarifa.Detalle = new List <ClsDetalleTarifa>(); CargaTarifa(tarifa); idAnteriorTar = tarifa.Id32; //list[list.Count - 1].Tarifas.Add(tarifa);//agrego la nueva tarifa al ultimo elemento de la lista. list[list.Count - 1].AddTarifa(tarifa); } } return(list); }
private static List<ClsCotizacion> GetFromDataReader(SqlDataReader dreader) { var list = new List<ClsCotizacion>(); Int32 idAnteriorCot = 0; Int32 idAnteriorTar = 0; Int32 idAnteriorDet = 0; while (dreader.Read()) { if (dreader["id"] != null && Convert.ToInt32(dreader["id"]) != idAnteriorCot)//valido para que cargue 1 vez la cabecera { var item = new ClsCotizacion(); item.Tarifas = new List<ClsTarifa>(); item.IncoTerm = new clsIncoTerm(); CargaCotizacion(item); CargaIncoterm(item.IncoTerm); idAnteriorCot = item.Id32; list.Add(item); } //Cargo Tarifas if (!String.IsNullOrEmpty(dreader["ctar_ID"].ToString()) && Convert.ToInt32(dreader["ctar_ID"]) != idAnteriorTar) { var tarifa = new ClsTarifa(); tarifa.Detalle = new List<ClsDetalleTarifa>(); CargaTarifa(tarifa); idAnteriorTar = tarifa.Id32; //list[list.Count - 1].Tarifas.Add(tarifa);//agrego la nueva tarifa al ultimo elemento de la lista. list[list.Count - 1].AddTarifa(tarifa); } } return list; }
private static void CargaTarifa(ClsTarifa tarifa) { tarifa.Id = Convert.ToInt32(dreader["ctar_ID"]); tarifa.Id32 = Convert.ToInt32(dreader["ctar_ID"]); tarifa.Fecha = Convert.ToDateTime(dreader["Fecha"]); tarifa.FechaValidesInicio = Convert.ToDateTime(dreader["FechaValidezInicio"]); tarifa.FechaValidesFin = Convert.ToDateTime(dreader["FechaValidezFin"]); tarifa.Estado = (ClsEstado.Estado)Convert.ToInt32(dreader["Ctar_IdEstado"]); if (dreader["Agente"] != null) tarifa.Agente = dreader["Agente"].ToString(); if (dreader["ComentarioCotizacion"] != null) tarifa.Comentario = dreader["ComentarioCotizacion"].ToString(); if (dreader["ComentarioInterno"] != null) tarifa.ComentarioInterno = dreader["ComentarioInterno"].ToString(); if (dreader["CreateDate"] != null) tarifa.FechaCreacion = Convert.ToDateTime(dreader["CreateDate"]); }
public static ResultadoTransaccion ListarTarifas(ClsCotizacion cotizacion) { ResultadoTransaccion res = new ResultadoTransaccion(); IList<ClsTarifa> listItems = new List<ClsTarifa>(); try { //Abrir Conexion conn = BaseDatos.Conexion(); //Consultar Asuntos x Tipo Actividad objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_L_Cotizacion_Tarifas"); SqlCommand command = new SqlCommand("SP_L_Cotizacion_Tarifas", conn); command.Transaction = transaction; command.Parameters.AddRange(objParams); command.CommandType = CommandType.StoredProcedure; dreader = command.ExecuteReader(); while (dreader.Read()) { var item = new ClsTarifa(); item.Id = Convert.ToInt32(dreader["ID"]); item.Id32 = Convert.ToInt32(dreader["ID"]); //item.cotizacion = Convert.ToInt32(dreader["IDCotizacion"]); if (dreader["Fecha"] != null) item.Fecha = Convert.ToDateTime(dreader["Fecha"]); if (dreader["FechaValidezInicio"] != null) item.FechaValidesInicio = Convert.ToDateTime(dreader["FechaValidezInicio"]); if (dreader["FechaValidezFin"] != null) item.FechaValidesFin = Convert.ToDateTime(dreader["FechaValidezFin"]); if (dreader["Agente"] != null) item.Agente = dreader["Agente"].ToString(); // if (dreader["ComentarioCotizacion"] != null) //item.ComentarioCotizacion = dreader["ComentarioCotizacion"].ToString(); if (dreader["ComentarioInterno"] != null) item.ComentarioInterno = dreader["ComentarioInterno"].ToString(); if (dreader["IdEstado"] != null) item.Id32 = Convert.ToInt32(dreader["IdEstado"]); if (dreader["CreateDate"] != null) item.FechaCreacion = Convert.ToDateTime(dreader["CreateDate"]); listItems.Add(item); } res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar; res.ObjetoTransaccion = listItems; } catch (Exception ex) { Log.EscribirLog(ex.Message); res.Descripcion = ex.Message; res.ArchivoError = "clsTarifaADO"; res.MetodoError = "ListarTarifas"; } finally { conn.Close(); } return res; }
public static ResultadoTransaccion ListarTarifas(ClsCotizacion cotizacion) { ResultadoTransaccion res = new ResultadoTransaccion(); IList <ClsTarifa> listItems = new List <ClsTarifa>(); try { //Abrir Conexion conn = BaseDatos.Conexion(); //Consultar Asuntos x Tipo Actividad objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_L_Cotizacion_Tarifas"); SqlCommand command = new SqlCommand("SP_L_Cotizacion_Tarifas", conn); command.Transaction = transaction; command.Parameters.AddRange(objParams); command.CommandType = CommandType.StoredProcedure; dreader = command.ExecuteReader(); while (dreader.Read()) { var item = new ClsTarifa(); item.Id = Convert.ToInt32(dreader["ID"]); item.Id32 = Convert.ToInt32(dreader["ID"]); //item.cotizacion = Convert.ToInt32(dreader["IDCotizacion"]); if (dreader["Fecha"] != null) { item.Fecha = Convert.ToDateTime(dreader["Fecha"]); } if (dreader["FechaValidezInicio"] != null) { item.FechaValidesInicio = Convert.ToDateTime(dreader["FechaValidezInicio"]); } if (dreader["FechaValidezFin"] != null) { item.FechaValidesFin = Convert.ToDateTime(dreader["FechaValidezFin"]); } if (dreader["Agente"] != null) { item.Agente = dreader["Agente"].ToString(); } // if (dreader["ComentarioCotizacion"] != null) //item.ComentarioCotizacion = dreader["ComentarioCotizacion"].ToString(); if (dreader["ComentarioInterno"] != null) { item.ComentarioInterno = dreader["ComentarioInterno"].ToString(); } if (dreader["IdEstado"] != null) { item.Id32 = Convert.ToInt32(dreader["IdEstado"]); } if (dreader["CreateDate"] != null) { item.FechaCreacion = Convert.ToDateTime(dreader["CreateDate"]); } listItems.Add(item); } res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar; res.ObjetoTransaccion = listItems; } catch (Exception ex) { Log.EscribirLog(ex.Message); res.Descripcion = ex.Message; res.ArchivoError = "clsTarifaADO"; res.MetodoError = "ListarTarifas"; } finally { conn.Close(); } return(res); }
public static ResultadoTransaccion GuardarTarifa(ClsCotizacion cot, ClsTarifa tar) { var res = new ResultadoTransaccion(); IList <ClsItem> listItems = new List <ClsItem>(); try { //Abrir Conexion conn = BaseDatos.Conexion(); objParams = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_N_Cotizacion_Tarifas"); objParams[0].Value = cot.Id; objParams[1].Value = tar.Fecha; objParams[2].Value = tar.FechaValidesInicio; objParams[3].Value = tar.FechaValidesFin; objParams[4].Value = tar.Agente; objParams[5].Value = tar.Comentario; objParams[6].Value = tar.ComentarioInterno; objParams[7].Value = (Int32)tar.Estado; objParams[8].Value = tar.FechaCreacion; objParams[9].Value = tar.Numero; var command = new SqlCommand("SP_N_Cotizacion_Tarifas", conn); command.Transaction = transaction; command.Parameters.AddRange(objParams); command.CommandType = CommandType.StoredProcedure; var comando = command.ExecuteScalar(); if (comando != null) { var id = Convert.ToInt64(comando); tar.Id = id; } //guardo Detalle primero foreach (var listItem in tar.Detalle) { GuardarDetalleTarifa(listItem, conn, tar.Id);//pasarle la conexion, ademas el id. } res.Accion = Entidades.Enums.Enums.AccionTransaccion.Consultar; res.Descripcion = "Se creo la tarifa Exitosamente"; res.ObjetoTransaccion = listItems; //ClsCotizacionADO.ActualizaEstadoCotizacion(cot); } catch (Exception ex) { Log.EscribirLog(ex.Message); res.Descripcion = ex.Message; res.ArchivoError = "clsTarifaADO"; res.MetodoError = "GuardarTarifa"; } finally { conn.Close(); } return(res); }