Beispiel #1
0
        public FormulasVM()
        {
            //General setup
            Formulas           = new ObservableCollection <Formula>(FormulaQueries.GetFormulas());
            InactiveFormulas   = new ObservableCollection <Formula>(FormulaQueries.GetFormulasInactivas());
            NewFormulaProducts = new ObservableCollection <formulaProduct>(ProductQueries.GetFormulaProducts());

            NuevaFormulaCommand          = new NewFormulaCommand(this);
            AddDetalleNewFormulaDataGrid = new NewFormulaDetalleDatagridCommand(this);
            newFormulaAddInstruction     = new NewFormulaAddInstructionCommand(this);
            editDetalleCommand           = new EditDetalleCommand(this);
            newDetalleCommand            = new NewDetalleCommand(this);
            newInstructionCommand        = new NewInstructionCommand(this);
            editFormulacommand           = new EditFormulaCommand(this);
            Transformations = new ObservableCollection <Formula>(FormulaQueries.GetFormulasTransformaciones());


            UnidadCreada = new ObservableCollection <string> {
                "galones", "kilos"
            };
            FormasFarmaceuticas = new ObservableCollection <string> {
                "jarabe", "tableta", "pildora", "suspension"
            };


            //new formula modal window setup
            NewFormula = new Formula();
            NewFormulaSelectedProduct = new formulaProduct();
            NewFormulaNewDetalle      = new DetalleFormula();
            NewFormulaNewInstruction  = new ProcedimientoDetalle();

            SelectedFormula = Formulas[0];
        }
Beispiel #2
0
        public void FormulaProcedimientoModal(object parameter)
        {
            NewFormulaInstructions     = new ObservableCollection <ProcedimientoDetalle>(FormulaQueries.GetProcedimientoDetalles(SelectedFormula.CodFormula));
            SelectedFormulaInstruction = new ProcedimientoDetalle();

            var testview = new FormulaInstrucctionsModal(this);

            testview.ShowDialog();
        }
Beispiel #3
0
        public void NewFormulaAddInstruction()
        {
            var testDetalle = new ProcedimientoDetalle
            {
                Instruction = NewFormulaNewInstruction.Instruction
            };

            //System.Windows.MessageBox.Show(testDetalle.Instruction);

            NewFormulaInstructions.Add(testDetalle);
        }
Beispiel #4
0
        public void AgregarProcediminetoDetalle()
        {
/*
 *          if (NewFormulaNewInstruction.Step == 0)
 *          {
 *              FormulaQueries.agregarProcedimiento(NewFormulaNewInstruction.Instruction, (NewFormulaInstructions.Count + 1), SelectedFormula.CodFormula);
 *
 *              ProcedimientoDetalle testvar = new ProcedimientoDetalle()
 *              {
 *                  Instruction = NewFormulaNewInstruction.Instruction
 *              };
 *
 *              NewFormulaInstructions.Add(testvar);
 *
 *              System.Windows.MessageBox.Show("Instruccion agregada");
 *          }
 *          else if (NewFormulaNewInstruction.Step > NewFormulaInstructions.Count)
 *          {
 *              System.Windows.MessageBox.Show("Porfavor ingrese un valor de orden no mayor al numero de instrucciones.");
 *          }
 *          else
 *          {*/
            /* FormulaQueries.agregarProcedimientoEnPosicion(NewFormulaNewInstruction.Instruction, NewFormulaNewInstruction.Step, SelectedFormula.CodFormula);
             * ProcedimientoDetalle testvar = new ProcedimientoDetalle()
             * {
             *   Instruction = NewFormulaNewInstruction.Instruction
             * };
             * NewFormulaInstructions.Insert((NewFormulaNewInstruction.Step - 1), testvar);
             *
             * System.Windows.MessageBox.Show("Instruccion agregada");-*/

            FormulaQueries.agregarProcedimiento(NewFormulaNewInstruction.Instruction, NewFormulaNewInstruction.Step, SelectedFormula.CodFormula);

            ProcedimientoDetalle testvar = new ProcedimientoDetalle()
            {
                Instruction = NewFormulaNewInstruction.Instruction,
                Step        = NewFormulaNewInstruction.Step
            };

            NewFormulaInstructions.Add(testvar);

            System.Windows.MessageBox.Show("Instruccion agregada");

            // }
        }
Beispiel #5
0
        public void NewFormulaModal(object parameter)
        {
            var TestView = new NewFormulaModal(this);

            NewFormula = new Formula();

            isTransform                = false;
            NewFormulaDetalles         = new ObservableCollection <DetalleFormula>();
            NewFormulaSelectedDetalle  = new DetalleFormula();
            SelectedFormulaInstruction = new ProcedimientoDetalle();
            NewFormulaInstructions     = new ObservableCollection <ProcedimientoDetalle>();
            NewFormula.FormaFarm       = FormasFarmaceuticas[0];
            NewFormula.Cantidad        = UnidadCreada[0];



            TestView.ShowDialog();
        }
Beispiel #6
0
        public static void updateProcedimiento(ProcedimientoDetalle procedure, string codigo)
        {
            cn = DBConnection.MainConnection();
            try
            {
                cmd = new OleDbCommand("UPDATE procedimiento_detalle " +
                                       "SET procedimiento = '" + procedure.Instruction + "' " +
                                       "WHERE id_formula = '" + codigo + "'  and numero_etapa = " + procedure.Step + ";", cn);
                cmd.ExecuteNonQuery();



                cn.Close();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Error al actualizar Procedimiento Detalle  " + ex);
            }
        }
Beispiel #7
0
        public static List <ProcedimientoDetalle> GetProcedimientoDetalles(string codigo)
        {
            List <ProcedimientoDetalle> instructions = new List <ProcedimientoDetalle>();

            cn = DBConnection.MainConnection();

            try
            {
                cmd = new OleDbCommand("SELECT * FROM procedimiento_detalle " +
                                       "where id_formula = '" + codigo + "' ORDER BY numero_etapa;", cn);

                dr = cmd.ExecuteReader();



                while (dr.Read())
                {
                    ProcedimientoDetalle temp = new ProcedimientoDetalle();

                    temp.Instruction = dr["procedimiento"].ToString();
                    temp.Step        = int.Parse(dr["numero_etapa"].ToString());

                    instructions.Add(temp);
                }

                dr.Close();
                cn.Close();
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("Error al obtener procedimientos " + ex.ToString());
            }


            return(instructions);
        }