コード例 #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (dataGridView1.Columns[e.ColumnIndex].HeaderText == "打印")
                {
                    int ret = 0;
                    try
                    {
                        ret = Program.openport("Gprinter GP-3120TU");                                           //Open specified printer driver
                        if (ret < 1)
                        {
                            return;
                        }

                        if (dataGridView1.Columns[0].HeaderText != "证书编号" || dataGridView1.Columns[1].HeaderText != "姓名" || dataGridView1.Columns[9].HeaderText != "发证日期")
                        {
                            MessageBox.Show("异常情况,请重新打开软件再尝试");
                            return;
                        }
                        string print1 = "姓名:" + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();    //
                        MajorLog.Info(print1);


                        MajorLog.Info(dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString());
                        MajorLog.Info(dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString().Substring(2, 8));

                        string print2 = "发证日期:" + dataGridView1.Rows[e.RowIndex].Cells[9].Value.ToString().Substring(2, 8);


                        string print3 = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
                        MajorLog.Info(print3);

                        DialogResult dr = MessageBox.Show(print1 + "\n" + print2 + "\n" + print3, "是否打印", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        if (dr == DialogResult.OK)
                        {
                            ret = Program.setup("30", "17", "6", "10", "0", "1", "0");                       //Setup the media size and sensor type info
                            ret = Program.clearbuffer();                                                     //Clear image buffer                                                                                                         //    ret = TSCLIB_DLL.barcode("0", "0", "128", "10", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
                            ret = Program.printerfont("0", "24", "TSS24.BF2", "0", "1", "1", print1);        //Drawing printer font
                            ret = Program.printerfont("0", "56", "TSS24.BF2", "0", "1", "1", print2);        //Drawing printer font
                            ret = Program.printerfont("0", "88", "TSS24.BF2", "0", "1", "1", print3);        //Drawing printer font
                            ret = Program.printlabel("1", "1");                                              //Print labels
                            ret = Program.closeport();
                        }
                        else
                        {
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("异常情况,无法正常打印标签!" + ex.Message);
                        MajorLog.Info("打码机未连接或出现异常情况,无法正常打印标签!" + ex.ToString());
                    }
                }
            }
        }
コード例 #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     ret = Function.Genuserkey();//产生用户密钥对
     if (ret > 0)
     {
         MajorLog.Debug("产生用户密钥对--成功");
     }
     else
     {
         MajorLog.Debug("产生用户密钥对--失败");
     }
     textBox1.Text = "产生用户密钥对--成功";
 }
コード例 #3
0
        private void button8_Click(object sender, EventArgs e)
        {
            string strGet2 = textBox1.Text;

            ret = Function.Importcert(strGet2);
            if (ret > 0)
            {
                MajorLog.Debug("写入用户证书--成功");
            }
            else
            {
                MajorLog.Debug("写入用户证书--失败");
            }
        }
