private void toolStripButtonDeleteUserInfo_Click(object sender, EventArgs e) { AccessDataBase.BLL.UserInfo bllUserInfo = new AccessDataBase.BLL.UserInfo(); if (MyMessageBox.MessageBoxOkCancel("用户信息删除后不能恢复,是否删除?") == System.Windows.Forms.DialogResult.Cancel) { return; } foreach (DataGridViewRow i in dataGridViewWithCheckBox1.Rows) { if (dataGridViewWithCheckBox1.GetRowCheckBoxState(i.Index)) { string userID = dataGridViewWithCheckBox1["UserID", i.Index].Value.ToString().Trim(); AccessDataBase.Model.UserInfo modeUserInfo = bllUserInfo.GetModel(int.Parse(userID)); if (bllUserInfo.Exists(modeUserInfo.UserID)) { bllUserInfo.Delete(modeUserInfo.UserID); } } } this.refreshDataGridView(); }
private void toolStripButtonDeleteUserInfo_Click(object sender, EventArgs e) { AccessDataBase.BLL.UserInfo bllUserInfo = new AccessDataBase.BLL.UserInfo(); if (MyMessageBox.MessageBoxOkCancel("�û���Ϣɾ�����ָܻ�,�Ƿ�ɾ��?") == System.Windows.Forms.DialogResult.Cancel) return; foreach (DataGridViewRow i in dataGridViewWithCheckBox1.Rows) { if (dataGridViewWithCheckBox1.GetRowCheckBoxState(i.Index)) { string userID = dataGridViewWithCheckBox1["UserID", i.Index].Value.ToString().Trim(); AccessDataBase.Model.UserInfo modeUserInfo = bllUserInfo.GetModel(int.Parse(userID)); if (bllUserInfo.Exists(modeUserInfo.UserID)) bllUserInfo.Delete(modeUserInfo.UserID); } } this.refreshDataGridView(); }
private void kryptonButtonOK_Click(object sender, EventArgs e) { int cardType = 0; string dateMatch; #region 基本信息 modelUserInfo.UserID = int.Parse(kryptonTextBoxUserID.Text); modelUserInfo.UserName = kryptonTextBoxUserName.Text.Trim(); modelUserInfo.DepartmentID = bllDepartmentInfo.GetModelList("DepartmentName='" + kryptonComboBoxDepartment.Text.Trim() + "'")[0].DepartmentID; #endregion #region 个人信息 //modelUserInfo.DepartmentID = #endregion #region 卡片信息1 if (kryptonCheckBoxCardInfo1.Enabled == true) { modelCardInfo1.CardID = kryptonTextBoxCardID1.Text.Trim(); modelUserInfo.PrimaryCardID = modelCardInfo1.CardID; if (string.IsNullOrEmpty(modelUserInfo.PrimaryCardID)) { MyMessageBox.MessageBoxOK("卡1号不能为空"); return; } modelCardInfo1.CardVersion = kryptonTextBoxCardVersion1.Text.Trim(); if (int.TryParse(kryptonTextBoxCardType1.Text.Trim(), out cardType)) { modelCardInfo1.CardType = cardType; } modelCardInfo1.CardLevel = kryptonTextBoxCardLevel1.Text.Trim(); modelCardInfo1.CardPassword = kryptonTextBoxCardPassword1.Text.Trim(); dateMatch = kryptonDateTimePickerCardIssueDateTime1.Value.ToShortDateString(); if (RegexMatch.IsDate(dateMatch)) { modelCardInfo1.CardIssueDateTime = dateMatch; } dateMatch = kryptonDateTimePickerCardValidDateTime1.Value.ToShortDateString(); if (RegexMatch.IsDate(dateMatch)) { modelCardInfo1.CardValidDateTime = dateMatch; } } else { modelUserInfo.PrimaryCardID = null; } #endregion #region 卡片信息2 if (kryptonCheckBoxCardInfo1.Enabled == true) { modelCardInfo2.CardID = kryptonTextBoxCardID2.Text.Trim(); modelUserInfo.SecondCardID = modelCardInfo2.CardID; if (string.IsNullOrEmpty(modelUserInfo.SecondCardID)) { MyMessageBox.MessageBoxOK("卡2号不能为空"); return; } modelCardInfo2.CardVersion = kryptonTextBoxCardVersion2.Text.Trim(); if (int.TryParse(kryptonTextBoxCardType2.Text.Trim(), out cardType)) { modelCardInfo2.CardType = cardType; } modelCardInfo2.CardLevel = kryptonTextBoxCardLevel2.Text.Trim(); modelCardInfo2.CardPassword = kryptonTextBoxCardPassword2.Text.Trim(); dateMatch = kryptonDateTimePickerCardIssueDateTime2.Value.ToShortDateString(); if (RegexMatch.IsDate(dateMatch)) { modelCardInfo2.CardIssueDateTime = dateMatch; } dateMatch = kryptonDateTimePickerCardValidDateTime2.Value.ToShortDateString(); if (RegexMatch.IsDate(dateMatch)) { modelCardInfo2.CardValidDateTime = dateMatch; } } else { modelUserInfo.SecondCardID = null; } #endregion #region 生物信息 modelUserInfo.FingerPosition0 = (kryptonComboBox2.SelectedIndex + 1) + kryptonComboBox1.SelectedIndex; modelUserInfo.FingerPosition1 = (kryptonComboBox3.SelectedIndex + 1) + kryptonComboBox4.SelectedIndex; modelUserInfo.FingerPrint0 = MyImageOperate.getByteByImage(pictureBoxFingerPrint1.Image); modelUserInfo.FingerPrint1 = MyImageOperate.getByteByImage(pictureBoxFingerPrint2.Image); modelUserInfo.Photograph = MyImageOperate.getByteByImage(pictureBoxPhotograph.Image); #endregion if (this.openMode == OpenMode.Add) { if ((kryptonCheckBoxCardInfo1.Enabled == true) && (bllCardInfo.Exists(modelCardInfo1.CardID))) { MyMessageBox.MessageBoxOK("卡1已经存在,不能添加"); } else if ((kryptonCheckBoxCardInfo2.Enabled == true) && (bllCardInfo.Exists(modelCardInfo2.CardID))) { MyMessageBox.MessageBoxOK("卡2已经存在,不能添加"); } else if (bllUserInfo.Exists(modelUserInfo.UserID)) { MyMessageBox.MessageBoxOK("用户信息已经存在,不能添加"); } else if (bllCardInfo.Add(modelCardInfo1) == false) { MyMessageBox.MessageBoxOK("添加卡1失败"); } else if (bllCardInfo.Add(modelCardInfo2) == false) { MyMessageBox.MessageBoxOK("添加卡2失败"); } else if (bllUserInfo.Add(modelUserInfo) == false) { MyMessageBox.MessageBoxOK("添加用户信息失败"); } else { this.Close(); } } else if (this.openMode == OpenMode.Update) { if ((kryptonCheckBoxCardInfo1.Enabled == true) && (bllCardInfo.Update(modelCardInfo1) == false)) { MyMessageBox.MessageBoxOK("修改卡1失败"); } else if ((kryptonCheckBoxCardInfo2.Enabled == true) && (bllCardInfo.Update(modelCardInfo2) == false)) { MyMessageBox.MessageBoxOK("修改卡2信息失败"); } else if (bllUserInfo.Update(modelUserInfo) == false) { MyMessageBox.MessageBoxOK("修改用户信息失败"); } this.Close(); } }