Esempio n. 1
0
 void CrearInsumo()
 {
     //Objetos.Insumos.IdFamilia = 1;
     //Objetos.Insumos.IdMoneda = 1;
     //Objetos.Insumos.IdProveedor = 1;
     //Objetos.Insumos.NombreInsumo = this.txtFormula.Text;
     //Objetos.Insumos.NombreInterno = this.txtFormula.Text;
     //Objetos.Insumos.UnidadMedida = UnidadMedida;
     //Objetos.Insumos.PrecioUnitario = Convert.ToDouble(lblCosto.Text) / Convert.ToDouble(Cantidad);
     //Objetos.Insumos.TotalCompraMX = 1000;
     //Objetos.Insumos.Guardar(Objetos.Insumos);
     cnInsumos.Guardar(AsignaDatosObjetoInsumo());
 }
Esempio n. 2
0
        private void btnGuardar_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (ValidaGUI())
                {
                    if (!Guardar)
                    {
                        bool ActualizarPreciosFormulas = false;
                        if (Convert.ToDouble(txtPrecioUnitaio.Text) != PU) //PU=> variable para almacenar el precio unitario del insumo cuando se consulta antes de cualquier edicion.
                        {
                            if (Convert.ToDouble(txtPrecioUnitaio.Text) < PU)
                            {
                                if (MessageBox.Show("El costo del insumo ha bajado.\n" +
                                                    "¿Deseas actualizar el precio de las fórmulas que contienen este insumo?",
                                                    "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    ActualizarPreciosFormulas = true;
                                }
                            }
                            else
                            {
                                ActualizarPreciosFormulas = true;
                            }
                        }
                        string connectionString = ConfigurationManager.ConnectionStrings["sdprolizaEntitiessp"].ConnectionString;

                        CNInsumos cNInsumos = new CNInsumos(connectionString, Estaticos.IdUsuario, AsignaGUIObjeto2(ActualizarPreciosFormulas), ActualizarPreciosFormulas, Convert.ToInt32(cmbMoneda.EditValue) == 2 ? Convert.ToDecimal(Estaticos.dolar) : 1);
                        using (waitForm frm = new waitForm(cNInsumos.ActualizarPv2, "Actualizando precio", "Por favor espere, no tardaremos mucho."))
                        {
                            frm.ShowDialog(this);
                        }
                        if (!cNInsumos.EstadoOperacion)
                        {
                            throw new Exception(cNInsumos.Msj);
                        }
                    }
                    else
                    {
                        cnInsumos.Guardar(AsignaGUIObjeto2(true));
                    }

                    Limpiar();
                    HabilitarCampos(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }