Exemplo n.º 1
0
        /// <summary>
        /// 读xml获取可用功能
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="skey_root"></param>
        /// <param name="skey_funcid"></param>
        /// <param name="skey_avail"></param>
        /// <param name="skey_des"></param>
        private void readfuncfromxml(string filepath, string skey_root, string skey_funcid, string skey_avail, string skey_des)
        {
            XmlAnalysis xma = new XmlAnalysis();

            string[] sFunc       = new string[64];
            string   sError      = null;
            int      nFuncAvailn = 0;

            //读取xml配置文件中的可用功能
            bool bSuccess = xma.readxml_findfunc(filepath, ref sFunc, ref Cfg.sFuncid, ref sError, skey_des,
                                                 skey_root, skey_funcid, skey_avail, ref nFuncAvailn);

            if (!bSuccess)
            {
                MessageBox.Show("Error:" + sError);
                return;
            }
            //更新下拉功能列表
            for (int i = 0; i < nFuncAvailn; ++i)
            {
                cbb_funcid.Items.Add(sFunc[i]);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 读xml获取可用功能
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="skey_root"></param>
        /// <param name="skey_funcid"></param>
        /// <param name="skey_avail"></param>
        /// <param name="skey_des"></param>
        private void readfuncfromxml(string filepath, string skey_root, string skey_funcid, string skey_avail, string skey_des)
        {
            XmlAnalysis xma = new XmlAnalysis();
            string[] sFunc = new string[64];
            string sError = null;
            int nFuncAvailn = 0;

            //读取xml配置文件中的可用功能
            bool bSuccess = xma.readxml_findfunc(filepath, ref sFunc, ref Cfg.sFuncid, ref sError, skey_des,
                                        skey_root, skey_funcid, skey_avail, ref nFuncAvailn);
            if (!bSuccess)
            {
                MessageBox.Show("Error:" + sError);
                return;
            }
            //更新下拉功能列表
            for (int i = 0; i < nFuncAvailn; ++i)
                cbb_funcid.Items.Add(sFunc[i]);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 功能号选择及解析
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbb_funcid_SelectedIndexChanged(object sender, EventArgs e)
        {
            XmlAnalysis xmla    = new XmlAnalysis();
            string      sError  = null;
            int         i       = 0;
            string      sFuncid = "";

            bt_GeneBankData.Enabled = false;
            btgetdata.Enabled       = false;
            tssLable.Text           = "";
            tssLable.ForeColor      = Color.Black;

            //结果集
            DataTable dtResult = new DataTable();

            for (int k = 0; k < Cfg.sPara.Length; ++k)
            {
                dtResult.Columns.Add(new DataColumn(Cfg.sPara[k], typeof(string)));
            }

            //功能判断
            string sfunc = cbb_funcid.Text;

            foreach (string sf in Cfg.sFuncid)
            {
                if (sf == null)
                {
                    continue;
                }
                if (sfunc.Contains(sf))
                {
                    sFuncid = sf;
                }
            }

            //解析xml
            bool bSuccess = xmla.readxml_funcPara(Cfg.sFilepath, sFuncid, ref sError, ref dtResult,
                                                  Cfg.sKey_root, Cfg.sKey_funcid, Cfg.sKey_avail, Cfg.sPara);

            if (!bSuccess)
            {
                MessageBox.Show("Error:" + sError);
                return;
            }

            //参数数量
            Cfg.nParaNum = dtResult.Rows.Count;
            if (Cfg.nParaNum > Cfg.nLength)
            {
                MessageBox.Show("Error:" + "该功能的参数超过了当前系统限制!" + Cfg.nLength.ToString());
                return;
            }

            //输出到前端控件
            foreach (DataRow dr in dtResult.Rows)
            {
                try
                {
                    lb[i].Text       = dr[Cfg.sPara[0]].ToString();     //keyname
                    tblen[i].Text    = dr[Cfg.sPara[1]].ToString();     //length
                    tbv[i].Text      = dr[Cfg.sPara[2]].ToString();     //value
                    tbv[i].MaxLength = int.Parse(tblen[i].Text);        //长度控制
                    //是否为空
                    if (dr[Cfg.sPara[3]].ToString() == "no")
                    {
                        lb[i].ForeColor = Color.Red;
                        tbv[i].Enabled  = true;
                    }
                    else if (dr[Cfg.sPara[3]].ToString() == "yes")
                    {
                        lb[i].ForeColor = Color.Black;
                        tbv[i].Enabled  = false;
                    }
                    else if (dr[Cfg.sPara[3]].ToString() == "solid")
                    {
                        lb[i].ForeColor = Color.Black;
                        tbv[i].Enabled  = false;
                    }
                    else
                    {
                        MessageBox.Show(Cfg.sPara[3].ToString() + "字段配置有误(必须为yes、no或solid");
                        return;
                    }
                    //对日期的特殊处理
                    if (lb[i].Text.Contains("operdate"))
                    {
                        tbv[i].Text = DateTime.Now.ToString("yyyyMMdd");
                    }
                    else if (lb[i].Text.Contains("opertime"))
                    {
                        tbv[i].Text = DateTime.Now.ToString("hhmmss");
                    }
                    ++i;
                }
                catch (Exception ed)
                {
                    MessageBox.Show(ed.ToString());
                }
            }

            //多余的控件关闭
            for (int j = Cfg.nLength - 1; j >= Cfg.nParaNum; --j)
            {
                tblen[j].Enabled = false;
                tbv[j].Enabled   = false;
                lb[j].Text       = "";
            }
            bt_GeneBankData.Enabled = true;
            btgetdata.Enabled       = true;
            tssLable.Text           = "从xml文件导入成功";
            tssLable.ForeColor      = Color.ForestGreen;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 功能号选择及解析
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbb_funcid_SelectedIndexChanged(object sender, EventArgs e)
        {
            XmlAnalysis xmla = new XmlAnalysis();
            string sError = null;
            int i = 0;
            string sFuncid = "";
            bt_GeneBankData.Enabled = false;
            btgetdata.Enabled = false;
            tssLable.Text = "";
            tssLable.ForeColor = Color.Black;

            //结果集
            DataTable dtResult = new DataTable();
            for(int k = 0; k < Cfg.sPara.Length; ++k)
                dtResult.Columns.Add(new DataColumn(Cfg.sPara[k], typeof(string)));

            //功能判断
            string sfunc = cbb_funcid.Text;
            foreach (string sf in Cfg.sFuncid)
            {
                if (sf == null)
                    continue;
                if (sfunc.Contains(sf))
                    sFuncid = sf;
            }

            //解析xml
            bool bSuccess = xmla.readxml_funcPara(Cfg.sFilepath, sFuncid, ref sError, ref dtResult,
                            Cfg.sKey_root, Cfg.sKey_funcid, Cfg.sKey_avail, Cfg.sPara);
            if (!bSuccess)
            {
                MessageBox.Show("Error:" + sError);
                return;
            }

            //参数数量
            Cfg.nParaNum = dtResult.Rows.Count;
            if(Cfg.nParaNum > Cfg.nLength)
            {
                MessageBox.Show("Error:" + "该功能的参数超过了当前系统限制!" + Cfg.nLength.ToString());
                return;
            }

            //输出到前端控件
            foreach(DataRow dr in dtResult.Rows)
            {
                try
                {
                    lb[i].Text = dr[Cfg.sPara[0]].ToString();           //keyname
                    tblen[i].Text = dr[Cfg.sPara[1]].ToString();        //length
                    tbv[i].Text = dr[Cfg.sPara[2]].ToString();          //value
                    tbv[i].MaxLength = int.Parse(tblen[i].Text);        //长度控制
                    //是否为空
                    if (dr[Cfg.sPara[3]].ToString() == "no")
                    {
                        lb[i].ForeColor = Color.Red;
                        tbv[i].Enabled = true;
                    }
                    else if (dr[Cfg.sPara[3]].ToString() == "yes")
                    {
                        lb[i].ForeColor = Color.Black;
                        tbv[i].Enabled = false;
                    }
                    else if (dr[Cfg.sPara[3]].ToString() == "solid")
                    {
                        lb[i].ForeColor = Color.Black;
                        tbv[i].Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show(Cfg.sPara[3].ToString() + "字段配置有误(必须为yes、no或solid");
                        return;
                    }
                    //对日期的特殊处理
                    if (lb[i].Text.Contains("operdate"))
                    {
                        tbv[i].Text = DateTime.Now.ToString("yyyyMMdd");
                    }
                    else if (lb[i].Text.Contains("opertime"))
                    {
                        tbv[i].Text = DateTime.Now.ToString("hhmmss");
                    }
                    ++i;
                }
                catch(Exception ed)
                {
                    MessageBox.Show(ed.ToString());
                }
            }

            //多余的控件关闭
            for(int j = Cfg.nLength - 1; j >= Cfg.nParaNum; --j)
            {
                tblen[j].Enabled = false;
                tbv[j].Enabled = false;
                lb[j].Text = "";
            }
            bt_GeneBankData.Enabled = true;
            btgetdata.Enabled = true;
            tssLable.Text = "从xml文件导入成功";
            tssLable.ForeColor = Color.ForestGreen;
        }