protected void UpdateVariablesPieza_Click(object sender, EventArgs e) { bool s1 = false; bool s2 = false; double aNCHO; if (double.TryParse(TxtAnchoPiezaSelected.Text, out aNCHO)) { Update("COT_ENDOSUBDET", "IDSUBDET", HdnIDSUBDET.Value, "ANCHO", aNCHO, false); s1 = true; } double aLTO; if (double.TryParse(TxtAltoPiezaSelected.Text, out aLTO)) { Update("COT_ENDOSUBDET", "IDSUBDET", HdnIDSUBDET.Value, "ALTO", aLTO, false); s2 = true; } if (s1 && s2) { SubDetalleCotizacion.GetItem item = new SubDetalleCotizacion.GetItem(HdnIDSUBDET.Value, true); SubDetalleCotizacion.Get Subdet = new SubDetalleCotizacion.Get(item.Datos.NODE, IDENDO, IDENDODET, true); SubDetalleCotizacion.CalcularPieza Calculos = new SubDetalleCotizacion.CalcularPieza(Subdet.SubDetalle, aNCHO, aLTO, "DISTRIBUCIÓN"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myalert", "alert('Información actualizada.'); window.location='" + Page.ResolveUrl("~/View/Distribuidor/Cotizador/Form-Item.aspx?NAME=" + NOMBRE + "&IDENDODET=" + IDENDODET + "&IDENDO=" + IDENDO + "&TOKEN=" + TOKEN) + "';", true); } }
protected bool ValidarIngreso() { bool IsValid = false; if (!string.IsNullOrEmpty(IDENDODET) || !string.IsNullOrEmpty(IDENDO) || !string.IsNullOrEmpty(TOKEN)) { Cot = new Cotizacion.GetRowInfo(IDENDO, TOKEN, true); if (Cot.HasRow) { DetalleCotizacion.GetItem ITEM = new DetalleCotizacion.GetItem(IDENDODET, true); if (ITEM.IsGetting) { if (!IsPostBack) { FillInformation(ITEM.Item); } SubDetalleCotizacion.Get get = new SubDetalleCotizacion.Get(1, IDENDO, IDENDODET, true); if (get.HasDetail) { FilltablaPiezas(get.SubDetalle); } IsValid = true; } } else { IsValid = false; } } else { IsValid = false; } return(IsValid); }
public byte[] ExcelGenerado() { Cotizacion.GetRowInfo Cot = new Cotizacion.GetRowInfo(IDENDO, TOKEN, ESTADO); using (var XlsPack = new ExcelPackage()) { XlsPack.Workbook.Properties.Author = "Glasser"; XlsPack.Workbook.Properties.Title = "Presupuesto N°" + Cot.Correlativo + " " + Cot.CLIENTEDOC; var hoja1 = XlsPack.Workbook.Worksheets.Add("Formulario"); hoja1.Name = "Presupuesto"; hoja1.PrinterSettings.PaperSize = ePaperSize.Letter; hoja1.Column(1).Width = 4.5; border = hoja1.Cells.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.None; #region Report Header hoja1.Row(3).Height = 32; hoja1.Column(2).Width = 2; hoja1.Column(8).Width = 2.5; hoja1.Column(9).Width = 2.5; cell = hoja1.Cells[3, 1, 3, 12]; cell.Merge = true; cell.Value = "Presupuesto N°" + Cot.Correlativo + " " + Cot.CLIENTEDOC; cell.Style.Font.Bold = true; cell.Style.Font.Size = 18; cell.Style.VerticalAlignment = ExcelVerticalAlignment.Center; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; border = cell.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin; #endregion DetalleCotizacion.Get Detalle = new DetalleCotizacion.Get(IDENDO, ESTADO); int row = 6; #region Report Detail foreach (DetalleCotizacion item in Detalle.Detalle) { /*Nro de item*/ cell = hoja1.Cells[row, 1]; cell.Value = Convert.ToInt32(item.POS_NR); /*nombre*/ cell = hoja1.Cells[row, 3, row, 10]; cell.Merge = true; cell.Value = item.NOMBRE; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; /*descripcion*/ cell = hoja1.Cells[row + 1, 3, row + 2, 7]; cell.Merge = true; cell.Style.WrapText = true; cell.Value = item.OBSERVACION; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; /*imagen*/ AddImage(hoja1, row + 1, 9, item.IMAGEN, item.NOMBRE); row = row + 3; /*lista de piezas*/ SubDetalleCotizacion.Get get = new SubDetalleCotizacion.Get(1, IDENDO, item.IDENDODET, true); if (get.HasDetail) { /*encabezado piezas*/ /*--pieza--*/ cell = hoja1.Cells[row, 4, row, 5]; cell.Merge = true; cell.Value = "Pieza"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; border = cell.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin; /*--Ancho--*/ cell = hoja1.Cells[row, 6]; cell.Value = "Ancho"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; border = cell.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin; /*--Alto--*/ cell = hoja1.Cells[row, 7]; cell.Value = "Alto"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; border = cell.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin; row++; foreach (SubDetalleCotizacion Sub in get.SubDetalle) { /*pieza*/ cell = hoja1.Cells[row, 4, row, 5]; cell.Merge = true; cell.Value = Sub.NOMBRE; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; border = cell.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin; /*ancho*/ cell = hoja1.Cells[row, 6]; cell.Value = Sub.ANCHO; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right; border = cell.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin; /*alto*/ cell = hoja1.Cells[row, 7]; cell.Value = Sub.ALTO; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right; border = cell.Style.Border; border.Bottom.Style = border.Top.Style = border.Left.Style = border.Right.Style = ExcelBorderStyle.Thin; row++; } } row++; /*Precio Unitario*/ cell = hoja1.Cells[row, 4, row, 5]; cell.Merge = true; cell.Value = "Precio Un. Neto:"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right; cell = hoja1.Cells[row, 6, row, 7]; cell.Merge = true; cell.Value = item.NETOUN; cell.Style.Numberformat.Format = "$#,##0"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; row++; /*Cantidad*/ cell = hoja1.Cells[row, 4, row, 5]; cell.Merge = true; cell.Value = "Cantidad:"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right; cell = hoja1.Cells[row, 6, row, 7]; cell.Merge = true; cell.Value = item.CANTIDAD; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; row++; row++; /*Total*/ cell = hoja1.Cells[row, 4, row, 5]; cell.Merge = true; cell.Value = "Neto Total:"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right; cell = hoja1.Cells[row, 6, row, 7]; cell.Merge = true; cell.Value = item.NETO; cell.Style.Numberformat.Format = "$#,##0"; cell.Style.Font.Bold = true; cell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; row = row + 6; } #endregion #region Report footer #endregion return(XlsPack.GetAsByteArray()); } }