Example #1
0
    protected void btncalcular_Click(object sender, EventArgs e)
    {
        if (txtcantidad.Text == "")
        {
            Utils.AddScriptClientUpdatePanel(updBotonEnviar, "showSuccessMessage6()");
        }
        //gvdetalle
        try
        {
            var colsNoVisible = gvdetalle.DataKeys[0].Values;

            int    IM_Stock    = int.Parse(colsNoVisible[4].ToString());
            double DM_Precio   = double.Parse(colsNoVisible[5].ToString());
            int    cantidad    = int.Parse(txtcantidad.Text);
            double precioAprox = 0;

            //_log.CustomWriteOnLog("Realizar venta 1", "STOCK DE MOLDURA  : " + IM_Stock.ToString());
            //_log.CustomWriteOnLog("Realizar venta 1", "PRECIO DE MOLDURA    : " + DM_Precio.ToString());

            if (cantidad <= IM_Stock)
            {
                precioAprox = cantidad * DM_Precio;
                _log.CustomWriteOnLog("Realizar venta 1", "PRECIO APROX DE COMPRA   : " + precioAprox.ToString());

                //txtsubtotal.Text = precioAprox.ToString();

                //updPanelSubTotal.Update();

                objDtoMoldura.PK_IM_Cod = Convert.ToInt32(txtcodigop.Text);
                double subtotal = Convert.ToDouble(txtcantidad.Text);
                gvdetalle2.DataSource = objCtrMoldura.CalcularSubtotal(objDtoMoldura, dtoTipoMoldura, subtotal);
                UpdatePanel1.Update();
                gvdetalle.Visible  = false;
                gvdetalle2.Visible = true;
                updPanelGVDetalle.Update();
                gvdetalle2.DataBind();

                txtimporttot.Text = precioAprox.ToString();

                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "showNotification", "showNotification('bg-green', 'Subtotal calculado', 'bottom', 'center', null, null);", true);
            }

            //ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "muestra2", "muestra2();", true);


            else
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "showNotification", "showNotification('bg-red', 'No se tiene el stock suficiente para proceder', 'bottom', 'center', null, null);", true);
            }
        }
        catch (Exception ex)
        {
            _log.CustomWriteOnLog("Realizar venta 1", "Error btncalcular_Click  : " + ex.Message);
        }
    }