コード例 #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (rdo_new.Checked)
            {
                if ((!Regex.IsMatch(textBox_id.Text, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", RegexOptions.IgnoreCase)))
                {
                    label_id.Visible      = true;
                    label_firstID.Visible = true;
                }
                else
                {
                    label_id.Visible      = false;
                    label_firstID.Visible = false;

                    textBox_appkey.Text = 'a' + textBox_id.Text.Substring(textBox_id.Text.Length - 6, 6);
                }
            }
            else
            {
                string CmdStr = "SELECT app密码 FROM tableall WHERE `身份证号`= @CertID";
                if (Function.UseDataBase != 0)
                {
                    using (MySqlConnection con = new MySqlConnection(SQLClass.connsql))
                        using (MySqlCommand cmd = new MySqlCommand(CmdStr, con))
                        {
                            try
                            {
                                cmd.Parameters.AddWithValue("@CertID", textBox_id.Text);

                                con.Open();
                                object obj = cmd.ExecuteScalar();
                                if (obj != null)
                                {
                                    textBox_appkey.Text = obj.ToString();
                                }
                                else
                                {
                                    MessageBox.Show("数据库中不存在此身份证,请新领证书");
                                }
                                con.Close();
                            }
                            catch (MySqlException ex)
                            {
                                MessageBox.Show(ex.ToString());
                                MajorLog.Error(ex.ToString());
                            }
                        }
                }
            }
        }
コード例 #5
0
        private void button3_Click(object sender, EventArgs e)
        {
            ret = Function.Genrootp10(ref s[0], downCmdRoot);//产生根证书P10
            if (ret > 0)
            {
                MajorLog.Debug("产生根证书P10--成功");
            }
            else
            {
                MajorLog.Debug("产生根证书P10--失败");
            }
            string strGet2 = System.Text.Encoding.Default.GetString(s, 0, s.Length);

            textBox1.Text = strGet2;
        }
コード例 #6
0
        private void button5_Click(object sender, EventArgs e)
        {
            ret = Function.Genrootcer(ref s[0], "FEDCBA9876543210", "20170101000000", "20270101000000", "CN=USER,O=TEST,C=CN", 1);
            //    ret = Function.Genrootcer(ref s[0], CertInfo.OnlyID, startday, endday, downCmdRoot, 1);//产生根证书
            if (ret > 0)
            {
                MajorLog.Debug("产生根证书--成功");
            }
            else
            {
                MajorLog.Debug("产生根证书--失败");
            }
            string strGet2 = System.Text.Encoding.Default.GetString(s, 0, s.Length);

            textBox1.Text = strGet2;
        }
コード例 #7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            MajorLog.Debug("这是一个Debug日志");
            label_age.Visible    = false;
            Function.UseDataBase = int.Parse(ConfigurationManager.AppSettings["UseDataBase"]);

            if (int.Parse(ConfigurationManager.AppSettings["UseCertForm"]) == 1)
            {
                button2.Visible = true;
            }
            else
            {
                button2.Visible = false;
            }

            //MySQLPath
            SQLClass.connsql = @"" + ConfigurationManager.AppSettings["MySQLPath"];

            //SQLClass.connsql = @"server=" + ConfigurationManager.AppSettings["SQLIP"] +
            //    ";Database=dmkeybase;uid=" + ConfigurationManager.AppSettings["SQLNAME"] +
            //    ";pwd=" + ConfigurationManager.AppSettings["SQLPSWD"] +
            //    ";SslMode="+ ConfigurationManager.AppSettings["SSLMODE"];

            dateTimePicker_valid_start.Text = (System.DateTime.Now).ToString("yyyy-MM-dd");
            dateTimePicker_valid_end.Text   = (System.DateTime.Now.AddYears(3)).ToString("yyyy-MM-dd");


            textBox_name.Text         = ConfigurationManager.AppSettings["name"];
            textBox_age.Text          = ConfigurationManager.AppSettings["age"];
            textBox_phone.Text        = ConfigurationManager.AppSettings["phone"];
            textBox_id.Text           = ConfigurationManager.AppSettings["id"];
            textBox_mail.Text         = ConfigurationManager.AppSettings["mail"];
            textBox_project_name.Text = ConfigurationManager.AppSettings["project_name"];
            textBox_appid.Text        = ConfigurationManager.AppSettings["appid"];
            textBox_appkey.Text       = ConfigurationManager.AppSettings["appkey"];

            textBox_company_name.Text    = ConfigurationManager.AppSettings["company_name"];
            textBox_company_phone.Text   = ConfigurationManager.AppSettings["company_phone"];
            textBox_company_address.Text = ConfigurationManager.AppSettings["company_address"];
            textBox_belong_company.Text  = ConfigurationManager.AppSettings["company_belong"];
        }
コード例 #8
0
        private void button2_Click(object sender, EventArgs e)
        {
            int ret = 0;

            try
            {
                ret = Program.openport("Gprinter GP-3120TU");                                           //Open specified printer driver
                if (ret < 1)
                {
                    //     MessageBox.Show("请检查打印机是否就绪!");
                    return;
                }
                string print1 = "姓名:" + CertInfo.name;
                string print2 = "有效期至:" + CertInfo.cert_validity_period_end.Substring(2, 8);
                string print3 = CertInfo.OnlyID;

                ret = Program.setup("30", "17", "6", "10", "0", "1", "0");                       //Setup the media size and sensor type info
                ret = Program.clearbuffer();                                                     //Clear image buffer                                                                                                         //    ret = TSCLIB_DLL.barcode("0", "0", "128", "10", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
                ret = Program.printerfont("0", "24", "TSS24.BF2", "0", "1", "1", print1);        //Drawing printer font
                ret = Program.printerfont("0", "56", "TSS24.BF2", "0", "1", "1", print2);        //Drawing printer font
                ret = Program.printerfont("0", "88", "TSS24.BF2", "0", "1", "1", print3);        //Drawing printer font

                //ret = Program.setup("40", "32", "6", "10", "0", "1", "0");                           //Setup the media size and sensor type info
                //ret = Program.clearbuffer();                                                           //Clear image buffer                                                                                                         //    ret = TSCLIB_DLL.barcode("0", "0", "128", "10", "1", "0", "2", "2", "Barcode Test"); //Drawing barcode
                //ret = Program.printerfont("0", "40", "TSS24.BF2", "0", "1", "1", print1);        //Drawing printer font
                //ret = Program.printerfont("0", "80", "TSS24.BF2", "0", "1", "1", print2);        //Drawing printer font
                //ret = Program.printerfont("0", "120", "TSS24.BF2", "0", "1", "1", print3);        //Drawing printer font

                ret = Program.printlabel("1", "1");                                                    //Print labels
                ret = Program.closeport();
            }
            catch (Exception ex)
            {
                MajorLog.Info("打码机未连接或出现异常情况,无法正常打印标签!" + ex.ToString());
            }
        }
コード例 #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            MajorLog.Debug("点击确认并制证");

            if (button1.Text == "确认并制证")
            {
                #region 制证

                try
                {
                    MajorLog.Debug("开始制证");
                    string downCmd = "CN=USER,O=" + CertInfo.OnlyID + ",C=CN";
                    //  string downCmdRoot = "CN=ROOT,O=TEST,C=CN";
                    byte[] s   = new byte[1024];
                    int    ret = 0;

                    ret = Function.Genuserkey();//产生用户密钥对
                    if (ret == -1)
                    {
                        return;
                    }
                    MajorLog.Info("产生用户密钥对");

                    ret = Function.Genuserp10(ref s[0], downCmd);//产生用户P10
                    if (ret == -1)
                    {
                        return;
                    }
                    MajorLog.Info("产生用户P10");

                    ret = Function.Genusercer(ref s[0], "FEDCBA9876543210", "20170101000000", "20270101000000", downCmd, 1);//产生用户证书
                    MajorLog.Info("产生用户证书");

                    string strGet2 = System.Text.Encoding.Default.GetString(s, 0, s.Length);
                    //    int len = strGet2.Length;
                    //    string downStr = strGet2.Substring(0, len);

                    ret = Function.Importcert(strGet2);
                    if (ret > 0)
                    {
                        MajorLog.Debug("写入证书--成功");
                    }
                    else
                    {
                        MajorLog.Debug("写入证书--失败");
                    }

                    timer1.Enabled = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    MajorLog.Debug(ex.ToString());
                }


                #endregion



                CertInfo.state = "0";
                string CmdStr = "insert into tableall(姓名,性别,年龄,手机号,身份证号,邮箱账号,证书类型,设备类型,发证日期,证书有效期,项目名称,APPID,APP密码,所属单位名称,所属单位电话,所属单位地址,备注,证书编号,状态,设备所属单位) " +
                                "values(@name,@gender, @age, @phone, @id,@mail,@issue_type,@install_type,@issue_day,@valid_period,@project_name,@appid,@appkey,@company_name,@company_phone,@company_address,@remarks,@OnlyID,@state,@belong)";

                if (Function.UseDataBase != 0)
                {
                    using (MySqlConnection con = new MySqlConnection(SQLClass.connsql))
                        using (MySqlCommand cmd = new MySqlCommand(CmdStr, con))
                        {
                            try
                            {
                                cmd.Parameters.AddWithValue("@name", CertInfo.name);
                                cmd.Parameters.AddWithValue("@gender", CertInfo.gender);
                                cmd.Parameters.AddWithValue("@age", CertInfo.age);
                                cmd.Parameters.AddWithValue("@phone", CertInfo.phone);
                                cmd.Parameters.AddWithValue("@id", CertInfo.id);

                                cmd.Parameters.AddWithValue("@mail", CertInfo.email);
                                cmd.Parameters.AddWithValue("@issue_type", CertInfo.issue_type);
                                cmd.Parameters.AddWithValue("@install_type", CertInfo.install_type);
                                cmd.Parameters.AddWithValue("@issue_day", CertInfo.issue_day);
                                cmd.Parameters.AddWithValue("@valid_period", CertInfo.cert_validity_period);
                                cmd.Parameters.AddWithValue("@project_name", CertInfo.project_name);
                                cmd.Parameters.AddWithValue("@appid", CertInfo.appid);
                                cmd.Parameters.AddWithValue("@appkey", CertInfo.appkey);
                                cmd.Parameters.AddWithValue("@company_name", CertInfo.company_name);
                                cmd.Parameters.AddWithValue("@company_phone", CertInfo.company_phone);
                                cmd.Parameters.AddWithValue("@company_address", CertInfo.company_address);
                                cmd.Parameters.AddWithValue("@remarks", CertInfo.remarks);
                                cmd.Parameters.AddWithValue("@OnlyID", CertInfo.OnlyID);
                                cmd.Parameters.AddWithValue("@State", CertInfo.state);
                                cmd.Parameters.AddWithValue("@Belong", CertInfo.company_belong);
                                con.Open();
                                cmd.ExecuteNonQuery();
                                con.Close();

                                button1.Text      = "制证中...";
                                button1.BackColor = Color.Green;
                            }
                            catch (MySqlException ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                }
                else
                {
                    MajorLog.Debug("未使用数据库");
                }
            }
            else
            {
                MessageBox.Show("制证已完成,请关闭此窗口!");
            }
        }
コード例 #10
0
        public int VerifyInfo()
        {
            if (!Regex.IsMatch(textBox_name.Text, @"^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$"))
            {
                label_name.Visible = true;
                return(-1);
            }
            else
            {
                label_name.Visible = false;
                CertInfo.name      = textBox_name.Text;
            }

            if (rdo_male.Checked)
            {
                CertInfo.gender = "男";
            }
            else
            {
                CertInfo.gender = "女";
            }

            CertInfo.age = textBox_age.Text;
            int Fage = 0;

            int.TryParse(textBox_age.Text, out Fage);
            if (Fage < 1 || Fage > 80)
            {
                label_age.Visible = true;
                return(-1);
            }
            else
            {
                label_age.Visible = false;
            }

            Regex regex = new Regex(@"1[3456789]\d{9}$");

            if (regex.IsMatch(textBox_phone.Text))
            {
                label_phone.Visible = false;
            }
            else
            {
                label_phone.Visible = true;
                return(-1);
            }

            CertInfo.phone = textBox_phone.Text;;


            if ((!Regex.IsMatch(textBox_id.Text, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", RegexOptions.IgnoreCase)))
            {
                label_id.Visible = true;
                return(-1);
            }
            else
            {
                label_id.Visible = false;
            }

            string bornyear_str  = textBox_id.Text.Substring(6, 4);
            string bornmonth_str = textBox_id.Text.Substring(10, 2);
            string bornday_str   = textBox_id.Text.Substring(12, 2);

            int born_year  = int.Parse(bornyear_str);
            int born_month = int.Parse(bornmonth_str);
            int born_day   = int.Parse(bornday_str);

            if (born_year < 1900 || born_year > 2030)
            {
                MessageBox.Show("身份证信息有误,请重新输入!");
                return(-1);
            }
            if (born_month > 12)
            {
                MessageBox.Show("身份证信息有误,请重新输入!");
                return(-1);
            }
            if (born_day < 1 || born_day > 31)
            {
                MessageBox.Show("身份证信息有误,请重新输入!");
                return(-1);
            }

            CertInfo.id = textBox_id.Text;

            if (rdo_new.Checked)//发证类型
            {
                CertInfo.issue_type = "新领";
            }
            else
            {
                CertInfo.issue_type = "补证";
            }

            string CmdStr = "SELECT * FROM tableall WHERE 身份证号 = @CertID";

            if (Function.UseDataBase != 0)
            {
                using (MySqlConnection con = new MySqlConnection(SQLClass.connsql))
                    using (MySqlCommand cmd = new MySqlCommand(CmdStr, con))
                    {
                        try
                        {
                            cmd.Parameters.AddWithValue("@CertID", CertInfo.id);

                            con.Open();
                            object obj = cmd.ExecuteScalar();
                            if (obj != null)
                            {
                                String dr = obj.ToString();
                                Trace.WriteLine(dr);
                                if (CertInfo.issue_type == "新领")//新领冲突
                                {
                                    MessageBox.Show("该身份证号码已进行过制证,请选择证书类型为补证!");
                                    con.Close();
                                    return(-1);
                                }
                                else//补证
                                {
                                    string       CmdStr2 = "UPDATE tableall SET 状态 = 2 WHERE 身份证号 = @id ";
                                    MySqlCommand cmd2    = new MySqlCommand(CmdStr2, con);
                                    cmd2.Parameters.AddWithValue("@id", CertInfo.id);
                                    cmd2.ExecuteNonQuery();
                                    con.Close();
                                }
                            }
                            else
                            {
                                CertInfo.state = "0";
                                con.Close();
                            }
                        }
                        catch (MySqlException ex)
                        {
                            MessageBox.Show(ex.ToString());
                            MajorLog.Error(ex.ToString());
                        }
                    }
            }

            if (textBox_mail.Text == null || textBox_mail.Text == "")
            {
                label_email.Visible = true;
                return(-1);
            }
            CertInfo.email = textBox_mail.Text;

            CertInfo.install_type = null;//安装类型
            if (checkBox7.Checked)
            {
                CertInfo.install_type = textBox_instype.Text;
                if (CertInfo.install_type == null || CertInfo.install_type == "")
                {
                    MessageBox.Show("选择其它时,输入信息不能为空");
                    return(-1);
                }
                CertInfo.install_type += ",";
            }

            foreach (CheckBox item in panel3.Controls)
            {
                if (item.Checked)
                {
                    CertInfo.install_type += item.Text + ",";
                }
            }
            if (CertInfo.install_type != null)
            {
                CertInfo.install_type = CertInfo.install_type.Substring(0, CertInfo.install_type.Length - 1);
            }
            else
            {
                MessageBox.Show("至少选择一种设备类型");
                return(-1);
            }


            CertInfo.issue_day = dateTimePicker_issue.Text;                        //发证日期

            CertInfo.cert_validity_period_start = dateTimePicker_valid_start.Text; //证书有效期开始
            CertInfo.cert_validity_period_end   = dateTimePicker_valid_end.Text;   //证书有效期结束


            if (textBox_project_name.Text == null || textBox_project_name.Text == "")
            {
                label_project.Visible = true;
                return(-1);
            }
            CertInfo.project_name = textBox_project_name.Text;

            if (textBox_appid.Text == null || textBox_appid.Text == "")
            {
                label_appid1.Visible = true;
                return(-1);
            }
            else
            {
                label_appid1.Visible = false;
            }
            CertInfo.appid = textBox_appid.Text;



            #region 验证APPID

            if (rdo_new.Checked)
            {
                string appidstr = textBox_appid.Text;
                string CmdStr3  = "SELECT * FROM tableall WHERE `APPID`= @CertAPPID";
                if (Function.UseDataBase != 0)
                {
                    using (MySqlConnection con = new MySqlConnection(SQLClass.connsql))
                        using (MySqlCommand cmd = new MySqlCommand(CmdStr3, con))
                        {
                            try
                            {
                                cmd.Parameters.AddWithValue("@CertAPPID", appidstr);

                                con.Open();
                                object obj = cmd.ExecuteScalar();
                                if (obj != null)
                                {
                                    label_appid2.Visible = true;
                                    return(-1);
                                }
                                else
                                {
                                    textBox_appid.Text   = appidstr;
                                    label_appid2.Visible = false;

                                    con.Close();
                                }
                            }
                            catch (MySqlException ex)
                            {
                                MessageBox.Show(ex.ToString());
                                MajorLog.Error(ex.ToString());
                            }
                        }
                }
            }
            else
            {
                string CmdStr3 = "SELECT appid FROM tableall WHERE `身份证号`= @CertID";
                if (Function.UseDataBase != 0)
                {
                    using (MySqlConnection con = new MySqlConnection(SQLClass.connsql))
                        using (MySqlCommand cmd = new MySqlCommand(CmdStr3, con))
                        {
                            try
                            {
                                cmd.Parameters.AddWithValue("@CertID", textBox_id.Text);

                                con.Open();
                                object obj = cmd.ExecuteScalar();
                                if (obj != null && obj.ToString() == textBox_appid.Text)
                                {
                                    label_appid2.Visible = false;
                                    con.Close();
                                }
                                else
                                {
                                    label_appid2.Visible = true;
                                    con.Close();
                                    return(-1);
                                }
                            }
                            catch (MySqlException ex)
                            {
                                MessageBox.Show(ex.ToString());
                                MajorLog.Error(ex.ToString());
                            }
                        }
                }
            }
            #endregion

            if (Regex.IsMatch(textBox_appkey.Text, @"^[a-zA-Z][a-zA-Z0-9]\w{5,15}$", RegexOptions.IgnoreCase))
            {
                if (Regex.IsMatch(textBox_appkey.Text, @"[\d]", RegexOptions.IgnoreCase))
                {
                    CertInfo.appkey = textBox_appkey.Text;
                }
                else
                {
                    label_appkey.Visible = true;

                    return(-1);
                }
            }
            else
            {
                label_appkey.Visible = true;
                return(-1);
            }



            if (textBox_company_name.Text == null || textBox_company_name.Text == "")
            {
                label_company_name.Visible = true;
                return(-1);
            }
            CertInfo.company_name = textBox_company_name.Text;


            if (textBox_company_phone.Text == null || textBox_company_phone.Text == "")
            {
                label_company_phone.Visible = true;
                return(-1);
            }
            CertInfo.company_phone = textBox_company_phone.Text;


            if (textBox_company_address.Text == null || textBox_company_address.Text == "")
            {
                label_company_address.Visible = true;
                return(-1);
            }
            CertInfo.company_address = textBox_company_address.Text;


            CertInfo.remarks = textBox_Remarks.Text;//备注

            if (textBox_belong_company.Text == null || textBox_belong_company.Text == "")
            {
                label_belong.Visible = true;
                return(-1);
            }
            CertInfo.company_belong = textBox_belong_company.Text;

            Random rd = new Random();

            string OnlyIDwithoutCRC = CertInfo.id.Substring(CertInfo.id.Length - 6, 6) + CertInfo.issue_day.Replace("/", "").Substring(0, 8);

            CertInfo.OnlyID = OnlyIDwithoutCRC + rd.Next(0, 32767).ToString("x4");

            //全部通过进入下一个页面,否则提示出错需要重新设置
            if (myAckMakeForm != null)
            {
                myAckMakeForm.Activate();
            }
            else
            {
                myAckMakeForm = new Form_AckMake();
            }
            myAckMakeForm.ShowDialog();

            return(1);
        }
コード例 #11
0
        private void button4_Click(object sender, EventArgs e)
        {
            textBox_appid.Text = "";

            if (rdo_new.Checked)
            {
                string   trs    = Pinyin.GetPinyin(textBox_name.Text);
                string[] nmlist = Regex.Split(trs, @"\s+");
                if (nmlist.Length >= 2)
                {
                    nmlist[0]           = nmlist[0].Substring(0, 1).ToUpper();
                    textBox_appid.Text += nmlist[0];
                    for (int i = 1; i < nmlist.Length; i++)
                    {
                        string temp = nmlist[i];
                        nmlist[i]           = temp.Substring(0, 1).ToUpper() + temp.Substring(1, temp.Length - 1);
                        textBox_appid.Text += nmlist[i];
                    }

                    int    count    = 1;
                    bool   valid    = false;
                    string appidstr = textBox_appid.Text;
                    string CmdStr   = "SELECT * FROM tableall WHERE `APPID`= @CertAPPID";
                    while (valid != true)
                    {
                        if (Function.UseDataBase != 0)
                        {
                            using (MySqlConnection con = new MySqlConnection(SQLClass.connsql))
                                using (MySqlCommand cmd = new MySqlCommand(CmdStr, con))
                                {
                                    try
                                    {
                                        cmd.Parameters.AddWithValue("@CertAPPID", appidstr);

                                        con.Open();
                                        object obj = cmd.ExecuteScalar();
                                        if (obj != null)
                                        {
                                            appidstr = textBox_appid.Text + (count++).ToString("x2");
                                            valid    = false;
                                        }
                                        else
                                        {
                                            textBox_appid.Text = appidstr;
                                            valid = true;
                                            con.Close();
                                        }
                                    }
                                    catch (MySqlException ex)
                                    {
                                        MessageBox.Show(ex.ToString());
                                        MajorLog.Error(ex.ToString());
                                    }
                                }
                        }
                    }
                }
                else
                {
                    MajorLog.Error("输入姓名不正确!");
                }
            }
            else
            {
                string CmdStr = "SELECT appid FROM tableall WHERE `身份证号`= @CertID";
                if (Function.UseDataBase != 0)
                {
                    using (MySqlConnection con = new MySqlConnection(SQLClass.connsql))
                        using (MySqlCommand cmd = new MySqlCommand(CmdStr, con))
                        {
                            try
                            {
                                cmd.Parameters.AddWithValue("@CertID", textBox_id.Text);

                                con.Open();
                                object obj = cmd.ExecuteScalar();
                                if (obj != null)
                                {
                                    textBox_appid.Text   = obj.ToString();
                                    label_appid2.Visible = false;
                                }
                                else
                                {
                                    MessageBox.Show("数据库中不存在此身份证,请新领证书");
                                }
                                con.Close();
                            }
                            catch (MySqlException ex)
                            {
                                MessageBox.Show(ex.ToString());
                                MajorLog.Error(ex.ToString());
                            }
                        }
                }
            }
        }