Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            List <ChengXuHaoModel> chengXuHaoModels = sql.GetDataTable <ChengXuHaoModel>("select * from ChengXuHao");

            foreach (var item in ChengXuHaoModels)
            {
                if (item.XingHao == this.txtXingHao.Text)
                {
                    MessageBox.Show("型号已存在");
                    return;
                }
                if (item.ChengXuHao == this.txtChengXuHao.Text)
                {
                    MessageBox.Show("程序号已存在");
                    return;
                }
            }
            string commandtext = string.Format("insert into ChengXuHao (ChengXuHao,XingHao,AddTime,WuLiaoBianHao) values ('{0}','{1}','{2}','{3}')", this.txtChengXuHao.Text, this.txtXingHao.Text, DateTime.Now.ToString(), this.txtWuLiaoBianHao.Text);

            if (sql.Execute(commandtext))
            {
                MessageBox.Show("添加成功");
            }
            else
            {
                MessageBox.Show("添加失败");
            }
            RefreshRecords();
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.txtSim.Text) || string.IsNullOrEmpty(this.txtUserName.Text))
            {
                MessageBox.Show("用户名称或SIM卡号不能为空");
            }

            string commandtext = string.Format("CREATE TABLE[dbo].[yg_{0}]("
                                               + " [记录标示号] int NOT NULL IDENTITY(1,1) ,"
                                               + " [记录时间] datetime NOT NULL ,"
                                               + " [更新时间] datetime NULL,"
                                               + " [记录类型] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL ,"
                                               + " [记录描述] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL ,"
                                               + " [电话号] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,"
                                               + " [瞬时流量] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,"
                                               + " [累积流量] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,"
                                               + " [正累积流量] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,"
                                               + "PRIMARY KEY([记录标示号]))", this.txtSim.Text);
            SqlHelper sql = new SqlHelper();

            sql.Open();
            Console.WriteLine(sql.TestConn);
            if (!sql.Execute(commandtext))
            {
                MessageBox.Show("创建失败!");
                return;
            }
            commandtext = string.Format("select * FROM ConnectionSet1 ORDER BY 序号 DESC");
            DataTable dataTable = accessHelper.GetDataTable(commandtext);

            if (dataTable == null)
            {
                return;
            }
            List <int> IDS = new List <int>();

            foreach (DataRow dr in dataTable.Rows)
            {
                IDS.Add(int.Parse(dr["序号"].ToString()));
            }
            int ID = IDS.Max();

            ID += 1;
            Console.WriteLine(this.cmbZuZhiJiGou.Text);
            commandtext = string.Format("Insert Into ConnectionSet1" +
                                        " (序号,组织机构,仪表编号,用户名称,SIM卡号,仪表型号,初装日期)" +
                                        " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", ID, this.cmbZuZhiJiGou.Text, this.txtSim.Text
                                        , this.txtUserName.Text, this.txtSim.Text, this.cmbInstrumentType.Text, DateTime.Now);
            if (!accessHelper.Execute(commandtext))
            {
                MessageBox.Show("Access添加失败");
                return;
            }
            MessageBox.Show("创建成功!");
            IniHuiZhongModels();
        }
Ejemplo n.º 3
0
        private void lstTags_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            string selectedText = (sender as ListBox).SelectedItem.ToString();
            string commandtext  = string.Format("INSERT INTO [OPCConfig] (Name) values ('{0}')", selectedText);

            if (access.Execute(commandtext))
            {
                this.lstAddedTags.Items.Add(selectedText);
                opcHelper.AddItem(selectedText);
            }
        }
Ejemplo n.º 4
0
        private void Register_Click(object sender, RoutedEventArgs e)
        {
            if (this.UserName.Text == "" || this.PassWord.Text == "")
            {
                MessageBox.Show("用户名和密码不能为空");
            }
            string           commandText = "SELECT * FROM [User]";
            List <UserModel> users       = sql.GetDataTable <UserModel>(commandText);

            foreach (var item in users)
            {
                if (item.UserName == this.UserName.Text)
                {
                    MessageBox.Show("用户名已存在");
                    return;
                }
            }
            commandText = string.Format("insert into [User] ([UserName],[PassWord],[Authority]) values ('{0}','{1}','{2}')", this.UserName.Text, this.PassWord.Text, this.cmbVerify.SelectedValue.ToString());
            bool result = sql.Execute(commandText);

            if (result)
            {
                SimpleLogHelper.Instance.WriteLog(LogType.Info, "注册新用户成功");
                MessageBox.Show("注册新用户成功");
            }
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            string commandtext = string.Format("UPDATE [OPCConfig] SET [info]='{0}' WHERE Name='{1}'", this.txbInfo.Text, this.txbTags.Text);

            if (!access.Execute(commandtext))
            {
                MessageBox.Show("保存失败");
            }
        }
Ejemplo n.º 6
0
        //public ProtocolFactory.ProtocolName AnalysisPhoneBelongWitchProtocol(string PhoneNum)
        //{
        //    var model = this.ConnectionModels.Where(m => m.PhoneNum == PhoneNum).FirstOrDefault();
        //    if (model != null)
        //    {
        //        switch (model.ProtocolType)
        //        {
        //            case "积算仪_AORY5000":
        //                return ProtocolFactory.ProtocolName.AutecAory5000;
        //            case "积算仪_新":
        //                return ProtocolFactory.ProtocolName.AutecNewModbusRtu;
        //            case "积算仪_老":
        //                return ProtocolFactory.ProtocolName.AutecOldModbusRtu;
        //            case "SCL_61D0":
        //                return ProtocolFactory.ProtocolName.HuiZhongSCL_61D;
        //            default:
        //                return ProtocolFactory.ProtocolName.NoFind;
        //        }
        //    }
        //    else
        //    {
        //        return ProtocolFactory.ProtocolName.NoFind;
        //    }
        //}

        public bool UpDateRecord(string PhoneNum, DateTime CollectTime)
        {
            bool result;

            try
            {
                string sql = string.Format("UpDate ConnectionSet1 set CollectTime='{0}' where SIM卡号='{1}';", CollectTime, PhoneNum);
                result = accessHelper.Execute(sql);
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Ejemplo n.º 7
0
        private void btnInsert_Click(object sender, RoutedEventArgs e)
        {
            string commandText = "Insert into model ([BianHao],[AddTime1]) values ('123','234')";

            Console.WriteLine(accessHelper.Execute(commandText));
        }