protected void btnregistrar_Click(object sender, EventArgs e) { TablaPDF = Tabla; if (griddetallefactura.Columns.Count > 0) { Label1.Visible = false; double total = 0; double subtotal = 0; string idorden; for (int i = 0; i < griddetallefactura.Rows.Count; i++) { subtotal = Convert.ToDouble(Tabla.Rows[i][4]); total = total + subtotal; } if (griddetallefactura.Rows.Count > 0) { try { if ((String)Session["Usuario"] != null) { Label1.Visible = false; TheGym k = new TheGym { emailbusadm = (String)Session["Usuario"], }; DataTable dt = new DataTable(); dt = k.GetIDemp(); if (dt.Rows.Count > 0) { k.fkempleadoorden = dt.Rows[0][0].ToString(); k.fkproveedororden = id; k.fechaorden = lblFecha.Text; k.horaorden = lblhora.Text; k.totalorden = Convert.ToString(total); DataTable dt1 = new DataTable(); dt1 = k.AddOrdenCompra(); idorden = dt1.Rows[0][0].ToString(); for (int i = 0; i < griddetallefactura.Rows.Count; i++) { k.fkorden = idorden; k.fkproducto = Tabla.Rows[i][0].ToString(); k.cantidadorden = Tabla.Rows[i][2].ToString(); k.precioorden = Tabla.Rows[i][3].ToString(); k.AddDetOrden(); /////// } } else { Label1.Text = "Orden de Compra Registrada"; Label1.Visible = true; } } else { TheGym k = new TheGym(); k.fkempleadoorden = "1"; k.fkproveedororden = id; k.fechaorden = lblFecha.Text; k.horaorden = lblhora.Text; k.totalorden = Convert.ToString(total); DataTable dt1 = new DataTable(); dt1 = k.AddOrdenCompra(); idorden = dt1.Rows[0][0].ToString(); for (int i = 0; i < griddetallefactura.Rows.Count; i++) { k.fkorden = idorden; k.fkproducto = Tabla.Rows[i][0].ToString(); k.cantidadorden = Tabla.Rows[i][2].ToString(); k.precioorden = Tabla.Rows[i][3].ToString(); k.AddDetOrden(); } ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-compraregistrada').modal('show');", true); //btnregistrar.Visible = false; //btncancelar.Visible = false; } //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-default').modal('show');", true); //btnPDF.Visible = true; //btnPDF.Enabled = true; //panelseleccionarproveedor.Visible = true; //panelregistrarorden.Visible = false; //DataTable dtaux = new DataTable(); //griddetallefactura.DataSource = dtaux; //griddetallefactura.DataBind(); //griddetallefactura.Dispose(); //griddetallefactura.Visible = false; //griddetallefactura.DataSource = dtaux; //griddetallefactura.DataBind(); //griddetallefactura.Dispose(); //griddetallefactura.Visible = false; //Tabla.Rows.Clear(); //gvproductos.DataSource = dtaux; //gvproductos.DataBind(); //gvproductos.Dispose(); //gvproductos.Visible = false; //tbcantidad.Text = ""; //tbcantidad.Enabled = false; //tbcantidad.Text = ""; //lblempleado.Text = ""; //lblhora.Text = ""; //tbproveedor.Text = ""; //lblFecha.Text = ""; //tbnombreproveedor.Text = ""; //lblerror.Text = ""; //tbnombreproductos.Text = ""; Lblerror1.Text = ""; lblerror.Visible = false; lblerror.Visible = false; Lblerror1.Visible = false; //btnregistrar.Enabled = false; //btncancelar.Enabled = false; generarPDF.Visible = true; } catch (Exception ex) { //Label1.Visible = true; //Label1.Text = ex.Message.ToString()+"a"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#modal-compraregistrada').modal('show');", true); } } else { Label1.Text = "Agregar productos a la Orden"; Label1.Visible = true; } } }