public List<clsPresupuestoMO> ConsultarPresupuestoMO(int IdPresupuesto) { try { List<clsPresupuestoMO> listapresupuestomo = new List<clsPresupuestoMO>(); TallerEntities ent = new TallerEntities(); var con = from w in ent.PresupuestoxManoObra where w.IdPresupuesto == IdPresupuesto select w; foreach (var item in con) { clsPresupuestoMO e = new clsPresupuestoMO(); e.IdPresupuestoMO = item.IdPresupuestoMO; e.IdPresupuesto = item.IdPresupuesto; e.IdManoObra = item.IdManoObra; e.IdTrabajo = item.IdTrabajo; e.Descripcion = item.ManoObra.TipoTrabajo.Descripcion; e.PrecioHora = item.PrecioHora; e.NroHoras = item.Horas; e.Total = item.Total; listapresupuestomo.Add(e); } return listapresupuestomo; } catch (System.Data.SqlClient.SqlException ex) { Console.WriteLine("Error datPresupuestoMO: " + ex); return null; } }
private void btnBuscarMO_Click(object sender, EventArgs e) { frmConsultarManoObra f = new frmConsultarManoObra(); f.ShowDialog(); oPresupuestoMO = f.pmo; if (oPresupuestoMO.IdManoObra == 0) { gridControl1.DataSource = null; table.Clear(); txtTotalTiempo.Text = ""; txtSubTotal.Text = ""; txtIva.Text = ""; txtTotalPresupuesto.Text = ""; } else { cachesubtotalpresupuesto2 = cachesubtotalpresupuesto; cachesubtotaltiempo2 = cachesubtotaltiempo; DataRow dr = table.NewRow(); if (Convert.ToInt32(colIdPresupuestoMO.SummaryItem.SummaryValue) == 0 || Convert.ToInt32(colIdPresupuestoMO.SummaryItem.SummaryValue) < oDatPresupuesto.getIdSiguientePMO()) { dr[0] = oDatPresupuesto.getIdSiguientePMO(); } else { dr[0] = Convert.ToInt32(colIdPresupuestoMO.SummaryItem.SummaryValue) + 1; } if (txtCodigo.Text == "" || txtCodigo.Text == "0") { dr[1] = oDatPresupuesto.getIdSiguiente(); } else { dr[1] = Convert.ToInt32(txtCodigo.Text); } dr[2] = oPresupuestoMO.IdManoObra; dr[3] = oPresupuestoMO.IdTrabajo; dr[4] = oDatPresupuesto.getDescripcionSegunIdTipoTrabajo(oPresupuestoMO.IdTrabajo); dr[5] = oPresupuestoMO.PrecioHora; dr[6] = oPresupuestoMO.NroHoras; dr[7] = oPresupuestoMO.Total; table.Rows.Add(dr); gridControl1.DataSource = table; txtTotalTiempo.Text = Convert.ToString(cachesubtotaltiempo2 + Convert.ToInt32(colNroHoras.SummaryItem.SummaryValue)); txtSubTotal.Text = Convert.ToString(cachesubtotalpresupuesto2 + Convert.ToDecimal(colTotal.SummaryItem.SummaryValue)); decimal iva = Convert.ToDecimal(txtSubTotal.Text) * Convert.ToDecimal(0.12); txtIva.Text = Convert.ToString(Math.Round(iva, 2)); txtTotalPresupuesto.Text = Convert.ToString(Convert.ToDecimal(txtSubTotal.Text) + Convert.ToDecimal(txtIva.Text)); } }