public int insertar_historial_estados_cv(Ent_HistorialEstadosCV historial) { string sqlquery = "usp_insertar_historial_estados_cv"; int f = 0; try { using (SqlConnection cn = new SqlConnection(Ent_Conexion.conexion)) { if (cn.State == 0) { cn.Open(); } using (SqlCommand cmd = new SqlCommand(sqlquery, cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@cod_entid", historial.cod_entid); cmd.Parameters.AddWithValue("@fc_nint", historial.fc_nint); cmd.Parameters.AddWithValue("@id_estado", historial.id_estado); cmd.Parameters.AddWithValue("@descripcion", historial.descripcion); cmd.Parameters.AddWithValue("@cod_usuario", historial.cod_usuario); cmd.Parameters.AddWithValue("@cod_vendedor", historial.cod_vendedor); cmd.Parameters.AddWithValue("@cod_tda", historial.cod_tda); cmd.Parameters.AddWithValue("@serie_numero", historial.serieNumero); f = cmd.ExecuteNonQuery(); } } }catch (Exception ex) { f = 0; } return(f); }
public void insertar_historial_estados_cv(string cod_entid, string fc_nint, string descripcion, string id_estado, string cod_vendedor, string cod_tda, string serieNumero) { Ent_Usuario user = null; user = (Ent_Usuario)Session[Ent_Constantes.NameSessionUser]; string _usu_id = user.usu_id.ToString(); Ent_HistorialEstadosCV _historial = new Ent_HistorialEstadosCV(); _historial.cod_entid = cod_entid; _historial.cod_usuario = _usu_id; _historial.fc_nint = fc_nint; _historial.descripcion = descripcion; _historial.id_estado = id_estado; _historial.cod_vendedor = cod_vendedor; _historial.serieNumero = serieNumero; _historial.cod_tda = cod_tda; int f = datos.insertar_historial_estados_cv(_historial); if (f > 0) { TempData["Success"] = "Se actualizo el estado correctamente"; } else { TempData["Error"] = "Error al actualizar el estado."; } }
public Ent_VentaCanal get_Ventas_por_sn(string noDoc, string cod_entid, string fc_nint) { Ent_VentaCanal ven = null; string sqlquery = "usp_select_canal_ventas_por_sn"; try { //Ent_Conexion.conexion = "Server=192.168.1.242;Database=BDPOS;User ID=sa;Password=1;Trusted_Connection=False;"; using (SqlConnection cn = new SqlConnection(Ent_Conexion.conexion)) { if (cn.State == 0) { cn.Open(); } using (SqlCommand cmd = new SqlCommand(sqlquery, cn)) { cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@serie_numero", noDoc); cmd.Parameters.AddWithValue("@cod_entid", cod_entid); cmd.Parameters.AddWithValue("@fc_nint", fc_nint); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables.Count > 0) { DataTable dtC = ds.Tables[0]; DataTable dtD = ds.Tables[1]; DataTable dtH = ds.Tables[2]; DataTable dtIC = ds.Tables[3]; DataTable dtID = ds.Tables[4]; ven = new Ent_VentaCanal(); ven.cod_entid = dtC.Rows[0]["COD_ENTID"].ToString(); ven.serieNumero = dtC.Rows[0]["FC_SFAC"].ToString() + "-" + dtC.Rows[0]["FC_NFAC"].ToString(); ven.tiendaOrigen = dtC.Rows[0]["COD_ENTID"].ToString() + " - " + dtC.Rows[0]["des_entida"].ToString(); ven.tiendaDestino = dtC.Rows[0]["FC_ID_TDACVTA"].ToString() + " - " + dtC.Rows[0]["des_entidb"].ToString(); ven.tipo = dtC.Rows[0]["FC_ID_TIP_CVTA"].ToString().Trim(); ven.estado = dtC.Rows[0]["FC_ID_ESTADO_CVTA"].ToString(); ven.cliente = (dtC.Rows[0]["FC_RUC"].ToString() + " - " + dtC.Rows[0]["FC_NOMB"].ToString() + " " + dtC.Rows[0]["FC_APEP"].ToString() + " " + dtC.Rows[0]["FC_APEM"].ToString()).Trim(); ven.fechaVenta = Convert.ToDateTime(dtC.Rows[0]["FC_FFAC"]); ven.direccionA = dtC.Rows[0]["direccion_a"].ToString(); ven.direccionB = dtC.Rows[0]["direccion_b"].ToString(); ven.direccionCliente = dtC.Rows[0]["FC_DCLI"].ToString(); ven.referenciaCliente = dtC.Rows[0]["FC_REFERE"].ToString(); ven.hora = dtC.Rows[0]["FC_HORA"].ToString(); ven.noDocCli = dtC.Rows[0]["FC_RUC"].ToString(); ven.nombreCliente = dtC.Rows[0]["FC_NOMB"].ToString(); ven.apeMatCliente = dtC.Rows[0]["FC_APEM"].ToString(); ven.apePatCliente = dtC.Rows[0]["FC_APEP"].ToString(); ven.nombreCompletoCliente = (dtC.Rows[0]["FC_NOMB"].ToString() + " " + dtC.Rows[0]["FC_APEP"].ToString() + " " + dtC.Rows[0]["FC_APEM"].ToString()).Trim(); ven.tipoComprobante = dtC.Rows[0]["FC_SUNA"].ToString(); ven.fc_nint = dtC.Rows[0]["FC_NINT"].ToString(); ven.idVendedor = dtC.Rows[0]["FC_VEND"].ToString(); ven.nomVendedor = dtC.Rows[0]["V_NOMB"].ToString(); ven.nombreEstado = dtC.Rows[0]["nombreEstado"].ToString(); ven.descripcionEstado = dtC.Rows[0]["descripcionEstado"].ToString(); ven.colorEstado = dtC.Rows[0]["colorEstado"].ToString(); ven.importeTotal = Convert.ToDecimal(dtC.Rows[0]["FC_TOTAL"].ToString()); ven.nombreTipoCV = dtC.Rows[0]["nombre_tipo_cv"].ToString(); ven.cod_entid_b = dtC.Rows[0]["FC_ID_TDACVTA"].ToString(); ven.guia_electronica = dtC.Rows[0]["ge"].ToString(); ven.ubigeoCliente = dtC.Rows[0]["fc_ubi"].ToString(); ven.ubigeoTienda = dtC.Rows[0]["cod_ubigeo"].ToString(); ven.telefonoCliente = dtC.Rows[0]["fc_lcon"].ToString(); List <Ent_DetallesVentaCanal> listVenD = new List <Ent_DetallesVentaCanal>(); foreach (DataRow item in dtD.Rows) { Ent_DetallesVentaCanal venD = new Ent_DetallesVentaCanal(); venD.codigoProducto = item["FD_ARTI"].ToString(); venD.nombreProducto = item["des_artic"].ToString(); venD.precioUnitario = item["FD_PREF"].ToString(); venD.descuento = item["FD_DREF"].ToString(); venD.total = item["FD_TOTAL"].ToString(); venD.cantidad = Convert.ToInt32(Convert.ToDouble(item["FD_QFAC"].ToString())); venD.talla = item["FD_REGL"].ToString(); venD.fd_colo = item["FD_COLO"].ToString(); listVenD.Add(venD); } ven.detalles = listVenD; List <Ent_HistorialEstadosCV> listHist = new List <Ent_HistorialEstadosCV>(); foreach (DataRow item in dtH.Rows) { Ent_HistorialEstadosCV _hist = new Ent_HistorialEstadosCV(); _hist.cod_entid = item["cod_entid"].ToString(); _hist.fc_nint = item["fc_nint"].ToString(); _hist.id_estado = item["id_estado"].ToString(); _hist.fecha = (DateTime)item["fecha"]; _hist.cod_usuario = item["usu_id"].ToString(); _hist.descripcion = item["descripcion"].ToString(); _hist.usu_nombre = item["usu_nombre"].ToString(); _hist.nombreEstado = item["nombreEstado"].ToString(); _hist.colorEstado = item["colorEstado"].ToString(); _hist.descripcionEstado = item["descripcionEstado"].ToString(); _hist.cod_vendedor = item["cod_vendedor"].ToString(); _hist.nomVendedor = item["v_nomb"].ToString(); listHist.Add(_hist); } if (dtIC.Rows.Count > 0) { Ent_Informacion_Tienda_envio ic = new Ent_Informacion_Tienda_envio(); ic.id = Convert.ToInt32(dtIC.Rows[0]["id"]); ic.cod_entid = dtIC.Rows[0]["cod_entid"].ToString(); ic.courier = dtIC.Rows[0]["courier"].ToString(); ic.cx_nroDocProveedor = dtIC.Rows[0]["cx_nroDocProveedor"].ToString(); ic.cx_codTipoDocProveedor = dtIC.Rows[0]["cx_codTipoDocProveedor"].ToString(); ic.cx_codDireccionProveedor = dtIC.Rows[0]["cx_codDireccionProveedor"].ToString(); ic.cx_codCliente = dtIC.Rows[0]["cx_codCliente"].ToString(); ic.cx_codCtaCliente = dtIC.Rows[0]["cx_codCtaCliente"].ToString(); ic.id_usuario = dtIC.Rows[0]["id_usuario"].ToString(); ic.de_terminal = dtIC.Rows[0]["de_terminal"].ToString(); ic.chaski_storeId = dtIC.Rows[0]["chaski_storeId"].ToString(); ic.chaski_branchId = dtIC.Rows[0]["chaski_branchId"].ToString(); ic.chaski_api_key = dtIC.Rows[0]["chaski_api_key"].ToString(); ven.informacionTiendaEnvio = ic; } if (dtID.Rows.Count > 0) { Ent_Informacion_Tienda_Destinatario id = new Ent_Informacion_Tienda_Destinatario(); id.id = Convert.ToInt32(dtID.Rows[0]["id"]); id.nroDocumento = dtID.Rows[0]["nroDocumento"].ToString(); id.email = dtID.Rows[0]["email"].ToString(); id.referencia = dtID.Rows[0]["referencia"].ToString(); id.telefono = dtID.Rows[0]["telefono"].ToString(); id.direccion_entrega = dtID.Rows[0]["direccion_entrega"].ToString(); id.cod_entid = dtID.Rows[0]["cod_entid"].ToString(); ven.informacionTiendaDestinatario = id; } ven.historialEstados = listHist; } } } } catch (Exception ex) { ven = null; } return(ven); }