示例#1
0
        private void btn_savehospital_Click(object sender, EventArgs e)
        {
            if (this.txthospitalname.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入医院名称!", "系统提示!");
                this.txthospitalname.Focus();
                return;
            }
            if (this.txtdepartment.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入科室名称!", "系统提示!");
                this.txtdepartment.Focus();
                return;
            }

            HospitalInfo objHospitalInfo = new HospitalInfo();

            objHospitalInfo.Department   = this.txtdepartment.Text.Trim();
            objHospitalInfo.HospitalName = this.txthospitalname.Text.Trim();
            addhospitalinfo(objHospitalInfo);
            int res = objHospitalInfoService.AddHospitalInfo(objHospitalInfo);

            if (res > 0)
            {
                MessageBox.Show("添加成功!", "系统提示!");
            }
        }
        private void btnset_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Trim().Length == 0 || this.textBox2.Text.Trim().Length == 0)
            {
                MessageBox.Show("请输入正确信息!", "系统提示!");
                this.textBox1.Focus();
                return;
            }
            DataHelper.HospitalNameflag              = 0;
            DataHelper.CommandWriteHospitalName[4]   = 0x30;
            DataHelper.CommandWriteDepartmentName[4] = 0x70;
            DataHelper.HospitalName   = null;
            DataHelper.DepartmentName = null;
            timer1.Start();
            this.btnset.Enabled         = false;
            this.btngethospiyal.Enabled = false;
            string str3 = this.textBox1.Text.Trim();
            string str  = this.textBox2.Text.Trim();

            objHospitalInfoService.AddHospitalInfo(AddHospitalInfo(str3, str));

            DataHelper.HospitalName   = System.Text.Encoding.Unicode.GetBytes(str3);
            DataHelper.DepartmentName = System.Text.Encoding.Unicode.GetBytes(str);
            DataHelper.Flag           = 18;
            DataHelper.CommandWriteHospitalName[11] = DataHelper.HospitalName[DataHelper.HospitalNameflag];
            try
            {
                if (this.usbhid3.SpecifiedDevice != null)
                {
                    //   Thread.Sleep(50);
                    this.usbhid3.SpecifiedDevice.SendData(DataHelper.WriteHospitalNameData());
                }
                else
                {
                    MessageBox.Show("请插入设备! ");
                }
            }
            catch (Exception ex)
            {
                SQLiteHelper.WriteLog("  private void btnset_Click(object sender, EventArgs e)", ex.Message);
                // MessageBox.Show(ex.ToString());
            }
            DataHelper.HospitalNameflag++;
            this.textBox1.Text = "";
            this.textBox2.Text = "";
        }