Ejemplo n.º 1
0
    private void CreatDataSet(object datasetid)
    {
        XmlDocument xmlDoc = new XmlDocument();
        string resourceName = psyPath + ".vi-VN.resx";
        ResXResourceReader reader = new ResXResourceReader(resourceName);
        IDictionaryEnumerator enumerator = reader.GetEnumerator();
        while (enumerator.MoveNext())
        {
            if (enumerator.Key.ToString() == "WebDataSets")
            {
                string sXml = (string)enumerator.Value;
                xmlDoc.LoadXml(sXml);
                break;
            }
        }
        if (xmlDoc != null)
        {
            XmlNode nWDSs = xmlDoc.SelectSingleNode("WebDataSets");
            if (nWDSs != null)
            {
                XmlNode nWDS = nWDSs.SelectSingleNode("WebDataSet[@Name='" + datasetid + "']");
                if (nWDS != null)
                {
                    string remoteName = "";
                    int packetRecords = 100;
                    bool active = false;
                    bool serverModify = false;

                    XmlNode nRemoteName = nWDS.SelectSingleNode("RemoteName");
                    if (nRemoteName != null)
                        remoteName = nRemoteName.InnerText;

                    XmlNode nPacketRecords = nWDS.SelectSingleNode("PacketRecords");
                    if (nPacketRecords != null)
                        packetRecords = nPacketRecords.InnerText.Length == 0 ? 100 : Convert.ToInt32(nPacketRecords.InnerText);

                    XmlNode nActive = nWDS.SelectSingleNode("Active");
                    if (nActive != null)
                        active = nActive.InnerText.Length == 0 ? false : Convert.ToBoolean(nActive.InnerText);

                    XmlNode nServerModify = nWDS.SelectSingleNode("ServerModify");
                    if (nServerModify != null)
                        serverModify = nServerModify.InnerText.Length == 0 ? false : Convert.ToBoolean(nServerModify.InnerText);

                    WebDataSet wds = new WebDataSet();
                    wds.RemoteName = remoteName;
                    wds.PacketRecords = packetRecords;
                    wds.ServerModify = serverModify;
                    wds.Active = true;

                    wdsDay = wds;
                    if (strWhere != string.Empty)
                    {
                        wdsDay.SetWhere(strWhere);
                    }

                }
            }
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent();
            wdsSolution.DataSource = WSolution;
            GroupMenus = WGroupMenus;
            UserMenus = WUserMenus;
            Menu = WMenu;
            this.ddlSolution.DataBind();

            if (Session["State"] != null)
            {
                if (Session["State"].ToString() == "X")
                {
                    Label1.Visible = false;
                    Label2.Visible = false;
                    ddlCopy.Visible = false;
                    ddlSolution.Visible = false;
                    btnApply.Visible = false;
                    btnEqual.Visible = false;
                    btnCopy.Visible = false;
                    btnSelectAll.Visible = false;
                    btnCancelAll.Visible = false;
                }
                else if (Session["State"].ToString() == "U")
                {
                    String lID = Session["UserID"].ToString();

                    for (int i = 0; i < WUser.RealDataSet.Tables[0].Rows.Count; i++)
                        if (WUser.RealDataSet.Tables[0].Rows[i]["USERID"].ToString() != lID)
                            ddlCopy.Items.Add(WUser.RealDataSet.Tables[0].Rows[i]["USERID"].ToString());

                    Menu.SetWhere("ITEMTYPE='" + this.ddlSolution.SelectedValue + "'");
                    cblMenu.DataSource = Menu;
                    cblMenu.DataValueField = "MENUID";
                    cblMenu.DataTextField = "CAPTION";
                    cblMenu.DataBind();

                    //WUserMenus.SetWhere("USERID='" + lID + "'");
                    for (int i = 0; i < WUserMenus.RealDataSet.Tables[0].Rows.Count; i++)
                    {
                        for (int j = 0; j < cblMenu.Items.Count; j++)
                        {
                            string text = cblMenu.Items[j].Value;

                            if (WUserMenus.RealDataSet.Tables[0].Rows[i]["USERID"].ToString() == lID && WUserMenus.RealDataSet.Tables[0].Rows[i]["MENUID"].ToString() == text)
                            {
                                cblMenu.Items[j].Selected = true;
                                break;
                            }
                        }
                    }
                }
                else if (Session["State"].ToString() == "G")
                {
                    String lID = Session["GroupID"].ToString();

                    for (int i = 0; i < WGroup.RealDataSet.Tables[0].Rows.Count; i++)
                        if (WGroup.RealDataSet.Tables[0].Rows[i]["GROUPID"].ToString() != lID)
                            ddlCopy.Items.Add(WGroup.RealDataSet.Tables[0].Rows[i]["GROUPID"].ToString());

                    Menu.SetWhere("ITEMTYPE='" + this.ddlSolution.SelectedValue + "'");
                    cblMenu.DataSource = Menu;
                    cblMenu.DataValueField = "MENUID";
                    cblMenu.DataTextField = "CAPTION";
                    cblMenu.DataBind();

                    //WGroupMenus.SetWhere("GROUPID='" + lID + "'");
                    for (int i = 0; i < WGroupMenus.RealDataSet.Tables[0].Rows.Count; i++)
                    {
                        for (int j = 0; j < cblMenu.Items.Count; j++)
                        {
                            string text = cblMenu.Items[j].Value;
                            if (WGroupMenus.RealDataSet.Tables[0].Rows[i]["GROUPID"].ToString() == lID && WGroupMenus.RealDataSet.Tables[0].Rows[i]["MENUID"].ToString() == text)
                            {
                                cblMenu.Items[j].Selected = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }