private void button1_Click(object sender, EventArgs e) { if (list.Count > 0) { bool flag = true; for (int i = 0; i < list.Count; i++) { string type; if (list[i].类型.Equals("人员")) { type = "0"; } else { type = "1"; } if (!(codebll.InsertIntoCodesenderSet(list[i].标识卡, list[i].GetEmpID(), type) > 0)) { flag = false; } } if (!flag) { //MessageBox.Show("保存失败...", "提示", MessageBoxButtons.OK); labMessage.Text = "保存失败"; labMessage.ForeColor = Color.Red; labOut.Visible = true; labMessage.Visible = true; } else { //btnPReset_Click(this, new EventArgs()); list.Clear(); labMessage.Text = "保存成功!"; labMessage.ForeColor = Color.Black; labOut.Visible = true; labMessage.Visible = true; //Czlt-2011-12-10 跟新时间 codebll.UpdateTime(); if (!New_DBAcess.IsDouble) //单机版,直接刷新 { btnPReset_Click(this, new EventArgs()); a_FrmCodeSender.BindCodeSet(1); } else //热备版,启用定时器 { dgvSet.DataSource = new DataTable(); a_FrmCodeSender.HostBackRefresh(true); } } } }
private void btnCodeSave_Click(object sender, EventArgs e) { if (txtCodeMinNum.Text.Trim().Equals("")) { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "最小值未输入标识卡号"; labCodeMassage.Visible = true; return; } if (int.Parse(txtCodeMinNum.Text) <= 0) { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "不能输入0号标识卡"; labCodeMassage.Visible = true; return; } if (frmoperator == 0) { int state = 0; if (rbtZC.Checked) { state = 1; } if (rbtBad.Checked) { state = 2; } if (rbtLost.Checked) { state = 3; } if (rbtLowD.Checked) { state = 4; } if (chbMulit.Checked) { try { if (txtCodeMaxNum.Text.Trim().Equals("")) { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "最大值未输入标识卡号"; labCodeMassage.Visible = true; return; } int min = int.Parse(txtCodeMinNum.Text); int max = int.Parse(txtCodeMaxNum.Text); if ((max - min) >= 500) { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "标识卡一次最多添加500个..."; labCodeMassage.Visible = true; //MessageBox.Show("标识卡一次最多添加100个...", "提示", MessageBoxButtons.OK); return; } if (max < min) { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "最大输入值不能比最小输入值小"; labCodeMassage.Visible = true; return; } //int state = 0; bool flag = true; //if (rbtZC.Checked) // state = 1; //if (rbtBad.Checked) // state = 2; //if (rbtLost.Checked) // state = 3; //if (rbtLowD.Checked) // state = 4; for (int i = min; i <= max; i++) { if (codebll.InsertCodeSender(i, 1, state, 2, txtCodeReMark.Text) <= 0) { flag = false; } } if (flag) { labCodeMassage.ForeColor = Color.Black; labCodeMassage.Text = "保存成功"; } else { labCodeMassage.ForeColor = Color.Black; labCodeMassage.Text = "保存成功"; } labCodeMassage.Visible = true; } catch (Exception ex) { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "保存失败"; labCodeMassage.Visible = true; } } else { try { if (txtCodeMinNum.Enabled) { int code = int.Parse(txtCodeMinNum.Text); labCodeMassage.Visible = true; if (codebll.InsertCodeSender(code, 1, state, 2, txtCodeReMark.Text) > 0) { labCodeMassage.ForeColor = Color.Black; labCodeMassage.Text = "保存成功"; } else { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "该标识卡已存在"; return; } } else { int code = int.Parse(txtCodeMinNum.Text); labCodeMassage.Visible = true; if (codebll.UpdateCodeSenderState(code, state) > 0) { labCodeMassage.ForeColor = Color.Black; labCodeMassage.Text = "保存成功"; } else { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "保存失败"; return; } } } catch (Exception ex) { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "保存失败"; labCodeMassage.Visible = true; } } } else { int state = 0; if (rbtZC.Checked) { state = 1; } if (rbtBad.Checked) { state = 2; } if (rbtLost.Checked) { state = 3; } if (rbtLowD.Checked) { state = 4; } if (codebll.UpdateCodeSenderState(CodeSenderAddress, state, txtCodeReMark.Text)) { labCodeMassage.ForeColor = Color.Black; labCodeMassage.Text = "保存成功"; label14.Visible = true; labCodeMassage.Visible = true; } else { labCodeMassage.ForeColor = Color.Red; labCodeMassage.Text = "保存失败"; label14.Visible = true; labCodeMassage.Visible = true; return; } } //Czlt-2011-12-10 跟新时间 codebll.UpdateTime(); if (!New_DBAcess.IsDouble) //单机版,直接刷新 { a_FrmCodeSender.BindCode(1); } else //热备版,启用定时器 { a_FrmCodeSender.HostBackRefresh(true); } }