how to check unchek checkboxes using xml

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanthsp2002
    New Member
    • Apr 2006
    • 28

    how to check unchek checkboxes using xml

    i have an xml file, i have to enable or disable checkboxes based on these valuse


    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <ModulesAvalable>
    
        <Module name="calculator" hasdatabase="False" enabled="True"></Module>
        <Module name="employeemanager" hasdatabase="True"  enabled="False"></Module>
        <Module name="Central Office" hasdatabase="False" enabled="True"></Module>
        <Module name="emp/emp Manager" hasdatabase="True" enabled="True"></Module>
        
    </ModulesAvalable>
    so how to do this
    Last edited by Dormilich; Jan 9 '09, 07:27 AM. Reason: added [code] tags
  • shanthsp2002
    New Member
    • Apr 2006
    • 28

    #2
    I got the answer friends

    <?xml version="1.0" encoding="utf-8" ?>
    <ModulesAvailab le>
    <Module>
    <NAME>FRE</NAME>
    <HASDATABASE>FA LSE</HASDATABASE>
    <ENABLED>FALS E</ENABLED>
    </Module>
    <Module>
    <NAME>CENTRALOF FICE</NAME>
    <HASDATABASE>FA LSE</HASDATABASE>
    <ENABLED>FALS E</ENABLED>
    </Module>


    <Module>
    <NAME>POS</NAME>
    <HASDATABASE>TR UE</HASDATABASE>
    <ENABLED>TRUE </ENABLED>
    </Module>

    <Module>
    <NAME>POS/POSMANAGER</NAME>
    <HASDATABASE>TR UE</HASDATABASE>
    <ENABLED>TRUE </ENABLED>
    </Module>
    </ModulesAvailabl e>

    we r reading data from this file to check or uncheck the checkboxes


    using System;
    using System.Collecti ons.Generic;
    using System.Componen tModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Diagnost ics;
    using System.IO;
    using System.Xml;



    () cashier
    () central server option button
    () manager

    [] install database checkbox

    here checkbox must be unchecked for cashier and central server for manager its enabled
    so we do this using this code








    using System.Windows. Forms;

    namespace ReadmeDilogue
    {
    public partial class ReadmeForm : Form
    {
    bool InstallDb = false;


    public ReadmeForm(bool installDatabase )
    {
    InstallDb = installDatabase ;



    InitializeCompo nent();
    }


    private void ReadmeForm_Load (object sender, EventArgs e)
    {
    DataSet ds = new DataSet();
    ds.ReadXml("D:\ \PRS\\EXAMP\\Ne w Folder\\ReadmeD ilogue\\ReadmeD ilogue\\DATA.xm l");

    try
    {

    if (Convert.ToBool ean(ds.Tables[0].Rows[0][2]) == false)
    {
    radioButton0.En abled = false;
    }
    if (Convert.ToBool ean(ds.Tables[0].Rows[1][2]) == false)
    {
    radioButton1.En abled = false;
    }
    if (Convert.ToBool ean(ds.Tables[0].Rows[2][2]) == false)
    {
    radioButton2.En abled = false;
    }
    if (Convert.ToBool ean(ds.Tables[0].Rows[3][2]) == false)
    {
    radioButton3.En abled = false;
    }
    for (int i = 0; i <= ds.Tables[0].Rows.Count-1; i++)
    {
    if (Convert.ToBool ean(ds.Tables[0].Rows[i][2]) == true)
    {

    if (Convert.ToBool ean(ds.Tables[0].Rows[i][1]) == true)
    {
    checkBox2.Enabl ed = true;
    }
    else
    {
    checkBox2.Enabl ed = false;
    }
    }

    }
    }
    catch (Exception de)
    {
    Console.WriteLi ne("Exception: {0}", de.ToString());
    }

    }


    //getting value of installDb (TRUE|FALSE)

    public bool InstallDB
    {
    get { return this.checkBox2. Checked; }
    }


    public void change_color()
    {
    button1.BackCol or = System.Drawing. Color.Gold;


    }


    private void button1_Click(o bject sender, EventArgs e)
    {


    MessageBox.Show (Convert.ToStri ng(InstallDB));


    this.Close();
    }
    private void checkBox2_Check edChanged(objec t sender, EventArgs e)
    {


    }




    /// <summary>
    /// the install database checkbox will be disabled if FRE or CENTRAL SERVER is selected
    /// here we are also unchecking the install database checkbox if it is alredy checked
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>



    private void radioButton0_Ch eckedChanged_1( object sender, EventArgs e)
    {
    checkBox2.Check ed = false;

    if (radioButton0.C hecked == false)
    {
    checkBox2.Enabl ed = true;
    }
    else if (radioButton0.C hecked == true)
    {

    checkBox2.Enabl ed = false;
    }
    }

    private void radioButton1_Ch eckedChanged(ob ject sender, EventArgs e)
    {
    checkBox2.Check ed = false;

    if (radioButton1.C hecked == true)
    {
    checkBox2.Enabl ed = false;
    }
    else if (radioButton1.C hecked == false)
    {

    checkBox2.Enabl ed = true;
    }

    }

    // InstallDatabase Checkbox will be enabled if pos or posManager is selected

    private void radioButton2_Ch eckedChanged(ob ject sender, EventArgs e)
    {
    if (radioButton2.C hecked == true)
    {
    checkBox2.Enabl ed = true;
    }
    else if (radioButton2.C hecked == false)
    {

    checkBox2.Enabl ed = false;
    }
    }

    private void radioButton3_Ch eckedChanged(ob ject sender, EventArgs e)
    {
    if (radioButton3.C hecked == true)
    {
    checkBox2.Enabl ed = true;
    }
    else if (radioButton3.C hecked == false)
    {

    checkBox2.Enabl ed = false;
    }

    }



    }
    }
    Last edited by shanthsp2002; Apr 10 '06, 12:38 PM.

    Comment

    Working...