void txtkshm_Validated(object sender, EventArgs e) { try { string str = ToDBC(txtkshm.Text.Trim()); int klxId = Convert.ToInt32(Convertor.IsNull(cmbklx.SelectedValue, "0")); ts_mz_class.Klx klx = new Klx(klxId, InstanceForm.BDatabase); string kh = klx.FormatCardNo(str); txtkshm.Text = kh; if (!string.IsNullOrEmpty(textBox1.Text) && Convertor.IsInteger(textBox1.Text)) { int pics = Convert.ToInt32(textBox1.Text); string lastKh = klx.ComputeLastNumber(kh, pics); txtjshm.Text = lastKh; } } catch (ts_mz_class.Klx.AssignedCardPicsOverLimitException over) { MessageBox.Show(over.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBox1.Focus(); } catch (ts_mz_class.Klx.CardNumberOutOfSettingLengthException error) { MessageBox.Show(error.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); txtkshm.Focus(); } }
private void txtjshm_Validating(object sender, CancelEventArgs e) { try { if (!String.IsNullOrEmpty(txtjshm.Text) && Convertor.IsInteger(txtjshm.Text)) { int klxId = Convert.ToInt32(Convertor.IsNull(cmbklx.SelectedValue, "0")); ts_mz_class.Klx klx = new Klx(klxId, InstanceForm.BDatabase); string kh = klx.FormatCardNo(txtjshm.Text.Trim()); int jsbm = Convert.ToInt32(txtjshm.Text.Trim()); int ksbm = Convert.ToInt32(txtkshm.Text.Trim()); if (jsbm < ksbm) { e.Cancel = false; if (ksbm > 0 && !String.IsNullOrEmpty(textBox1.Text)) { textBox1_Validated(textBox1, e); } } else { textBox1.Text = Convert.ToString(jsbm - ksbm + 1); txtjshm.Text = kh; } } else { txtjshm.Text = ""; } } catch (Exception ex) { e.Cancel = false; MessageBox.Show(ex.Message); } }