Example #1
0
        public static List <Clases.EFormula> Lee_Formula(string Receta)
        {
            List <Clases.EFormula> ii_LEFormula = new List <Clases.EFormula>();

            Clases.EFormula ii_EFormula = new Clases.EFormula();
            DataSet         DS          = new DataSet();
            string          Error       = "";
            string          sql         = "  SELECT * from Formula_receta WHERE id_receta_fr = '" + Receta + "'";

            DS = funciones.EjecutaSQL(sql, ref Error);
            if (DS.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < DS.Tables[0].Rows.Count; i++)
                {
                    ii_EFormula             = new Clases.EFormula();
                    ii_EFormula.ID_Receta   = DS.Tables[0].Rows[i]["id_receta_fr"].ToString();
                    ii_EFormula.ID_Articulo = DS.Tables[0].Rows[i]["id_articulo_fr"].ToString();
                    ii_EFormula.id_unidad   = DS.Tables[0].Rows[i]["id_unidad_fr"].ToString();
                    ii_EFormula.cantidad    = decimal.Parse(DS.Tables[0].Rows[i]["cant_art_fr"].ToString());
                    ii_EFormula.obligatorio = DS.Tables[0].Rows[i]["no_sust_art_fr"].ToString();
                    ii_LEFormula.Add(ii_EFormula);
                }
                return(ii_LEFormula);
            }
            return(null);
        }
Example #2
0
        bool Inserta_Formula()
        {
            string Error = "";
            List <Clases.EFormula> aa_LEFormulaAseg = new List <Clases.EFormula>();

            Clases.EFormula aa_EPlanAseg = new Clases.EFormula();
            for (int ii = 0; ii < dataGridView1.RowCount - 1; ii++)
            {
                aa_EPlanAseg = new Clases.EFormula();

                aa_EPlanAseg.ID_Receta   = tid.Text;
                aa_EPlanAseg.ID_Articulo = dataGridView1.Rows[ii].Cells[0].Value.ToString().Trim();
                aa_EPlanAseg.id_unidad   = dataGridView1.Rows[ii].Cells[2].Value.ToString().Trim();
                aa_EPlanAseg.cantidad    = decimal.Parse(dataGridView1.Rows[ii].Cells[3].Value.ToString().Trim());
                bool obligatorio = Convert.ToBoolean(dataGridView1.Rows[ii].Cells[4].Value);
                if (obligatorio)
                {
                    aa_EPlanAseg.obligatorio = "X";
                }

                aa_LEFormulaAseg.Add(aa_EPlanAseg);
            }

            if (funciones.Inserta_Formula(aa_LEFormulaAseg, ref Error))
            {
                return(true);
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(Error.Trim()))
                {
                    MessageBox.Show(Error.ToString().Trim());
                }
            }
            return(false);
        }