private void button_del_Click(object sender, EventArgs e)
        {
            rowNum = getRow();//获取datagriadview行号
            string nodeName = dataGridView1.Rows[rowNum].Cells["Device_Name"].Value.ToString();

            if (dataGridView1.CurrentCell.RowIndex >= 0)
            {
                if (MessageBox.Show("你确定要删除吗?", "确定", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string sql = "DELETE FROM device  WHERE Device_ID = ";
                    sql += "'" + dataGridView1.Rows[rowNum].Cells[0].Value.ToString() + "'";

                    dbMySql.Open(databaseName);
                    dbMySql.ExcuteNonQuery(databaseName, sql);
                    dbMySql.Close(databaseName);
                    deleteRow(rowNum);
                    dataGridView1.Update();


                    TreeExXML.TreeExXMLCls xt2 = new TreeExXML.TreeExXMLCls();
                    xt2.DeleteXmlNodeByXPath("D:\\MyVidio\\myxml.xml", null, nodeName);


                    fath.ReloadTreeView();
                }
                else
                {
                    MessageBox.Show("没有选中的记录,请选择!");
                }
            }
        }
Ejemplo n.º 2
0
        public bool UpLoad(byte[] buffer, string deviceid)
        {
            DETECTION_INFO detInfo     = new DETECTION_INFO();//共计866字节
            object         detinfoType = detInfo;
            TastInfo       Tinfo       = new TastInfo();

            Tinfo.ByteArrayToStructureEndian(buffer, ref detinfoType, 0);
            detInfo = (DETECTION_INFO)detinfoType;


            //写入数据库
            string batch_id = System.Text.Encoding.UTF8.GetString(detInfo.batch_id, 0, GetLen(detInfo.batch_id)).Trim();
            string task_id  = System.Text.Encoding.UTF8.GetString(detInfo.task_id, 0, GetLen(detInfo.task_id)).Trim();
            //             UInt64 batch_id = detInfo.batch_id;
            //             UInt32 task_id = detInfo.task_id;
            string p_name          = System.Text.Encoding.UTF8.GetString(detInfo.p_name, 0, GetLen(detInfo.p_name)).Trim();
            string type            = System.Text.Encoding.UTF8.GetString(detInfo.type, 0, GetLen(detInfo.type));
            int    channel         = (int)detInfo.channel;
            string ftest_result    = System.Text.Encoding.UTF8.GetString(detInfo.ftest_result, 0, GetLen(detInfo.ftest_result)).Trim();
            string test_result     = System.Text.Encoding.UTF8.GetString(detInfo.test_result, 0, GetLen(detInfo.test_result)).Trim();
            string result_unit     = System.Text.Encoding.UTF8.GetString(detInfo.result_unit, 0, GetLen(detInfo.result_unit)).Trim();
            string standard        = System.Text.Encoding.UTF8.GetString(detInfo.standard, 0, GetLen(detInfo.standard)).Trim();
            string abs_result      = System.Text.Encoding.UTF8.GetString(detInfo.abs_result, 0, GetLen(detInfo.abs_result)).Trim();
            string sample_no       = System.Text.Encoding.UTF8.GetString(detInfo.sample_no, 0, GetLen(detInfo.sample_no)).Trim();
            string sample_name     = System.Text.Encoding.UTF8.GetString(detInfo.sample_name, 0, GetLen(detInfo.sample_name)).Trim();
            string sites           = System.Text.Encoding.UTF8.GetString(detInfo.sites, 0, GetLen(detInfo.sites)).Trim();
            string submission_unit = System.Text.Encoding.UTF8.GetString(detInfo.submission_unit, 0, GetLen(detInfo.submission_unit)).Trim();
            string test_operator   = System.Text.Encoding.UTF8.GetString(detInfo.test_operator, 0, GetLen(detInfo.test_operator)).Trim();
            string test_unit       = System.Text.Encoding.UTF8.GetString(detInfo.test_unit, 0, GetLen(detInfo.test_unit)).Trim();
            string test_time       = System.Text.Encoding.UTF8.GetString(detInfo.test_time, 0, GetLen(detInfo.test_time)).Trim();
            // DateTime dt = DateTime.ParseExact(test_time, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
            int User_Id = 1234;

            if (deviceid != null)
            {
                User_Id = int.Parse(deviceid);
            }

            string strsql = "Insert Into " +
                            "detectioninfo(batch_id,task_id,p_name,type,channel,Juge_result,Detect_result,result_unit,standard,Absolut_result,sample_no,sample_name,sites,submission_unit,test_operator,test_unit,test_time,Device_ID)"
                            + "values('" + batch_id + "','" + task_id + "','" + p_name + "','" + type + "'," + channel + ",'" + ftest_result + "','" + test_result + "','" + result_unit + "','" + standard + "','" + abs_result + "','" + sample_no + "','" + sample_name + "','" + sites + "','" + submission_unit + "','" + test_operator + "','" + test_unit + "','" + test_time + "'," + User_Id + ")";

            try
            {
                dbMySql.Open(databasename);
                dbMySql.ExcuteNonQuery(databasename, strsql);
                dbMySql.Close(databasename);
                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
        private void button_Del_Click(object sender, EventArgs e)
        {
            int rowNum = getRow();

            if (dataGridView1.CurrentCell.RowIndex >= 0)
            {
                if (MessageBox.Show("你确定要删除吗?", "确定", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string sql = "DELETE FROM ftinfor  WHERE id = '" + tinfoid + "' ";

                    dbMySql.Open(databaseName);
                    dbMySql.ExcuteNonQuery(databaseName, sql);
                    dbMySql.Close(databaseName);
                    deleteRow(rowNum);
                    dataGridView1.Update();
                }
                else
                {
                    MessageBox.Show("没有选中的记录,请选择!");
                }
            }
        }
Ejemplo n.º 4
0
        private void button_Del_Click(object sender, EventArgs e)
        {
            rowNum = getRow();//获取datagriadview行号
            if (dataGridView1.CurrentCell.RowIndex >= 0)
            {
                if (MessageBox.Show("你确定要删除吗?", "确定", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string sql = "DELETE FROM companyinfo  WHERE Company_ID = ";
                    sql += "'" + dataGridView1.Rows[rowNum].Cells[0].Value.ToString() + "'";

                    dbMySql.Open();
                    dbMySql.ExcuteNonQuery(databaseName, sql);
                    dbMySql.Close();
                    deleteRow(rowNum);
                    dataGridView1.Update();
                }
//                 else
//                 {
//
//                     MessageBox.Show("没有选中的记录,请选择!");
//
//                 }
            }
        }
Ejemplo n.º 5
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            int    id;
            string password;
            string city;
            string mobile;
            string centercode;
            string email;
            string company;
            int    j       = parent.dataGridView1.CurrentCell.RowIndex;
            string tinfoid = parent.dataGridView1.Rows[j].Cells[0].Value.ToString();

            if (parameter.fuc == "update")
            {
                //  ShowAll();
                id         = int.Parse(this.textBox_Account.Text.Trim());
                password   = this.textBox_Code.Text.Trim();
                city       = this.textBox_Address.Text.Trim();
                mobile     = this.textBox_cell.Text.Trim();
                email      = this.textBox_Email.Text.Trim();
                centercode = this.textBox_CeenterCode.Text.Trim();
                company    = this.textBox_Company.Text.Trim();
                strsql     = " UPDATE user set " +
                             " PassWord = '******'," +
                             " City= '" + city + "'," +
                             "  Mobile= '" + mobile + "'," +
                             " Email= '" + email + "'," +
                             " CenterCode= '" + centercode + "'," +
                             " Company= '" + company + "'" +
                             " WHERE User_ID = '" + tinfoid + "'";
            }
            else
            {
                if (string.IsNullOrEmpty(textBox_Account.Text.Trim()))
                {
                    MessageBox.Show("请输入用户账户!");
                    return;
                }
                else
                {
                    DataSet dataSet = new DataSet();
                    string  sql     = "SELECT * FROM user";
                    int     ret     = database.ReadDataBase(sql, "companyinfo", dataSet);

                    if (ret == 0)
                    {
                        foreach (DataRow row in dataSet.Tables["companyinfo"].Rows)
                        {
                            if (row["User_ID"].ToString() == textBox_Account.Text.Trim().ToString())
                            {
                                MessageBox.Show("该账户已经存在,请重新输入!");
                                return;
                            }
                        }
                    }
                }

                // FoodServer.MainForm.m_userId = User_Name;
                id         = int.Parse(this.textBox_Account.Text.Trim());
                password   = this.textBox_Code.Text.Trim();
                city       = this.textBox_Address.Text.Trim();
                mobile     = this.textBox_cell.Text.Trim();
                email      = this.textBox_Email.Text.Trim();
                centercode = this.textBox_CeenterCode.Text.Trim();
                company    = this.textBox_Company.Text.Trim();


                if (DataToRow())
                {
                    strsql = "Insert Into " +
                             "user(User_ID,PassWord,City,Mobile,Email,CenterCode,Company) "
                             + "values(" + id + ",'" + password + "','" + city + "','" + mobile + "','" + email + "','" + centercode + "','" + company + "')";
                }
            }
            dbMySql.Open();
            dbMySql.ExcuteNonQuery(databaseName, strsql);
            dbMySql.Close();
            parent.dataGridView1.Refresh();
            parent.re_Load();
            this.Close();
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string         strsql;
            FINFOR_INFOSTR ftinfostr = new FINFOR_INFOSTR();
            int            j         = parent.dataGridView1.CurrentCell.RowIndex;

            ftinfostr.ftesttimes  = parent.dataGridView1.Rows[j].Cells[1].Value.ToString();
            ftinfostr.fsample     = parent.dataGridView1.Rows[j].Cells[2].Value.ToString();
            ftinfostr.wavemode    = parent.dataGridView1.Rows[j].Cells[3].Value.ToString();
            ftinfostr.wavemajor   = parent.dataGridView1.Rows[j].Cells[4].Value.ToString();
            ftinfostr.waveminor   = parent.dataGridView1.Rows[j].Cells[5].Value.ToString();
            ftinfostr.formulaC    = parent.dataGridView1.Rows[j].Cells[6].Value.ToString();
            ftinfostr.formulaB    = parent.dataGridView1.Rows[j].Cells[7].Value.ToString();
            ftinfostr.formulaA    = parent.dataGridView1.Rows[j].Cells[8].Value.ToString();
            ftinfostr.interdilute = parent.dataGridView1.Rows[j].Cells[9].Value.ToString();
            ftinfostr.unit        = parent.dataGridView1.Rows[j].Cells[10].Value.ToString();
            ftinfostr.standards   = parent.dataGridView1.Rows[j].Cells[11].Value.ToString();
            ftinfostr.comparemode = parent.dataGridView1.Rows[j].Cells[12].Value.ToString();
            ftinfostr.comparemin  = parent.dataGridView1.Rows[j].Cells[13].Value.ToString();
            ftinfostr.comparemax  = parent.dataGridView1.Rows[j].Cells[14].Value.ToString();
            ftinfostr.tesrangemax = parent.dataGridView1.Rows[j].Cells[15].Value.ToString();
            ftinfostr.tesrangemin = parent.dataGridView1.Rows[j].Cells[16].Value.ToString();

            ftinfostr.red    = parent.dataGridView1.Rows[j].Cells[17].Value.ToString();
            ftinfostr.pitch  = parent.dataGridView1.Rows[j].Cells[18].Value.ToString();
            ftinfostr.yellow = parent.dataGridView1.Rows[j].Cells[19].Value.ToString();

            string tinfoid = parent.dataGridView1.Rows[j].Cells[0].Value.ToString();

            if (parameter.fuc == "update")
            {
                ftinfostr.ftesttimes  = this.textBox_ftesttimes.Text.Trim();
                ftinfostr.fsample     = this.textBox2.Text.Trim();
                ftinfostr.wavemode    = this.textBox3.Text.Trim();
                ftinfostr.wavemajor   = this.textBox4.Text.Trim();
                ftinfostr.waveminor   = this.textBox5.Text.Trim();
                ftinfostr.formulaC    = this.textBox6.Text.Trim();
                ftinfostr.formulaB    = this.textBox7.Text.Trim();
                ftinfostr.formulaA    = this.textBox8.Text.Trim();
                ftinfostr.interdilute = this.textBox9.Text.Trim();
                ftinfostr.unit        = this.textBox10.Text.Trim();
                ftinfostr.standards   = this.textBox11.Text.Trim();
                ftinfostr.comparemode = this.textBox12.Text.Trim();
                ftinfostr.comparemin  = this.textBox13.Text.Trim();
                ftinfostr.comparemax  = this.textBox14.Text.Trim();
                ftinfostr.tesrangemax = this.textBox15.Text.Trim();
                ftinfostr.tesrangemin = this.textBox16.Text.Trim();
                ftinfostr.red         = this.textBox_red.Text.Trim();
                ftinfostr.pitch       = this.textBox1_pitch.Text.Trim();
                ftinfostr.yellow      = this.textBox1_yellow.Text.Trim();
                strsql = " UPDATE ftinfor set " +
                         " ftestitems = '" + ftinfostr.ftesttimes + "'," +
                         " fsample = '" + ftinfostr.fsample + "'," +
                         " wavemode = '" + ftinfostr.wavemode + "'," +
                         " wavemajor = '" + ftinfostr.wavemajor + "'," +
                         " waveminor = '" + ftinfostr.waveminor + "'," +
                         " formulaC = '" + ftinfostr.formulaC + "'," +
                         " formulaB = '" + ftinfostr.formulaB + "'," +
                         " formulaA = '" + ftinfostr.formulaA + "'," +
                         " interdilute = '" + ftinfostr.interdilute + "'," +
                         " unit = '" + ftinfostr.unit + "'," +
                         " standards = '" + ftinfostr.standards + "'," +
                         " comparemode = '" + ftinfostr.comparemode + "'," +
                         " comparemin = '" + ftinfostr.comparemin + "'," +
                         " comparemax = '" + ftinfostr.comparemax + "'," +
                         " testrangemax = '" + ftinfostr.tesrangemax + "'," +
                         " testrangemin = '" + ftinfostr.tesrangemin + "'," +
                         " alarm_red = '" + ftinfostr.red + "'," +
                         " alarm_pitch = '" + ftinfostr.pitch + "'," +
                         " alarm_yellow = '" + ftinfostr.yellow + "'" +
                         " WHERE id = '" + tinfoid + "'";
            }
            else
            {
                ftinfostr.ftesttimes  = this.textBox_ftesttimes.Text.Trim();
                ftinfostr.fsample     = this.textBox2.Text.Trim();
                ftinfostr.wavemode    = this.textBox3.Text.Trim();
                ftinfostr.wavemajor   = this.textBox4.Text.Trim();
                ftinfostr.waveminor   = this.textBox5.Text.Trim();
                ftinfostr.formulaC    = this.textBox6.Text.Trim();
                ftinfostr.formulaB    = this.textBox7.Text.Trim();
                ftinfostr.formulaA    = this.textBox8.Text.Trim();
                ftinfostr.interdilute = this.textBox9.Text.Trim();
                ftinfostr.unit        = this.textBox10.Text.Trim();
                ftinfostr.standards   = this.textBox11.Text.Trim();
                ftinfostr.comparemode = this.textBox12.Text.Trim();
                ftinfostr.comparemin  = this.textBox13.Text.Trim();
                ftinfostr.comparemax  = this.textBox14.Text.Trim();
                ftinfostr.tesrangemax = this.textBox15.Text.Trim();
                ftinfostr.tesrangemin = this.textBox16.Text.Trim();
                ftinfostr.red         = this.textBox_red.Text.Trim();
                ftinfostr.pitch       = this.textBox1_pitch.Text.Trim();
                ftinfostr.yellow      = this.textBox1_yellow.Text.Trim();



                strsql = "Insert Into " +
                         "ftinfor (ftestitems,fsample,wavemode,wavemajor,waveminor,formulaC,formulaB,formulaA,interdilute,unit,standards,comparemode,comparemin,comparemax,testrangemax,testrangemin,alarm_red, alarm_pitch, alarm_yellow)"
                         + "values('" + ftinfostr.ftesttimes + "','" + ftinfostr.fsample + "','" + ftinfostr.wavemode + "','" + ftinfostr.wavemajor + "','" + ftinfostr.waveminor + "','" + ftinfostr.formulaC + "','" + ftinfostr.formulaB + "','" + ftinfostr.formulaA + "',"
                         + " '" + ftinfostr.interdilute + "','" + ftinfostr.unit + "', '" + ftinfostr.standards + "','" + ftinfostr.comparemode + "',"
                         + " '" + ftinfostr.comparemin + "','" + ftinfostr.comparemax + "',  '" + ftinfostr.tesrangemax + "', '" + ftinfostr.tesrangemin + "',"
                         + "'" + ftinfostr.red + "', '" + ftinfostr.pitch + "', '" + ftinfostr.yellow + "')";
            }
            dbMySql.Open(databaseName);
            dbMySql.ExcuteNonQuery(databaseName, strsql);
            dbMySql.Close(databaseName);
            parent.dataGridView1.Refresh();
            parent.LoadConfigInfo();
            this.Close();
        }
Ejemplo n.º 7
0
        private void button_ok_Click(object sender, EventArgs e)
        {
            ToolTip tt = new ToolTip();

            tt.IsBalloon = true;       //如果false就是一个方块型的提示框
            tt.SetToolTip(this.textBox_name, "请输入非数字名称!");
            tt.Show("请输入非数字名称!", this.textBox_name);
            // return;



            if (parameter.fuc == "update")
            {
                string strsql = "Update device SET "
                                + "Device_ID = '" + textBox_ID.Text.ToString() + "',"
                                + "Device_PassWord = '******',"
                                + "Device_Code = '" + textBox_Code.Text.ToString() + "',"
                                + "Device_Name = '" + textBox_name.Text.ToString() + "',"
                                + "Device_Addr = '" + textBox_Addr.Text.ToString() + "',"
                                + "Device_Type = '" + textBox_Type.Text.ToString() + "',"
                                + "Device_Ver = '" + textBox_version.Text.ToString() + "'"
                                + "WHERE Device_ID = " + IDNum + "";

                dbMySql.Open(databasename);
                dbMySql.ExcuteNonQuery(databasename, strsql);
                dbMySql.Close(databasename);
                this.Close();
                parent.Device_Load();
                newDeviceName     = textBox_name.Text.ToString();
                this.DialogResult = DialogResult.OK;
                MessageBox.Show("修改成功");
            }
            else
            {
                if (string.IsNullOrEmpty(textBox_name.Text.Trim()))
                {
                    MessageBox.Show("请输入终端名称!");
                    return;
                }
                else
                {
                    DataSet dataSet = new DataSet();
                    string  sql     = "SELECT * FROM device";
                    int     ret     = database.ReadDataBase(sql, "device", dataSet);
                    FoodServer.MainForm.m_csName = this.textBox_name.Text.Trim().ToString();
                    if (ret == 0)
                    {
                        foreach (DataRow row in dataSet.Tables["device"].Rows)
                        {
                            if (row["Device_Name"].ToString() == FoodServer.MainForm.m_csName)
                            {
                                MessageBox.Show("该终端已经存在,请重新输入终端名称!");
                                return;
                            }
                        }
                    }
                }

                // FoodServer.MainForm.m_userId = User_Name;
                FoodServer.MainForm.m_csAddress         = textBox_Addr.Text.Trim().ToString();
                FoodServer.MainForm.m_csDeviceType      = textBox_Type.Text.Trim().ToString();
                FoodServer.MainForm.m_csSoftwareVersion = textBox_version.Text.Trim().ToString();
                int    userid   = 0;
                int    group_id = 0;
                int    x        = 300;
                int    y        = 150;
                string strsql   = "Insert Into " +
                                  "device(Device_Group_ID,Device_Name,device.Device_Addr,device.Device_Type,device.Device_Ver, device.Device_X,device.Device_Y)"
                                  + "values('" + group_id + "','" + FoodServer.MainForm.m_csName + "','" + FoodServer.MainForm.m_csAddress + "','" + FoodServer.MainForm.m_csDeviceType + "','" + FoodServer.MainForm.m_csSoftwareVersion + "'," + x + "," + y + ")";
                try
                {
                    dbMySql.Open(databasename);
                    dbMySql.ExcuteNonQuery(databasename, strsql);
                    dbMySql.Close(databasename);

                    DataSet dataSet1 = new DataSet();
                    string  sql1     = "SELECT * FROM device";
                    int     re       = database.ReadDataBase(sql1, "device2", dataSet1);
                    if (re == 0)
                    {
                        foreach (DataRow r in dataSet1.Tables["device2"].Rows)
                        {
                            if (r["Device_Name"].ToString() == FoodServer.MainForm.m_csName)
                            {
                                userid = int.Parse(r["Device_ID"].ToString());
                            }
                        }
                    }

                    ImagControl mark = new ImagControl();
                    mark.Location   = new Point(150, 150);
                    mark.PicboxShow = "room-b.png";
                    mark.Center     = mark.Location;
                    mark.Cname      = this.textBox_name.Text.ToString();
                    fa.pictureBox1.Controls.Add(mark);
                    fa.treeView1.Refresh();
                    fa.reloadview();

                    // fa.dataGridView1.Refresh();

                    FoodServer.MainForm.DrawInfo line = new FoodServer.MainForm.DrawInfo();
                    line.imc     = mark;
                    line.user_id = userid;
                    line.name    = FoodServer.MainForm.m_csName;
                    fa.Pics.Add(line);
                    fa.PicsSave.Add(line);
                    fa.Redraw(line, mark.Center);

                    mark.MouseUp          += new System.Windows.Forms.MouseEventHandler(fa.Mouse_Up);
                    mark.MouseDown        += new System.Windows.Forms.MouseEventHandler(fa.MouseDown);
                    mark.MouseMove        += new System.Windows.Forms.MouseEventHandler(fa.MouseMove);
                    mark.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(fa.MouseDoubleClick);
                    mark.MouseHover       += new System.EventHandler(fa.MouseHover);
                    //Adds Line object to an arraylist
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                this.DialogResult = DialogResult.OK;
            }

            this.Close();
        }
Ejemplo n.º 8
0
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void RecvData(object sender, NetEventArgs e)
        {
            //  string info = string.Format("recv data:{0} from:{1}.", e.Client.Datagram, e.Client);
            TcpSvr svr = (TcpSvr)sender;

            byte[] recivebuffer = System.Text.Encoding.UTF8.GetBytes(e.Client.Datagram);
            byte[] buffer       = new byte[MsgHeadLength];
            Array.Copy(recivebuffer, 1, buffer, 0, MsgHeadLength);
            TastInfo Info     = new TastInfo();
            MSGHEAD  head     = new MSGHEAD();
            object   headType = head;

            Info.ByteArrayToStructureEndian(buffer, ref headType, 0);
            head = (MSGHEAD)headType;
            string centercode = head.Msg_GNSSCenter.ToString();

            switch (head.Msg_ID)
            {
            //用于心跳监测
            case 03:
                svr.SendMessage(e.Client, "", 0x0004, centercode);
                // svr.SendMessage(e.Client, "", 0x0003, centercode);
                break;
            //检测结果上传消息
            //TEST NUM	4	Unint32_t	结果个数
            //TEST INFO	804	Octet_string	检测结果信息

            case 06:
                byte[] test_num = new byte[4];
                Array.Copy(recivebuffer, MsgHeadLength + 1, test_num, 0, 4);
                Array.Reverse(test_num);

                UInt32 num     = (UInt32)BitConverter.ToInt32(test_num, 0);
                byte[] buffer3 = new byte[head.Msg_Length - 18 - 4];
                Array.Copy(recivebuffer, MsgHeadLength + 1 + 4, buffer3, 0, head.Msg_Length - 18 - 4);
                DETECTION_INFO detInfo     = new DETECTION_INFO();
                object         detInfoType = detInfo;

                Info.ByteArrayToStructureEndian(buffer3, ref detInfoType, 0);
                detInfo = (DETECTION_INFO)detInfoType;

//                     DataTable tbInfo = LoadDetectionInfo();
//                     DataSet ds = new DataSet();
//
//                     DataRow r = tbInfo.NewRow();
//                     r["p_name"] = System.Text.Encoding.UTF8.GetString(detInfo.p_name, 0, GetLen(detInfo.p_name)).Trim();
//                     r["sample_name"] = System.Text.Encoding.UTF8.GetString(detInfo.sample_name,0,GetLen(detInfo.sample_name)).Trim();
//                     r["channel"] = detInfo.channel;
//                     r["type"] = System.Text.Encoding.UTF8.GetString(detInfo.type, 0, GetLen(detInfo.type));
//                     r["standard"] = System.Text.Encoding.UTF8.GetString(detInfo.standard, 0, GetLen(detInfo.standard));
//                     r["sample_no"] = System.Text.Encoding.UTF8.GetString(detInfo.sample_no, 0, GetLen(detInfo.sample_no)).Trim();
//                     r["sites"] = System.Text.Encoding.UTF8.GetString(detInfo.sites, 0, GetLen(detInfo.sites)).Trim();
//                     r["submission_unit"] = System.Text.Encoding.UTF8.GetString(detInfo.submission_unit, 0, GetLen(detInfo.submission_unit));
//                     r["test_operator"] = System.Text.Encoding.UTF8.GetString(detInfo.test_operator, 0, GetLen(detInfo.test_operator));
//
//                     r["test_unit"] = System.Text.Encoding.UTF8.GetString(detInfo.test_unit, 0, GetLen(detInfo.test_unit));
//                     r["test_time"] = System.Text.Encoding.UTF8.GetString(detInfo.test_time, 0, GetLen(detInfo.test_time));
//
//                     r["User_Id"] = e.Client.UserId;
//
//                     //并将数据写入到数据库
//                     tbInfo.Rows.Add(r);

                string   p_name          = System.Text.Encoding.UTF8.GetString(detInfo.p_name, 0, GetLen(detInfo.p_name)).Trim();
                string   sample_name     = System.Text.Encoding.UTF8.GetString(detInfo.sample_name, 0, GetLen(detInfo.sample_name)).Trim();
                int      channel         = (int)detInfo.channel;
                string   type            = System.Text.Encoding.UTF8.GetString(detInfo.type, 0, GetLen(detInfo.type));
                string   standard        = System.Text.Encoding.UTF8.GetString(detInfo.standard, 0, GetLen(detInfo.standard));
                string   sample_no       = System.Text.Encoding.UTF8.GetString(detInfo.sample_no, 0, GetLen(detInfo.sample_no)).Trim();
                string   sites           = System.Text.Encoding.UTF8.GetString(detInfo.sites, 0, GetLen(detInfo.sites)).Trim();
                string   submission_unit = System.Text.Encoding.UTF8.GetString(detInfo.submission_unit, 0, GetLen(detInfo.submission_unit));
                string   test_operator   = System.Text.Encoding.UTF8.GetString(detInfo.test_operator, 0, GetLen(detInfo.test_operator));
                string   test_unit       = System.Text.Encoding.UTF8.GetString(detInfo.test_unit, 0, GetLen(detInfo.test_unit));
                string   test_time       = System.Text.Encoding.UTF8.GetString(detInfo.test_time, 0, GetLen(detInfo.test_time));
                DateTime dt      = DateTime.ParseExact(test_time, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
                int      User_Id = (int)e.Client.UserId;
                string   strsql  = "Insert Into " +
                                   "detectioninfo(p_name,sample_name,channel,type,standard,sample_no,sites,submission_unit,test_operator,test_unit,test_time,User_Id)"
                                   + "values('" + p_name + "','" + sample_name + "'," + channel + ",'" + type + "','" + standard + "','" + sample_no + "','" + sites + "','" + submission_unit + "','" + test_operator + "','" + test_unit + "','" + test_time + "'," + User_Id + ")";

                dbMySql.Open(databaseName);
                dbMySql.ExcuteNonQuery(databaseName, strsql);
                dbMySql.Close(databaseName);

                break;

            case 09:
                //视频上传
                svr.SendMessage(e.Client, 0, 0x000a, centercode);
                break;

            case 0x000e:
                //远程状态和工作参数查询应答消息
                //具体参数不明确
                break;


            default:
                break;
            }


            //测试把收到的数据返回给客户端
            //svr.SendText(e.Client, e.Client.Datagram);
            //MessageBox.Show(message.ToString());


            //svr.SendFile(this.textBox1.Text);
        }
Ejemplo n.º 9
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            if (textBox_Name.Text == "")
            {
                MessageBox.Show("请输入送检单位名称!");
                return;
            }
            string strsql;

            if (parameter.fuc == "update")
            {
                strsql = "Update companyinfo SET "
                         + "Company_Name = '" + textBox_Name.Text.ToString() + "',"
                         + "Company_Addr = '" + textBox_Addre.Text.ToString() + "',"
                         + "Company_Email = '" + textBox_Email.Text.ToString() + "',"
                         + "Company_Class = '" + textBox_Class.Text.ToString() + "',"
                         + "Company_Tel = '" + textBox_Tel.Text.ToString() + "'"
                         + "WHERE Company_ID = " + IDNum + "";
            }
            else
            {
                if (string.IsNullOrEmpty(textBox_Name.Text.Trim()))
                {
                    MessageBox.Show("请输入终端名称!");
                    return;
                }
                else
                {
                    DataSet dataSet = new DataSet();
                    string  sql     = "SELECT * FROM companyinfo";
                    int     ret     = database.ReadDataBase(sql, "companyinfo", dataSet);

                    if (ret == 0)
                    {
                        foreach (DataRow row in dataSet.Tables["companyinfo"].Rows)
                        {
                            if (row["Company_Name"].ToString() == textBox_Name.Text.Trim().ToString())
                            {
                                MessageBox.Show("该送检单位已经存在,请重新输入送检单位!");
                                return;
                            }
                        }
                    }
                }

                // FoodServer.MainForm.m_userId = User_Name;
                string Name  = textBox_Name.Text.Trim().ToString();
                string Addr  = textBox_Addre.Text.Trim().ToString();
                string email = textBox_Email.Text.Trim().ToString();
                string Tel   = textBox_Tel.Text.Trim().ToString();
                string Clas  = textBox_Class.Text.Trim().ToString();

                strsql = "Insert Into " +
                         "companyinfo(Company_Name,Company_Addr,Company_Tel,Company_Email,Company_Class)"
                         + "values('" + Name + "','" + Addr + "','" + Tel + "','" + email + "','" + Clas + "')";
            }
            dbMySql.Open(databaseName);
            dbMySql.ExcuteNonQuery(databaseName, strsql);
            dbMySql.Close(databaseName);
            this.Close();
            parent.Unit_Load();
            //MessageBox.Show("修改成功");
        }