protected void dgvSubtotal_RowComand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Cotizar") { E_Cotizacion objE_Cot = new E_Cotizacion(); D_Cotizacion objD_Cot = new D_Cotizacion(); C_Cotizacion objC_Cot = new C_Cotizacion(); double preTotal = Convert.ToDouble(dgvSubtotal.DataKeys[Convert.ToInt32(e.CommandArgument)].Values["SubTotal"].ToString()); double desc = Convert.ToDouble(txtDescuento.Text); string nom = txtNombreCot.Text; objE_Cot.PreTotal1 = preTotal; objE_Cot.Descuento1 = Convert.ToDouble(txtDescuento.Text.Trim()); objE_Cot.Total1 = (preTotal - (preTotal * (Convert.ToDouble(txtDescuento.Text.Trim()) / 100))); objE_Cot.NombreCotizacion1 = txtNombreCot.Text.Trim(); if (desc.ToString() == null) { throw new Exception("Ingrese el descuento"); } if (desc <= 0) { throw new Exception("El descuento debe ser mayor a cero."); } if (txtNombreCot.Text == "") { throw new Exception("Ingrese un nombre a la cotización"); } camposCot(); objC_Cot.insertarCotizacion(objE_Cot); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "Notificacion('Ok','Se registró correctamente la cotización','success')", true); } else if (e.CommandName == "Finalizar") { D_Cotizacion objD_Cot = new D_Cotizacion(); D_Pedido objD_Ped = new D_Pedido(); E_Pedido objE_Ped = new E_Pedido(); String idPedido = (Session["pedido"] == null) ? null : Session["pedido"].ToString(); objE_Ped.IdPedido1 = Convert.ToInt32(Session["pedido"]); objD_Ped.actualizarPedido(objE_Ped); dgvTotal.DataSource = objD_Cot.TotalCotizar(); dgvTotal.DataBind(); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "Notificacion('Ok','Se finalizó la cotización.','success')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "Notificacion('Error','" + ex.Message + "','error')", true); } }
public void insertarCotizacion(E_Cotizacion objE_Cot) { SqlCommand unCommand = new SqlCommand("SP_InsertarCotizacion", conexion); unCommand.CommandType = CommandType.StoredProcedure; unCommand.Parameters.AddWithValue("@PreTotal", objE_Cot.PreTotal1); unCommand.Parameters.AddWithValue("@Descuento", objE_Cot.Descuento1); unCommand.Parameters.AddWithValue("@Total", objE_Cot.Total1); unCommand.Parameters.AddWithValue("@NombreCotizacion", objE_Cot.NombreCotizacion1); conexion.Open(); unCommand.ExecuteNonQuery(); conexion.Close(); }
public void insertarCotizacion(E_Cotizacion objE_Cot) { objD_Cot.insertarCotizacion(objE_Cot); }