Beispiel #1
0
        public XML_Gral LeeConfiguracionGral()
        {
            DataSet ds = new DataSet();
            ds.ReadXml(this.filePath);

            DataTable dtConfig = ds.Tables["configuracionGral"];

            XML_Gral c = new XML_Gral();

            if (dtConfig != null)
            {
                foreach (DataRow dr in dtConfig.Rows)
                {
                    //leemos la configuracion general
                    c.IdLastConfig = Convert.ToInt32(dr["IdLastConfig"]);
                }
            }

            return c;
        }
Beispiel #2
0
        public void GrabaConfiguracionGral(XML_Gral config)
        {
            try
            {
                //leemos nuevamente las configuraciones en un dataset, y agregamos
                //un nuevo datarow con la nueva configuracion y luego grabamos el xml
                DataSet ds = new DataSet();
                ds.ReadXml(this.filePath);

                DataTable dt = ds.Tables["configuracionGral"];

                DataRow dr;

                //en caso que no exista la tabla, la creamos
                if (dt != null)
                {
                    dt.Rows[0]["IdLastConfig"] = config.IdLastConfig;
                }
                else
                {
                    DataColumn dc;

                    dt = new DataTable("configuracionGral");

                    dc = new DataColumn("IdLastConfig");
                    dt.Columns.Add(dc);

                    dr = dt.NewRow();

                    dr["IdLastConfig"] = config.IdLastConfig;

                    dt.Rows.Add(dr);

                    ds.Tables.Add(dt);
                }

                ds.WriteXml(this.filePath);

            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }