private void frmFunSet_Load(object sender, EventArgs e) { this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;//去掉窗体边框 try { string setValue = SetConfig.GetValue("ScanDrive"); _twain = new Twain(new WinFormsWindowMessageHook(this)); List <DictionaryEntry> listDS = _twain.GetAllSources().Select(x => new DictionaryEntry() { Key = x.SourceId.ProductName, Value = x.SourceId.ProductName + " " + x.SourceId.Version.Info }).ToList(); int index = listDS.FindIndex(x => x.Key.ToString() == setValue); dgvCompany.DataSource = listDS; if ((dgvCompany.DataSource as List <DictionaryEntry>) != null && (dgvCompany.DataSource as List <DictionaryEntry>).Count > 0) { dgvCompany.ClearSelection(); } if (index >= 0) { dgvCompany.Rows[index].Selected = true; dgvCompany.CurrentCell = this.dgvCompany.Rows[index].Cells[1]; } } catch (Exception) { //MessageBox.Show("未检测到有扫描仪驱动!"); } }
public void login() { if (!string.IsNullOrEmpty(txtName.Text.Replace("\r", "").Replace("\n", "")) && !string.IsNullOrEmpty(txtPwd.Text.Replace("\r", "").Replace("\n", ""))) { string str = getXmlStr(txtName.Text.Replace("\r", "").Replace("\n", ""), txtPwd.Text.Replace("\r", "").Replace("\n", "")).Replace("\r", "").Replace("\n", ""); if (str != "0" && !string.IsNullOrEmpty(str)) { TestData jobj = JsonConvert.DeserializeObject <TestData>(str); string times = SetConfig.GetValue("times"); if (!string.IsNullOrEmpty(times)) { if (Convert.ToInt32(times) < Convert.ToInt32(DateTime.Now.ToString("yyyyMMdd"))) { SetConfig.setValue("times", DateTime.Now.ToString("yyyyMMdd")); SetConfig.setValue("todayBillNum", "0"); } } else { SetConfig.setValue("times", DateTime.Now.ToString("yyyyMMdd")); SetConfig.setValue("todayBillNum", "0"); } string todayBillNum = SetConfig.GetValue("todayBillNum"); frmScanMain fsm = new frmScanMain(); fsm.telephone = jobj.telephone; fsm.userPicUrl = jobj.userPicUrl; fsm.listCI = jobj.comInfoList; fsm.userName = jobj.userName; fsm.label4.Text = todayBillNum + "张"; this.Hide(); fsm.Show(); } else { this.txtPwd.Text = string.Empty; MessageBox.Show("用户名或密码错误"); } } else { MessageBox.Show("请输入用户名或密码"); } }