public void carga_grilla_General(int region, int zona, int localidad, int contratista, int instalador) { OracleConnection CnOra = new OracleConnection(conexion_cliente_oracle); OracleDataAdapter da; DataSet objDS = new DataSet(); CnOra.Open(); da = new OracleDataAdapter("PK_SUSTITUCION_MEDIDOR.CARGAR_ORDENES", CnOra); da.SelectCommand.CommandType = CommandType.StoredProcedure; PRO.agrega_parametro_sp(da, "o_cursor", OracleType.Cursor, ParameterDirection.Output, ""); PRO.agrega_parametro_sp(da, "i_region", OracleType.Int32, ParameterDirection.Input, region.ToString()); PRO.agrega_parametro_sp(da, "i_zona", OracleType.Int32, ParameterDirection.Input, zona.ToString()); PRO.agrega_parametro_sp(da, "i_localidad", OracleType.Int32, ParameterDirection.Input, localidad.ToString()); PRO.agrega_parametro_sp(da, "i_instalador", OracleType.Int32, ParameterDirection.Input, instalador.ToString()); PRO.agrega_parametro_sp(da, "i_contratista", OracleType.Int32, ParameterDirection.Input, contratista.ToString()); da.SelectCommand.CommandType = CommandType.StoredProcedure; DataTable dtOrdenes = new DataTable(); try { da.Fill(dtOrdenes); CnOra.Close(); CnOra.Dispose(); } catch (Exception ex) { //lbErrorGrilla.Text = ex.ToString() + servicio; //lbErrorGrilla.ForeColor = System.Drawing.Color.Red; //lbErrorGrilla.Text = ex.ToString() + numero_orden; //lbErrorGrilla.ForeColor = System.Drawing.Color.Red; //lbErrorGrilla.Text = desde + "***" + hasta; } DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("NUMERO_ORDEN", typeof(String))); dt.Columns.Add(new DataColumn("FECHA_CREACION", typeof(String))); // dt.Columns.Add(new DataColumn("ID_SERVICIO", typeof(String))); dt.Columns.Add(new DataColumn("NOMBRE_CONTRATISTA", typeof(String))); dt.Columns.Add(new DataColumn("RUTA", typeof(String))); dt.Columns.Add(new DataColumn("LOCALIDAD", typeof(String))); dt.Columns.Add(new DataColumn("CLIENTE", typeof(String))); dt.Columns.Add(new DataColumn("DIRECCION", typeof(String))); dt.Columns.Add(new DataColumn("NOMBRE_INSTALADOR", typeof(String))); dt.Columns.Add(new DataColumn("CAUSA_CAMBIO", typeof(String))); DataRow dr; int total = 0; foreach (DataRow drOrdenItem in dtOrdenes.Rows) { dr = dt.NewRow(); dr["NUMERO_ORDEN"] = drOrdenItem["NUMERO_ORDEN"].ToString(); dr["FECHA_CREACION"] = drOrdenItem["FECHA_CREACION"].ToString().Replace("00:00:00", ""); dr["ID_SERVICIO"] = drOrdenItem["ID_SERVICIO"].ToString();// dr["NOMBRE_CONTRATISTA"] = drOrdenItem["NOMBRE_CONTRATISTA"].ToString(); dr["RUTA"] = drOrdenItem["RUTA"].ToString(); dr["LOCALIDAD"] = drOrdenItem["LOCALIDAD"].ToString(); dr["CLIENTE"] = drOrdenItem["CLIENTE"].ToString(); dr["DIRECCION"] = drOrdenItem["DIRECCION"].ToString(); dr["NOMBRE_INSTALADOR"] = drOrdenItem["NOMBRE_INSTALADOR"].ToString(); dr["CAUSA_CAMBIO"] = drOrdenItem["CAUSA_CAMBIO"].ToString(); dt.Rows.Add(dr); total = total + 1; } DataView MydataView; MydataView = new DataView(dt); GridOrden.DataSource = MydataView; GridOrden.DataBind(); lb_mje.Visible = true; lb_mje.ForeColor = Color.Black; lb_mje.Text = "SE HAN ENCONTRADO: " + total + " REGISTROS "; }
public void cargarGrilla2(int numOrden, int EstadoImpresa) { DataTable dt = new DataTable(); string queryFiltro = ""; Boolean marca; marca = false; OracleCommand cmd = new OracleCommand(); OracleConnection objConexion = new OracleConnection(conexion_cliente_oracle); OracleDataAdapter adapter = new OracleDataAdapter(cmd); DataSet ds = new DataSet(); if (numOrden == 0 && EstadoImpresa == 0) { ddlEstadoOrd.SelectedIndex = 0; ddlEstadoImp.SelectedIndex = 0; } dt.Columns.AddRange(new DataColumn[1] { new DataColumn("NUMERO_ORDEN") }); foreach (GridViewRow row in GrdInstalador.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox chkRow = (row.Cells[0].FindControl("check_impr1") as CheckBox); if (chkRow.Checked) { numeroOrd = row.Cells[0].Text; dt.Rows.Add(numeroOrd); } } } GridSeloper.DataSource = dt; GridSeloper.DataBind(); foreach (GridViewRow row in GridSeloper.Rows) { if (GridSeloper.Rows.Count > 1) { if (marca == false) { queryFiltro = queryFiltro + "" + row.Cells[0].Text; marca = true; } else { queryFiltro = queryFiltro + "," + row.Cells[0].Text; } } else if (GridSeloper.Rows.Count == 1) { queryFiltro = queryFiltro + row.Cells[0].Text; } } if (numOrden >= 1) { if (numOrden == 1) { string Sql1 = ""; Sql1 = Sql1 + "select O.NUMERO_ORDEN,O.FECHA_CREACION,O.ID_SERVICIO, "; Sql1 = Sql1 + "O.RUTA,O.LOCALIDAD,O.CLIENTE,O.DIRECCION,O.COD_INSTALADOR,EO.DESCRIPCION "; Sql1 = Sql1 + "from ORDEN O "; Sql1 = Sql1 + "LEFT JOIN ESTATUS_ORDEN EO ON EO.COD_ESTATUS_ORDEN=O.COD_IMPROCEDENCIA "; Sql1 = Sql1 + "WHERE O.COD_INSTALADOR in (" + queryFiltro + ") and O.ID_SINCRONIZACION in(4) ORDER BY O.RUTA"; objConexion.Open(); cmd.Connection = objConexion; cmd.CommandText = Sql1; cmd.CommandType = CommandType.Text; //OracleDataReader dr = cmd.ExecuteReader(); adapter.SelectCommand.ExecuteNonQuery(); adapter.Fill(ds, "Table"); GridOrden.DataSource = ds.Tables["Table"]; GridOrden.DataBind(); objConexion.Close(); } if (numOrden == 2) { string Sql2 = ""; Sql2 = Sql2 + "select O.NUMERO_ORDEN,O.FECHA_CREACION,O.ID_SERVICIO, "; Sql2 = Sql2 + "O.RUTA,O.LOCALIDAD,O.CLIENTE,O.DIRECCION,O.COD_INSTALADOR,EO.DESCRIPCION "; Sql2 = Sql2 + "from ORDEN O "; Sql2 = Sql2 + "LEFT JOIN ESTATUS_ORDEN EO ON EO.COD_ESTATUS_ORDEN=O.COD_IMPROCEDENCIA "; Sql2 = Sql2 + "WHERE O.COD_INSTALADOR in (" + queryFiltro + ") and O.ID_SINCRONIZACION in(1) ORDER BY O.RUTA"; objConexion.Open(); cmd.Connection = objConexion; cmd.CommandText = Sql2; cmd.CommandType = CommandType.Text; //OracleDataReader dr = cmd.ExecuteReader(); adapter.SelectCommand.ExecuteNonQuery(); adapter.Fill(ds, "Table"); GridOrden.DataSource = ds.Tables["Table"]; GridOrden.DataBind(); objConexion.Close(); } if (numOrden == 3) { string Sql3 = ""; Sql3 = Sql3 + "select O.NUMERO_ORDEN,O.FECHA_CREACION,O.ID_SERVICIO, "; Sql3 = Sql3 + "O.RUTA,O.LOCALIDAD,O.CLIENTE,O.DIRECCION,O.COD_INSTALADOR,EO.DESCRIPCION "; Sql3 = Sql3 + "from ORDEN O "; Sql3 = Sql3 + "LEFT JOIN ESTATUS_ORDEN EO ON EO.COD_ESTATUS_ORDEN=O.COD_IMPROCEDENCIA "; Sql3 = Sql3 + "WHERE O.COD_INSTALADOR in (" + queryFiltro + ") and O.ID_SINCRONIZACION in(3) ORDER BY O.RUTA"; objConexion.Open(); cmd.Connection = objConexion; cmd.CommandText = Sql3; cmd.CommandType = CommandType.Text; //OracleDataReader dr = cmd.ExecuteReader(); adapter.SelectCommand.ExecuteNonQuery(); adapter.Fill(ds, "Table"); GridOrden.DataSource = ds.Tables["Table"]; GridOrden.DataBind(); objConexion.Close(); } } if (EstadoImpresa >= 1) { if (EstadoImpresa == 1) { string Sql4 = ""; Sql4 = Sql4 + "select O.NUMERO_ORDEN,O.FECHA_CREACION,O.ID_SERVICIO, "; Sql4 = Sql4 + "O.RUTA,O.LOCALIDAD,O.CLIENTE,O.DIRECCION,O.COD_INSTALADOR,EO.DESCRIPCION "; Sql4 = Sql4 + "from ORDEN O "; Sql4 = Sql4 + "LEFT JOIN ESTATUS_ORDEN EO ON EO.COD_ESTATUS_ORDEN=O.COD_IMPROCEDENCIA "; Sql4 = Sql4 + "WHERE O.COD_INSTALADOR in (" + queryFiltro + ") and O.ID_SINCRONIZACION in(3,4) ORDER BY O.RUTA"; objConexion.Open(); cmd.Connection = objConexion; cmd.CommandText = Sql4; cmd.CommandType = CommandType.Text; //OracleDataReader dr = cmd.ExecuteReader(); adapter.SelectCommand.ExecuteNonQuery(); objConexion.Close(); adapter.Fill(ds, "Table"); GridOrden.DataSource = ds.Tables["Table"]; GridOrden.DataBind(); objConexion.Close(); } if (EstadoImpresa == 2) { string Sql5 = ""; Sql5 = Sql5 + "select O.NUMERO_ORDEN,O.FECHA_CREACION,O.ID_SERVICIO, "; Sql5 = Sql5 + "O.RUTA,O.LOCALIDAD,O.CLIENTE,O.DIRECCION,O.COD_INSTALADOR,EO.DESCRIPCION "; Sql5 = Sql5 + "from ORDEN O "; Sql5 = Sql5 + "LEFT JOIN ESTATUS_ORDEN EO ON EO.COD_ESTATUS_ORDEN=O.COD_IMPROCEDENCIA "; Sql5 = Sql5 + "WHERE O.COD_INSTALADOR in (" + queryFiltro + ") and O.visita>1 ORDER BY O.RUTA"; objConexion.Open(); cmd.Connection = objConexion; cmd.CommandText = Sql5; cmd.CommandType = CommandType.Text; //OracleDataReader dr = cmd.ExecuteReader(); adapter.SelectCommand.ExecuteNonQuery(); adapter.Fill(ds, "Table"); GridOrden.DataSource = ds.Tables["Table"]; GridOrden.DataBind(); objConexion.Close(); } } else if (numOrden == 0 && EstadoImpresa == 0) { string Sql6 = ""; Sql6 = Sql6 + "select O.NUMERO_ORDEN,O.FECHA_CREACION,O.ID_SERVICIO, "; Sql6 = Sql6 + "O.RUTA,O.LOCALIDAD,O.CLIENTE,O.DIRECCION,O.COD_INSTALADOR,EO.DESCRIPCION "; Sql6 = Sql6 + "from ORDEN O "; Sql6 = Sql6 + "LEFT JOIN ESTATUS_ORDEN EO ON EO.COD_ESTATUS_ORDEN=O.COD_IMPROCEDENCIA "; Sql6 = Sql6 + "WHERE O.COD_INSTALADOR in (" + queryFiltro + ") and O.ID_SINCRONIZACION in(3,4) ORDER BY O.RUTA"; objConexion.Open(); cmd.Connection = objConexion; cmd.CommandText = Sql6; cmd.CommandType = CommandType.Text; //OracleDataReader dr = cmd.ExecuteReader(); adapter.SelectCommand.ExecuteNonQuery(); adapter.Fill(ds, "Table"); GridOrden.DataSource = ds.Tables["Table"]; GridOrden.DataBind(); objConexion.Close(); } }