Documente Academic
Documente Profesional
Documente Cultură
WITH Consulta ( Nombre, OdtId, Revision, Fecha, DisciplinaId, Valor, TotalPI, Cargadas ) AS ( SELECT Disciplina_1.Nombre, ProyeccionCargaOdt.OdtId, ProyeccionCarg aOdt.Revision, ProyeccionCargaOdt.Fecha, ProyeccionCargaOdt.DisciplinaId, ProyeccionCargaOdt.Valor, (SELECT SUM(PresupuestoInterno.TotalIng + Pr esupuestoInterno.TotalTec) AS PI FROM PresupuestoInterno INNER JOIN Disciplina ON Presupues toInterno.DisciplinaID = Disciplina.DisciplinaID WHERE (PresupuestoInterno.OdtID = Proyecci onCargaOdt.OdtId) AND (PresupuestoInterno.DisciplinaID = ProyeccionCargaOdt.Disc iplinaId) GROUP BY Disciplina.DisciplinaID, Disciplina.Nomb re) AS TotalPI, (SELECT ISNULL(SUM(HorasDia), 0) AS TotaHora s FROM HojaTiempoDetalles WHERE (OdtID = ProyeccionCargaOdt.OdtId) A ND (DisciplinaID = Disciplina_1.DisciplinaID)) AS Cargadas FROM ProyeccionCargaOdt INNER JOIN Disciplina AS Disciplina_1 ON ProyeccionCargaOdt.Discip linaId = Disciplina_1.DisciplinaID WHERE (ProyeccionCargaOdt.DisciplinaId = @DisciplinaId) AND (ProyeccionCa rgaOdt.Revision IN (SELECT TOP (100) PERCENT COUNT(*) AS Revisiones FROM ProyeccionRevOdt GROUP BY OdtId HAVING (COUNT(*) > 0) ORDER BY OdtId DESC)) )
// Final SELECT Disciplina_1.Nombre, ProyeccionCargaOdt.OdtId, ProyeccionCargaOdt. Revision, ProyeccionCargaOdt.Fecha, ProyeccionCargaOdt.DisciplinaId, ProyeccionCargaOdt.Valor, (SELECT SUM(PresupuestoInterno.TotalIng + Pr esupuestoInterno.TotalTec) AS PI FROM PresupuestoInterno INNER JOIN Disciplina ON Presupues toInterno.DisciplinaID = Disciplina.DisciplinaID WHERE (PresupuestoInterno.OdtID = Proyecci onCargaOdt.OdtId) AND (PresupuestoInterno.DisciplinaID = ProyeccionCargaOdt.Disc iplinaId) GROUP BY Disciplina.DisciplinaID, Disciplina.Nomb re) AS TotalPI, (SELECT ISNULL(SUM(HorasDia), 0) AS TotaHora s FROM HojaTiempoDetalles WHERE (OdtID = ProyeccionCargaOdt.OdtId) A ND (DisciplinaID = Disciplina_1.DisciplinaID)) AS Cargadas FROM ProyeccionCargaOdt INNER JOIN Disciplina AS Disciplina_1 ON ProyeccionCargaOdt.Discip linaId = Disciplina_1.DisciplinaID WHERE (ProyeccionCargaOdt.DisciplinaId = @DisciplinaId) AND (ProyeccionCa rgaOdt.Revision IN (SELECT TOP (100) PERCENT COUNT(*) AS Revisi ones FROM ProyeccionRevOdt GROUP BY OdtId HAVING (COUNT(*) > 0) ORDER BY OdtId DESC)) // ***** SELECT FROM OdtId, Revision, Observacion ProyeccionRevOdt
SELECT OdtId, COUNT(*) AS Revisiones FROM ProyeccionRevOdt GROUP BY OdtId HAVING (COUNT(*) > 0) ORDER BY OdtId DESC //** tiene un error SELECT TOP (1) ProyeccionRevOdt.Revision FROM Odt INNER JOIN ProyeccionRevOdt ON Odt.OdtID = ProyeccionRevOdt.OdtId WHERE (ProyeccionRevOdt.OdtId = (SELECT OdtId FROM ProyeccionCargaOdt GROUP BY OdtId)) GROUP BY ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision ORDER BY ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision DESC //***** SELECT TOP (1) ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision
FROM
Odt INNER JOIN ProyeccionRevOdt ON Odt.OdtID = ProyeccionRevOdt.OdtId WHERE (ProyeccionRevOdt.OdtId = '2510009') GROUP BY ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision ORDER BY ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision DESC SELECT FROM ProyeccionRevOdt.Revision, ProyeccionRevOdt.OdtId Odt INNER JOIN ProyeccionRevOdt ON Odt.OdtID = ProyeccionRevOdt.OdtId GROUP BY ProyeccionRevOdt.Revision, ProyeccionRevOdt.OdtId ORDER BY ProyeccionRevOdt.Revision, ProyeccionRevOdt.OdtId DESC SELECT DISTINCT ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision FROM Odt INNER JOIN ProyeccionRevOdt ON Odt.OdtID = ProyeccionRevOdt.OdtId GROUP BY ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision ORDER BY ProyeccionRevOdt.OdtId, ProyeccionRevOdt.Revision DESC SELECT DISTINCT O.OdtID, P.Revision FROM Odt AS O CROSS JOIN ProyeccionRevOdt AS P GROUP BY O.OdtID, P.Revision ORDER BY P.Revision DESC http://www.codeproject.com/KB/system/SCSI.aspx
// Disciplinas que estan involucradas en un proyecto. SELECT Disciplina.DisciplinaID, Disciplina.Nombre FROM Disciplina INNER JOIN PresupuestoInterno ON Disciplina.DisciplinaID = Presupu estoInterno.DisciplinaID WHERE (PresupuestoInterno.OdtID = '2510002') GROUP BY Disciplina.DisciplinaID, Disciplina.Nombre private void odtEmpresaBindingNavigatorSaveItem_Click(object sender, Even tArgs e) { this.Validate(); this.odtEmpresaBindingSource.EndEdit(); this.odtEmpresaTableAdapter.Update(this.tablasGenerales.OdtEmpresa); } private void Empresas_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'tablasGenerales.OdtE mpresa' table. You can move, or remove it, as needed. this.odtEmpresaTableAdapter.Fill(this.tablasGenerales.OdtEmpresa); } // Asigna el numero de la ODT al campo oculto OdtId para que se guarde. // los campos claves de la tabla son: OdtId y Revision. private void gridView1_InitNewRow(object sender, DevExpress.XtraGrid.Vie ws.Grid.InitNewRowEventArgs e)
{ DevExpress.XtraGrid.Views.Grid.GridView vista = sender as DevExpress .XtraGrid.Views.Grid.GridView; vista.SetRowCellValue(e.RowHandle, vista.Columns["OdtId"], odtid); } Data Source=14.0.1.52;Initial Catalog=SicProDotNet;Persist Security Info=True;Us er ID=sa Data Source=14.0.1.52;Initial Catalog=BDT;User ID=sa;Password=adminsaingesoft /** insertar.Parameters.Clear(); p = new System.Data.SqlClient.SqlParameter("@OdtId", fila[0] .ToString()); insertar.Parameters.Add(p); p = new System.Data.SqlClient.SqlParameter("@Revision", fila [1].ToString()); insertar.Parameters.Add(p); p = new System.Data.SqlClient.SqlParameter("@Fecha", fila[2] .ToString()); insertar.Parameters.Add(p); p = new System.Data.SqlClient.SqlParameter("@DisciplinaId", fila[DISCI].ToString()); insertar.Parameters.Add(p); p = new System.Data.SqlClient.SqlParameter("@Valor", fila[VA LOR].ToString()); insertar.Parameters.Add(p); **/ SELECT FROM WHERE OdtID,Titulo, Estatus, Facturable Odt (Estatus = 'Abierto') AND (Facturable = 1)
// Revision SELECT OdtId, Revision, Observacion FROM ProyeccionRevOdt WHERE (OdtId = @OdtId)
private void AceptarButton_Click(object sender, EventArgs e) { //Step 1 : Instantiate the spreadsheet creation engine. ExcelEngine excelEngine = new ExcelEngine(); //Step 2 : Instantiate the excel application object. IApplication application = excelEngine.Excel; application.UseNativeStorage = false; IWorkbook workbook = application.Workbooks.Open(@"PlantillaMatrizRes ponsabilidad.xlt"); IWorksheet sheet = workbook.Worksheets[0]; // --------------------------------------------------------------------------------------------------// Logica // -----------------------------------------------------------------
----------------------------------string _Archivo = "MatrizResponsabilidad-" + Archivo + ".xls"; workbook.SaveAs("MatrizResponsabilidad-" + Archivo + ".xls"); if (MessageBox.Show("Desea Abrir el Archivo?", "Abrir...", MessageBo xButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { System.Diagnostics.Process process = new System.Diagnostics. Process(); process.StartInfo.FileName = _Archivo; process.StartInfo.Verb = "Open"; process.StartInfo.WindowStyle = System.Diagnostics.ProcessWi ndowStyle.Normal; process.Start(); } catch { MessageBox.Show(this, "Cannot find an application on your sy stem suitable for openning the file with exported data.", Application.ProductNam e, MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Close the workbook. workbook.Close(); //No exception will be thrown if there are unsaved workbooks. excelEngine.ThrowNotSavedOnDestroy = false; excelEngine.Dispose(); } SELECT Disciplina.DisciplinaID, Disciplina.Nombre, SUM(PresupuestoInterno .TotalIng + PresupuestoInterno.TotalTec) AS PI FROM PresupuestoInterno INNER JOIN Disciplina ON PresupuestoInterno.DisciplinaID = Discipl ina.DisciplinaID WHERE (PresupuestoInterno.OdtID = '2P10002') GROUP BY Disciplina.DisciplinaID, Disciplina.Nombre SELECT FROM WHERE // Final a SELECT OdtId, Revision, Fecha, DisciplinaId, Valor ProyeccionCargaOdt (OdtId = '2P10002') AND (Revision = 1) AND (DisciplinaId = '5')
OdtId, Revision, Fecha, DisciplinaId, Valor, (SELECT SUM(PresupuestoInterno.TotalIng + Pr esupuestoInterno.TotalTec) AS PI FROM PresupuestoInterno INNER JOIN Disciplina ON Presupues toInterno.DisciplinaID = Disciplina.DisciplinaID WHERE (PresupuestoInterno.OdtID = '2P10002 ') AND (PresupuestoInterno.DisciplinaID = ProyeccionCargaOdt.DisciplinaId)
GROUP BY Disciplina.DisciplinaID, Disciplina.Nomb re) AS HHPI FROM ProyeccionCargaOdt WHERE (OdtId = '2P10002') AND (Revision = 0) AND (DisciplinaId = '5') // Final b SELECT
OdtId, Revision, Fecha, DisciplinaId, Valor, (SELECT SUM(PresupuestoInterno.TotalIng + Pr esupuestoInterno.TotalTec) AS PI FROM PresupuestoInterno INNER JOIN Disciplina ON Presupues toInterno.DisciplinaID = Disciplina.DisciplinaID WHERE (PresupuestoInterno.OdtID = '2P10002 ') AND (PresupuestoInterno.DisciplinaID = ProyeccionCargaOdt.DisciplinaId) GROUP BY Disciplina.DisciplinaID, Disciplina.Nomb re) AS HHPI FROM ProyeccionCargaOdt WHERE (OdtId = '2P10002') AND (Revision = 1) ORDER BY DisciplinaId, Fecha 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 2P10002 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 01/03/2011 02/03/2011 05/03/2011 06/03/2011 07/03/2011 08/03/2011 11/03/2011 01/03/2011 02/03/2011 05/03/2011 06/03/2011 07/03/2011 08/03/2011 11/03/2011 01/03/2011 02/03/2011 05/03/2011 06/03/2011 07/03/2011 08/03/2011 11/03/2011 01/03/2011 02/03/2011 05/03/2011 06/03/2011 07/03/2011 08/03/2011 11/03/2011 01/03/2011 02/03/2011 05/03/2011 06/03/2011 07/03/2011 08/03/2011 11/03/2011 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 0:00:00 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 5 5 5 2 20 1 0 0 1 32 2 30 1 0 0 1 50 2 40 1 0 0 1 32 2 50 1 0 0 1 43 2 60 11 0 0 1 1