예제 #1
0
        public bool initialCon()
        {
            try
            {
                string strSql = "select wellNo,depName,gprsNo from tbWell";
                CDBConnection.getDataTable(ref CDBConnection.m_dtWellInfo, strSql, "tbWell");

                //报警下限
                strSql = String.Format("select val from tbInfo where des='报警下限'");
                string strWarnLevel = CDBConnection.ExecuteScalar(strSql);
                CDBConnection.m_iWarnLevel = Convert.ToInt32(strWarnLevel);

                //初始化售水表
                this.iniSalDt(ref CDBConnection.m_dtSal);
                //初始化指令集
                this.iniCmds(ref CDBConnection.m_htCmds);

                XmlDocument xDoc = new XmlDocument();
                xDoc.Load("Info.xml");

                string strServerType = xDoc.DocumentElement.SelectSingleNode("./tcpServer").Attributes.GetNamedItem("name").Value.ToString().Trim();
                if (strServerType == "server")
                {
                    CDBConnection.m_bServer = true;
                }
                else
                {
                    if (strServerType == "client")
                    {
                        CDBConnection.m_bClient = true;
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
예제 #2
0
파일: frmWaterSys.cs 프로젝트: hkiaipc/yh
        private void frmWaterSys_Load(object sender, System.EventArgs e)
        {
            try
            {
                string strSql=string.Format("select softName,userName,version,image from tbAdInfo where userid='{0}'",BengZhan.CDBConnection.m_strUserID);
                DataTable dtAdInfo=new DataTable();

                BengZhan.CDBConnection.getDataTable(ref dtAdInfo,strSql,"dt");

                XmlDocument xDocInfo=new XmlDocument();
                xDocInfo.Load(@"ini/sysIni.xml");

                xDocInfo.DocumentElement.SelectSingleNode("./abort/softName").Attributes.GetNamedItem("val").Value=dtAdInfo.Rows[0]["softName"].ToString().Trim();
                xDocInfo.DocumentElement.SelectSingleNode("./abort/version").Attributes.GetNamedItem("val").Value=dtAdInfo.Rows[0]["version"].ToString().Trim();
                xDocInfo.DocumentElement.SelectSingleNode("./abort/user").Attributes.GetNamedItem("val").Value=dtAdInfo.Rows[0]["userName"].ToString().Trim();

                xDocInfo.Save(@"ini/sysIni.xml");

                System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmWaterSys));

            //				if(dtAdInfo.Rows[0]["image"].ToString().Trim()=="frm1")
            //				{
            //
            //					BengZhan.frm1 frm=new frm1();
            //					System.Drawing.Image im=frm.BackgroundImage;
            //					this.BackgroundImage=im;
            //
            //				}
            //
            //				if(dtAdInfo.Rows[0]["image"].ToString().Trim()=="frmWaterSys1")
            //				{
            //					BengZhan.frm2 frm=new frm2();
            //					System.Drawing.Image im=frm.BackgroundImage;
            //					this.BackgroundImage=im;
            //				}
            //
            //				if(dtAdInfo.Rows[0]["image"].ToString().Trim()=="th")
            //				{
            //					this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
            //				}

                //System.Drawing.Image im=frm.BackgroundImage;

                //	string strSql=string.Format("delete from tbcmd insert into tbCmd values('start')");
                //	BengZhan.CDBConnection.ExecuteSql(strSql);
                //				this.pictureBox1.Location=new Point((this.toolBar1.Location.Y+this.toolBar1.Height),this.toolBar1.Location.X);
                //				this.pictureBox1.Height=this.Height-this.pictureBox1.Location.Y;
                //				this.pictureBox1.Width=this.Width;
                //this.pictureBox1.Image=((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));

                //this.errorProvider2.SetError(this.toolBar1.b,"warn");

                //��ʼһ����ͼ
                iniWellAmount();

                CInsertMenu cInsertM=new CInsertMenu();
                cInsertM.EnableMenu(this.mainMenu1);
                cInsertM.enableToolbar(this.toolBar1,this.mainMenu1);
                //this.enableToolBar();
                this.iniFrm();

                //*******************************ϵͳ��ʼ��**********************************************
                //New.laidianDisplay.GDBConnection GDBC=new New.laidianDisplay.GDBConnection();
                //GDBC.initialCDB();

                BengZhan.CDBConnection cdb=new CDBConnection();
                cdb.initialCon();
                //��ʼ��remotingϵͳ��
                GprsSoft.serverMonitor.CServer csObj=new GprsSoft.serverMonitor.CServer();
                csObj.InitialCServer();
                CDBConnection.refreshHis();
                //***************************************************************************************

                if(BengZhan.CDBConnection.m_bClient==true)
                {
                    this.Text=this.Text+"[�ͻ���]";
                }
                if(BengZhan.CDBConnection.m_bServer==true)
                {
                    this.Text=this.Text+"[������]";
                }

                if(m_softName!=null)
                {
                    if(m_softName.Trim()!="")
                    {

                        this.Text=m_softName;
                        //this.Text=m_softName+string.Format("    [��ǰ�û���{0}]",CDBConnection.m_strUserName);
                    }
                }

                //this.BackgroundImage=null;
                //�Զ��������ݿ�

                //this.startFrm();

                autoBackup();

                this.startTimer();

                this.regCom();

                this.disToolBar();

                this.BackColor=Color.White;
                this.Text=this.Text+"[�°�]";

                this.Text="��������ϵͳ";

                XmlDocument xDoc=new XmlDocument();

                xDoc.Load("Server.xml");

                string strTitle=xDoc.DocumentElement.SelectSingleNode("./abort/softName").Attributes.GetNamedItem("val").Value.Trim();

                this.Text=strTitle;

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #3
0
        public void EnableMenu(MainMenu mMenu)
        {
            try
            {
                SqlConnection sCon = new SqlConnection(BengZhan.CDBConnection.m_strCon);
                sCon.Open();
                string strUserID = CDBConnection.m_strUserID;

                string strSql           = String.Format("select parentManager from tbUsers where userID='{0}'", strUserID);
                string strParentManager = CDBConnection.ExecuteScalar(strSql);
                if (strParentManager.Trim() != "")
                {
                    strSql = String.Format("select userID from tbUsers where userName='******'", strParentManager.Trim());
                    string strUID = CDBConnection.ExecuteScalar(strSql).Trim();
                    strUserID = strUID;
                }

                strSql = String.Format("select menuName from userMenu where UserID='{0}'", strUserID);
                SqlCommand sCmd = new SqlCommand();
                sCmd.Connection  = sCon;
                sCmd.CommandText = strSql;
                DataSet        ds  = new DataSet();
                SqlDataAdapter sda = new SqlDataAdapter();
                sda.SelectCommand = sCmd;
                sda.Fill(ds, "userMenu");
                DataTable dtUserMenu = ds.Tables["userMenu"];

                for (int i = 0; i < mMenu.MenuItems.Count; i++)
                {
                    mMenu.MenuItems[i].Enabled = false;
                    mMenu.MenuItems[i].Visible = false;

                    string strParent = mMenu.MenuItems[i].Text.Trim();
                    for (int x = 0; x < dtUserMenu.Rows.Count; x++)
                    {
                        if (strParent == dtUserMenu.Rows[x][0].ToString().Trim())
                        {
                            mMenu.MenuItems[i].Enabled = true;
                            mMenu.MenuItems[i].Visible = true;
                            break;
                        }
                    }

                    for (int j = 0; j < mMenu.MenuItems[i].MenuItems.Count; j++)
                    {
                        mMenu.MenuItems[i].MenuItems[j].Visible = false;
                        mMenu.MenuItems[i].MenuItems[j].Enabled = false;

                        for (int y = 0; y < dtUserMenu.Rows.Count; y++)
                        {
                            string strChild = mMenu.MenuItems[i].MenuItems[j].Text.Trim();

                            if (strChild == dtUserMenu.Rows[y][0].ToString().Trim())
                            {
                                mMenu.MenuItems[i].MenuItems[j].Visible = true;
                                mMenu.MenuItems[i].MenuItems[j].Enabled = true;

                                break;
                            }
                        }
                    }
                }

//				for(int i=0;i<mMenu.MenuItems.Count;i++)
//				{
//					mMenu.MenuItems[i].Enabled=true;
//					mMenu.MenuItems[i].Visible=true;
//
//				}
                sCon.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #4
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.m_frm != null)
                {
                    this.m_frm.Close();
                }

                XmlDocument xDoc = new XmlDocument();
                xDoc.Load("Server.xml");
                string        strCon = xDoc.DocumentElement.SelectSingleNode("./strCon").InnerText.Trim();
                SqlConnection sCon   = new  SqlConnection(strCon);

                try
                {
                    sCon.Open();
                    BengZhan.CDBConnection.m_strCon = strCon;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("连接失败,请测试连接!");
                    return;
                }

                CDBConnection.m_sCon = sCon;

                string strSql = String.Format("select count(*) from tbUsers where userID='{0}' and userPwd='{1}'", this.txtUserName.Text.Trim(), this.txtPwd.Text.Trim());
                sCon = new SqlConnection(BengZhan.CDBConnection.m_strCon);
                sCon.Open();
                SqlCommand sCmd = new SqlCommand();
                sCmd.Connection  = sCon;
                sCmd.CommandText = strSql;
                string strCount = sCmd.ExecuteScalar().ToString();
                sCon.Close();
                int iCount = Convert.ToInt32(strCount);
                if (iCount <= 0)
                {
                    MessageBox.Show("用户ID或密码有误!");
                    return;
                }


                CDBConnection.m_strUserID = this.txtUserName.Text.Trim();

                strSql = String.Format("select userName from tbUsers where userID='{0}'", CDBConnection.m_strUserID);
                CDBConnection.m_strUserName = CDBConnection.ExecuteScalar(strSql);

                xDoc = new XmlDocument();
                xDoc.Load("Server.xml");

                xDoc.DocumentElement.SelectSingleNode("./load").Attributes.GetNamedItem("name").Value = CDBConnection.m_strUserID;
                xDoc.Save("Server.xml");

                if (BengZhan.tools.DBConnection.m_App != null)
                {
                    this.Close();
                    return;
                }
                BengZhan.tools.DBConnection.m_App = this;
                this.Hide();
                this.Visible = false;


                frmWaterSys frmWaterSysObj = new frmWaterSys();
                frmWaterSysObj.WindowState = System.Windows.Forms.FormWindowState.Maximized;

                frmWaterSysObj.Show();

                if (xDoc.DocumentElement.SelectSingleNode("./app") == null)
                {
                    return;
                }

                string strFile = xDoc.DocumentElement.SelectSingleNode("./app").Attributes.GetNamedItem("val").Value.Trim();

                System.Diagnostics.Process p = new System.Diagnostics.Process();

                p.StartInfo.WorkingDirectory = strFile;
                p.StartInfo.FileName         = "bengzhan.exe";
                //Info.WorkingDirectory
                p.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }