//判断图书条码为数值 private void txtBarCode_TextChanged(object sender, EventArgs e) { if (!DataValidate.IsInteger(this.txtBarCode.Text.Trim())) { this.txtBarCode.Text = ""; } }
private void btnLogin_Click(object sender, EventArgs e) { //选中匿名登录,直接匿名身份登录,否则,判断用户名和密码是否正确 if (this.checkBox1.Checked == false) { #region 数据验证 if (this.txtLoginId.Text.Trim().Length == 0) { MessageBox.Show("请填写用户名!", "登录提示"); this.txtLoginId.Focus(); return; } if (!DataValidate.IsInteger(this.txtLoginId.Text.Trim())) { MessageBox.Show("用户名必须为正整数!", "登录提示"); this.txtLoginId.Focus(); return; } if (this.txtLoginPwd.Text.Trim().Length == 0) { MessageBox.Show("请填写密码!", "登录提示"); this.txtLoginPwd.Focus(); return; } #endregion //封装对象 SysAdmin objAdmin = new SysAdmin() { LoginId = Convert.ToInt32(this.txtLoginId.Text.Trim()), LoginPwd = this.txtLoginPwd.Text.Trim() }; try { //调用登陆数据库方法,进行账号验证 objAdmin = objAdminService.AdminLogin(objAdmin); if (objAdmin == null) { MessageBox.Show("用户名或密码不正确!", "登录提示"); return; } else { this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { MessageBox.Show("登陆异常,原因:" + ex.Message, "登录提示"); return; } } else { this.DialogResult = DialogResult.OK; } }
//SQL成绩失焦事件 private void textSQL_LostFocus(object sender, RoutedEventArgs e) { if (DataValidate.IsInteger(textSQL.Text.Trim()) == false) { System.Windows.Forms.MessageBox.Show("请输入正确分数!!!", "友情提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } }
//登录 private void btnLoin_Click(object sender, RoutedEventArgs e) { //数据验证 if (txtLogID.Text.Trim().Length == 0) { MessageBox.Show("请输入登录账号!", "登录提示"); txtLogID.Focus(); //获取焦点 return; } if (DataValidate.IsInteger(txtLogID.Text.Trim()) == false) //Datavalidate存在common问文件下,通过正则表达式判断输入的账号是否为数字 { MessageBox.Show("请输入正确账号!(纯数字格式)", "登录提示"); txtLogID.Focus(); return; } if (txtLogPwd.Password.Length == 0) { MessageBox.Show("请输入登录密码!", "登录提示"); txtLogPwd.Focus(); return; } //输入的账号密码 Admins admin = new Admins() { LoginID = Convert.ToInt32(txtLogID.Text.Trim()), //获取到输入的账号 LoginPwd = txtLogPwd.Password.Trim() //输入的密码 }; //和后台交互查询,判断登录信息是否正确 try { Admins mainuse = new AdminManager().GetAdmins(admin); //通过管理员账号获取到密码 if (mainuse == null) { MessageBox.Show("用户账号不存在!", "提示信息"); txtLogID.Focus(); //获取焦点 } else { if (mainuse.LoginPwd == txtLogPwd.Password) { //保存登录信息 App.CurrentAdmin = mainuse; this.DialogResult = true; this.Close(); } else { MessageBox.Show("用户密码错误!", "提示信息"); txtLogPwd.Focus(); } } } catch (Exception) { MessageBox.Show("服务器连接异常,登录失败!请检查您的网络!"); } }
private void btnLogin_Click(object sender, RoutedEventArgs e) { //数据验证 if (txtLogId.Text.Trim().Length == 0) { MessageBox.Show("请输入登录账号!", "登录提示"); txtLogId.Focus();//焦点 return; } if (DataValidate.IsInteger(txtLogId.Text.Trim()) == false)//通过通用层进行验证 { MessageBox.Show("账号有误!(纯数字格式)", "登录提示"); txtLogId.Focus();//聚焦 return; } if (txtLogPwd.Password.Length == 0) { MessageBox.Show("请输入登录密码!", "登录提示"); txtLogPwd.Focus(); return; } //输入的账号密码 Admins admins = new Admins() { LoginId = Convert.ToInt32(txtLogId.Text.Trim()) }; //先尝试和后天交互,进行查询是否有对应项 try { Admins mainuse = new AdminManager().GetAdmins(admins); if (mainuse == null) { MessageBox.Show("用户信息不存在重新输入!", "提示信息"); txtLogId.Focus();//聚焦 } else { if (mainuse.LoginPwd == Convert.ToInt32(txtLogPwd.Password)) { //保存登录信息 App.CurrentAdmin = mainuse; this.DialogResult = true; this.Close(); } else { MessageBox.Show("用户密码有误请重新输入!", "提示信息"); txtLogPwd.Focus(); } } } catch (Exception ex) { MessageBox.Show("服务器连接异常,登录失败!请检查您的网络!"); throw ex; } }
bool CheckInfor() { if (string.IsNullOrEmpty(txtName.Text)) { System.Windows.MessageBox.Show("姓名不能为空!"); txtName.Focus(); return(false); } if (string.IsNullOrEmpty(txtAge.Text)) { System.Windows.MessageBox.Show("年龄不能为空!"); txtAge.Focus(); return(false); } else if (!DataValidate.IsInteger(txtAge.Text)) { System.Windows.MessageBox.Show("年龄必须是纯数字!"); txtAge.Focus(); return(false); } if (string.IsNullOrEmpty(txtCardNo.Text)) { System.Windows.MessageBox.Show("打卡号不能为空!"); txtCardNo.Focus(); return(false); } if (string.IsNullOrEmpty(txtStuNoId.Text)) { System.Windows.MessageBox.Show("身份证号不能为空!"); txtStuNoId.Focus(); return(false); } //if (Common.DataValidate.IsIdentitycard(txtStuNoId.Text)) //{ // System.Windows.MessageBox.Show("必须为18位正整数!"); // txtStuNoId.Focus(); // return false; //} if (string.IsNullOrEmpty(txtPhoneNumber.Text)) { System.Windows.MessageBox.Show("联系方式不能为空!"); txtPhoneNumber.Focus(); return(false); } if (Common.DataValidate.IsPhone(txtPhoneNumber.Text)) { System.Windows.MessageBox.Show("必须为11位数!"); txtStuNoId.Focus(); return(false); } return(true); }
/// <summary> /// 更新图书数量 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSave_Click(object sender, EventArgs e) { if (this.txtAddCount.Text.Trim().Length == 0) { MessageBox.Show("请输入新增图书总数", "新增提示"); this.txtAddCount.SelectAll(); this.txtAddCount.Focus(); return; } if (!DataValidate.IsInteger(this.txtAddCount.Text.Trim())) { MessageBox.Show("新增图书总数必须是正整数!", "新增提示"); this.txtAddCount.SelectAll(); this.txtAddCount.Focus(); return; } try { var result = bookManager.UpdateBookCount(this.txtBarCode.Text.Trim(), Convert.ToInt32(this.txtAddCount.Text.Trim())); if (result == 1) { var book = books.Where(o => o.BarCode == this.txtBarCode.Text.Trim()).First(); book.BookCount += Convert.ToInt32(this.txtAddCount.Text.Trim()); this.dgvBookList.Refresh(); MessageBox.Show("新增成功,是否需要继续更新该图书数量?", "新增提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); //if (dialogResult == DialogResult.OK) //{ // this.txtAddCount.Text = string.Empty; // this.txtAddCount.Focus(); // return; //} //清除其他信息: this.lblBookName.Text = string.Empty; this.lblCategory.Text = string.Empty; this.lblBookPosition.Text = string.Empty; this.lblBookId.Text = string.Empty; this.lblBookCount.Text = string.Empty; this.pbImage.Image = null; this.txtAddCount.Text = string.Empty; this.txtAddCount.Enabled = false; this.btnSave.Enabled = false; this.txtBarCode.Clear(); this.txtBarCode.Focus(); } } catch (Exception ex) { MessageBox.Show("更新图书数量异常:" + ex.Message, "异常提示"); } }
private void txtAge_LostFocus(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtAge.Text)) { System.Windows.MessageBox.Show("年龄不能为空!"); txtAge.Focus(); } else if (!DataValidate.IsInteger(txtAge.Text)) { System.Windows.MessageBox.Show("年龄必须是纯数字!"); txtAge.Focus(); } }
//考勤号失去焦点事件 private void textClockNo_LostFocus(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(textClockNo.Text)) { System.Windows.MessageBox.Show("打卡号不能为空!"); textClockNo.Focus(); } else if (DataValidate.IsInteger(textClockNo.Text.Trim()) == false) { System.Windows.Forms.MessageBox.Show("考勤号必须为纯数字!", "友情提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } }
//登录 private void BtnLogin_Click(object sender, EventArgs e) { //数据校验 if (!DataValidate.IsInteger(this.txtLoginId.Text.Trim())) { MessageBox.Show("登录Id只能是整数!", "提示信息!"); this.txtLoginId.Focus(); return; } if (this.txtLoginPwd.Text.Trim().Length == 0) { MessageBox.Show("密码不能为空!", "提示信息!"); return; } //封装对象 SysAdmins admin = new SysAdmins { LoginId = Convert.ToInt32(this.txtLoginId.Text.Trim()), LoginPwd = this.txtLoginPwd.Text.Trim() }; try { admin = adminManager.AdminLogin(admin); if (admin != null) { if (admin.AdminStatus == 1) { Program.currentAdmin = admin; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("当前账户被禁用,请练习管理员!", "提示信息!"); } } else { MessageBox.Show("用户名或密码错误!", "提示信息!"); } } catch (Exception ex) { MessageBox.Show("登录异常," + ex.Message, "提示信息!"); } }
//更新图书总数 private void btnSave_Click(object sender, EventArgs e) { //数据验证 if (this.txtAddCount.Text.Trim().Length == 0) { MessageBox.Show("请输入新增图书量", "信息提示"); this.txtAddCount.Focus(); this.txtAddCount.SelectAll(); return; } if (!DataValidate.IsInteger(this.txtAddCount.Text.Trim())) { MessageBox.Show("新增总数非法,必须为整数", "错误提示"); return; } //数据更新 try { int addCount = Convert.ToInt32(this.txtAddCount.Text.Trim()); //更新数据库图书总数 int result = objBookManager.AddBookCount(this.txtBarCode.Text.Trim(), addCount); //更新列表中图书总数 if (result == 1) { var bookListTemp = bookList.Where(b => b.BarCode == this.txtBarCode.Text.Trim()).First(); bookListTemp.BookCount += addCount; this.dgvBookList.Refresh(); //清空图书信息的显示 this.lblBookName.Text = ""; this.lblBookCount.Text = ""; this.lblBookPosition.Text = ""; this.lblCategory.Text = ""; this.lblBookId.Text = ""; this.pbImage.Image = null; //图书条码文本框获取焦点 this.txtBarCode.Clear(); this.txtAddCount.Clear(); this.txtAddCount.Enabled = false; this.txtBarCode.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 鼠标离开触发 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtAdminId_MouseLeave(object sender, EventArgs e) { string adminId = txtAdminId.Text.Trim(); if (adminId == null || "".Equals(adminId)) { // errortext.Text = "账号不能为空"; txtAdminId.Focus();//获得焦点 return; } if (DataValidate.IsInteger(adminId)) { //errortext.Text = "账号必须是4为整数"; txtAdminId.Focus(); return; } }
/// <summary> /// 用户登陆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, EventArgs e) { if (this.txtUserId.Text.Trim().Length == 0 || this.txtPwd.Text.Trim().Length <= 0) { MessageBox.Show("请输入账号Id和密码", "登陆提示"); this.txtUserId.Focus(); return; } if (!DataValidate.IsInteger(this.txtUserId.Text.Trim())) { MessageBox.Show("用户名格式错误,必须为正整数", "登陆提示"); this.txtUserId.Focus(); return; } User objUser = new User() { UserId = Convert.ToInt32(this.txtUserId.Text.Trim()), UserPwd = this.txtPwd.Text.Trim() }; //提交数据库验证 try { objUser = this.objUserService.AdminLogin(objUser); if (objUser != null) { //触发登陆成功事件 LoginCompleted?.Invoke(objUser); this.Close(); } else { MessageBox.Show("登陆失败,用户名或密码错误", "登陆提示"); this.txtUserId.Focus(); return; } } catch (Exception ex) { MessageBox.Show("登陆账号数据库验证出错:" + ex.Message, "登陆错误"); return; } }
/// <summary> /// 同步计算工作量 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtEditModuleNo_TextChanged(object sender, EventArgs e) { if (!DataValidate.IsInteger(txtEditModuleNo.Text.Trim())) { //MessageBox.Show("烟罩分段数量必须是数字", "验证信息"); txtEditModuleNo.Text = ""; txtEditModuleNo.Focus(); return; } if (txtEditModuleNo.Text.Trim().Length == 0) { return; //分段没有输入,不计算 } if (cobEditModel.SelectedIndex == -1) { return; //模型没有选择,不计算 } txtEditSubTotalWorkload.Text = (Convert.ToDecimal(txtEditModuleNo.Text.Trim()) * Convert.ToDecimal(cobEditModel.SelectedValue)).ToString(); }
bool CheckInfor() { if (string.IsNullOrEmpty(txtName.Text)) { System.Windows.MessageBox.Show("姓名不能为空!"); txtName.Focus(); return(false); } if (string.IsNullOrEmpty(txtAge.Text)) { System.Windows.MessageBox.Show("年龄不能为空!"); txtAge.Focus(); return(false); } else if (!DataValidate.IsInteger(txtAge.Text)) { System.Windows.MessageBox.Show("年龄必须是纯数字!"); txtAge.Focus(); return(false); } if (string.IsNullOrEmpty(txtCardNo.Text)) { System.Windows.MessageBox.Show("打卡号不能为空!"); txtCardNo.Focus(); return(false); } if (string.IsNullOrEmpty(txtStuNoId.Text)) { System.Windows.MessageBox.Show("身份证号不能为空!"); txtStuNoId.Focus(); return(false); } if (string.IsNullOrEmpty(txtPhoneNumber.Text)) { System.Windows.MessageBox.Show("联系方式不能为空!"); txtPhoneNumber.Focus(); return(false); } return(true); }
/// <summary> /// 修改参数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEditData_Click(object sender, EventArgs e) { #region 数据验证 //必填项目 if (pbModelImage.Tag.ToString().Length == 0) { return; } if (!DataValidate.IsInteger(txtQuantity.Text.Trim())) { MessageBox.Show("请认真检查数量是否填错", "提示信息"); txtQuantity.Focus(); txtQuantity.SelectAll(); return; } #endregion //封装对象 UCWUVR4SDXF objUCWUVR4SDXF = new UCWUVR4SDXF() { UCWUVR4SDXFId = Convert.ToInt32(pbModelImage.Tag), Quantity = Convert.ToInt32(txtQuantity.Text) }; //提交修改 try { if (objUCWUVR4SDXFService.EditModel(objUCWUVR4SDXF) == 1) { MessageBox.Show("制图数据修改成功", "提示信息"); this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//登录 private void btnLogin_Click(object sender, EventArgs e) { #region 数据验证 if (this.txtAdminId.Text.Trim().Length == 0) { MessageBox.Show("请输入账号", "提示信息"); this.txtAdminId.Focus(); return; } if (this.txtLoginPwd.Text.Trim().Length == 0) { MessageBox.Show("请输入密码", "提示信息"); this.txtLoginPwd.Focus(); return; } if (!DataValidate.IsInteger(this.txtAdminId.Text.Trim())) { MessageBox.Show("账号不正确", "提示信息"); this.txtAdminId.Focus(); return; } #endregion #region 封装对象 SysAdmin objAdmin = new SysAdmin() { AdminId = Convert.ToInt32(this.txtAdminId.Text.Trim()), LoginPwd = this.txtLoginPwd.Text }; #endregion #region 调用后台进行登录 try { objAdmin = objAdminManager.AdminLogin(objAdmin); if (objAdmin != null) { if (objAdmin.StatusId == 1) { Program.currentAdmin = objAdmin; this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("账号已被锁定", "登录失败"); } } else { MessageBox.Show("账号或密码错误", "登录失败"); } } catch (Exception ex) { MessageBox.Show("系统异常,请稍后再试:" + ex.Message, "异常提示"); } #endregion }
/// <summary> /// 添加分类 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddCategory_Click(object sender, EventArgs e) { #region 数据验证 if (txtCategoryId.Text.Trim().Length == 0) { MessageBox.Show("分类编号不能为空", "验证信息"); txtCategoryId.Focus(); return; } if (cobParentId.SelectedIndex == -1) { MessageBox.Show("请选择父类编号", "验证信息"); cobParentId.Focus(); return; } if (txtCategoryName.Text.Trim().Length == 0) { MessageBox.Show("分类名称不能为空", "验证信息"); txtCategoryName.Focus(); return; } //验证编号是数字 if (!DataValidate.IsInteger(this.txtCategoryId.Text.Trim())) { MessageBox.Show("分类编号必须是数字", "验证信息"); txtCategoryId.Focus(); txtCategoryId.SelectAll(); return; } #endregion #region 封装对象 Category objCategory = new Category() { CategoryId = Convert.ToInt32(txtCategoryId.Text.Trim()), ParentId = Convert.ToInt32(cobParentId.Text), CategoryName = txtCategoryName.Text, CategoryDesc = txtCategoryDesc.Text, Model = txtModel.Text, SubType = txtSubType.Text, ModelImage = pbModelImage.Image != null ? new SerializeObjectToString().SerializeObject(pbModelImage.Image) : null, KMLink = txtKMLink.Text, ModelPath = txtModelPath.Text }; #endregion #region 添加到数据库 try { string result = objCategoryService.AddCategory(objCategory); if (result == "success") { //提示添加成功 MessageBox.Show("分类添加成功", "提示信息"); //刷新显示 IniCategoryId(cobParentId); //重新绑定下拉框 cobParentId.Text = objCategory.ParentId.ToString(); //重新给下拉框赋值,防止后面刷新dgv出错 RefreshData(cobParentId.Text); //根据下拉框的值刷新dgv //清空内容 pbModelImage.Image = null; foreach (Control item in Controls) { if (item is TextBox) { item.Text = ""; } } txtCategoryId.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } #endregion }
//确认添加 private void btnAdd_Click(object sender, EventArgs e) { #region 数据验证 if (this.txtBookName.Text.Trim() == null || "".Equals(this.txtBookName.Text.Trim())) { MessageBox.Show("图书名称不能为空", "提示"); return; } if (this.cboBookCategory.SelectedIndex == -1) { MessageBox.Show("请选择一种类别", "提示"); return; } if (this.cboPublisher.SelectedIndex == -1) { MessageBox.Show("请选择出版社", "提示"); return; } if (this.txtAuthor.Text.Trim() == null || "".Equals(this.txtAuthor.Text.Trim())) { MessageBox.Show("作者不能为空", "提示"); return; } if (this.txtBookPosition.Text.Trim() == null || "".Equals(this.txtBookPosition.Text.Trim())) { MessageBox.Show("图书位置不能为空", "提示"); return; } if (this.txtUnitPrice.Text.Trim() == null || "".Equals(this.txtUnitPrice.Text.Trim())) { MessageBox.Show("图书原价不能为空", "提示"); return; } if (this.txtBookCount.Text.Trim() == null || "".Equals(this.txtBookCount.Text.Trim())) { MessageBox.Show("图书总量不能为空", "提示"); return; } if (this.txtBarCode.Text.Trim() == null || "".Equals(this.txtBarCode.Text.Trim())) { MessageBox.Show("图书编码不能为空", "提示"); return; } if (!DataValidate.IsInteger(this.txtUnitPrice.Text.Trim())) { MessageBox.Show("原价必须是正整数"); return; } if (!DataValidate.IsInteger(this.txtBookCount.Text.Trim())) { MessageBox.Show("图书总量必须是正整数"); return; } if (this.pbCurrentImage.Image == null) { MessageBox.Show("图片不能为空", "提示"); return; } #endregion //封装图书对象 Books book = new Books() { BookName = this.txtBookName.Text.Trim(), barCode = this.txtBarCode.Text.Trim(), bookCategory = Convert.ToInt32(this.cboBookCategory.SelectedValue), publisherId = Convert.ToInt32(this.cboPublisher.SelectedValue), publishDate = Convert.ToDateTime(dtpPublishDate.Text), unitPrice = Convert.ToDouble(txtUnitPrice.Text.Trim()), BookCount = Convert.ToInt32(txtBookCount.Text.Trim()), author = this.txtAuthor.Text.Trim(), Remainder = Convert.ToInt32(txtBookCount.Text.Trim()), bookPosition = txtBookPosition.Text.Trim(), bookImage = new Common.SerializeObjectToString().SerializeObject(this.pbCurrentImage.Image), PublisherName = this.cboPublisher.Text }; //调用后台添加图书信息 try { bookService.AddBook(book); //同步添加到表格中 this.bookList.Add(book); this.dgvBookList.DataSource = null; this.dgvBookList.DataSource = bookList; //清空用户输入的数据, foreach (Control item in this.gbBook.Controls) { if (item is TextBox) { item.Text = ""; } else if (item is ComboBox) { ((ComboBox)item).SelectedIndex = -1; } } this.txtBookName.Focus(); this.pbCurrentImage.Image = null; } catch (Exception) { throw; } }
/// <summary> /// 提交修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEditDrawingPlan_Click(object sender, EventArgs e) { #region 数据验证 if (cobEditModel.SelectedIndex == -1) { MessageBox.Show("请选择烟罩型号", "验证信息"); cobEditModel.Focus(); return; } if (txtEditModuleNo.Text.Trim().Length == 0) { MessageBox.Show("请输烟罩分段数量", "验证信息"); txtEditModuleNo.Focus(); return; } if (cobEditODPNo.SelectedIndex == -1) { MessageBox.Show("请输入选择或输入项目编号,如果没有,请到项目列表中添加后再选择", "验证信息"); cobEditODPNo.Focus(); return; } //验证数量是数字 if (!DataValidate.IsInteger(txtEditModuleNo.Text.Trim())) { MessageBox.Show("烟罩分段数量必须是数字", "验证信息"); txtEditModuleNo.Focus(); txtEditModuleNo.SelectAll(); return; } //验证计划日期大于添加日期 if (DateTime.Compare(dtpEditDrReleaseTarget.Value, dtpEditAddedDate.Value) < 0) { MessageBox.Show("计划发图日期必须大于添加日期,请认真检查", "验证信息"); return; } #endregion //封装制图计划对象 DrawingPlan objDrawingPlan = new DrawingPlan() { DrawingPlanId = Convert.ToInt32(txtEditDrawingPlanId.Text), ProjectId = Convert.ToInt32(cobEditODPNo.SelectedValue), Item = txtEditItem.Text.Trim(), Model = cobEditModel.Text, ModuleNo = Convert.ToInt32(txtEditModuleNo.Text.Trim()), DrReleaseTarget = Convert.ToDateTime(dtpEditDrReleaseTarget.Text), SubTotalWorkload = Convert.ToDecimal(txtEditSubTotalWorkload.Text.Trim()), AddedDate = Convert.ToDateTime(dtpEditAddedDate.Text.Trim()) }; //调用后台方法修改对象 try { if (objDrawingPlanService.EditDrawingPlan(objDrawingPlan) == 1) { MessageBox.Show("修改计划成功!", "提示信息"); grbEditDrawingPlan.Visible = false; btnQueryAllPlan_Click(null, null);//同步刷新显示数据 } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 添加计划记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddDrawingPlan_Click(object sender, EventArgs e) { #region 数据验证 if (cobModel.SelectedIndex == -1) { MessageBox.Show("请选择烟罩型号", "验证信息"); cobModel.Focus(); return; } if (txtModuleNo.Text.Trim().Length == 0) { MessageBox.Show("请输烟罩分段数量", "验证信息"); txtModuleNo.Focus(); return; } if (cobODPNo.SelectedIndex == -1) { MessageBox.Show("请输入选择或输入项目编号,如果没有,请到项目列表中添加后再选择", "验证信息"); cobODPNo.Focus(); return; } //验证数量是数字 if (!DataValidate.IsInteger(txtModuleNo.Text.Trim())) { MessageBox.Show("烟罩分段数量必须是数字", "验证信息"); txtModuleNo.Focus(); txtModuleNo.SelectAll(); return; } #endregion //封装制图计划对象 DrawingPlan objDrawingPlan = new DrawingPlan() { ProjectId = Convert.ToInt32(cobODPNo.SelectedValue), Item = txtItem.Text.Trim(), Model = cobModel.Text, ModuleNo = Convert.ToInt32(txtModuleNo.Text.Trim()), DrReleaseTarget = Convert.ToDateTime(dtpDrReleaseTarget.Text), SubTotalWorkload = Convert.ToDecimal(txtSubTotalWorkload.Text.Trim()) }; //提交添加 try { int drawingPlanId = objDrawingPlanService.AddDraingPlan(objDrawingPlan); if (drawingPlanId > 1) { //提示添加成功 MessageBox.Show("制图计划添加成功", "提示信息"); //刷新显示 btnQueryByProjectId_Click(null, null); //清空内容 //cobUserId.SelectedIndex = -1;//不清空制图人员 //cobModel.SelectedIndex = -1;//不清空型号 //foreach (Control item in Controls) //{ // if (item == txtODPNo) return;//不清空ODPNo,方便查询 // if (item is TextBox) // { // item.Text = ""; // } //} txtSubTotalWorkload.Text = ""; txtModuleNo.Text = ""; txtItem.Text = ""; txtItem.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//登录 private void btnLogin_Click(object sender, RoutedEventArgs e) { //数据验证 if (txtLogId.Text.Trim().Length == 0)//对账号的验证 { MessageBox.Show("请输入登录账号!", "登录提示"); txtLogId.Focus(); return; }//使用正则表达式进行判断 if (DataValidate.IsInteger(txtLogId.Text.Trim()) == false)//调用这个DataValidate(类)的Isinteger这个方法表示验证某个文本框是否为正整数 { MessageBox.Show("请输入正确账号!(纯数字格式)", "登录提示"); txtLogId.Focus(); return; }//密码的验证 if (txtLogPwd.Password.Length == 0)//在这个文本框中如果输入的账号长度0,则这个文本框为空 { MessageBox.Show("请输入登录密码!", "登录提示"); txtLogPwd.Focus(); return; } #region//第一种登录方式 //输入的账号密码 //在Model中获取Admins Admins admin = new Admins() { //1.判断LoginId中是否是数字2.验证Common里面的DataValidate LoginId = Convert.ToInt32(txtLogId.Text.Trim()), LoginPwd = txtLogPwd.Password //获取账号密码后和Admins中属性做比较 对应 }; //和后台交互查询,判断登录信息是否正确 //导入BLL(业务逻辑层) try { //拿到数据查看是否正确,然后传给MainWindow从数据库中获取值和拿到的数据作比较 Admins mainuse = new AdminManager().GetAdmins(admin); if (mainuse == null)//内容不能为空 { MessageBox.Show("用户账号不存在!", "提示信息"); txtLogId.Focus(); } else { if (mainuse.LoginPwd == txtLogPwd.Password)//输入的密码和数据库的密码作比较 { //保存登录信息 App.CurrentAdmin = mainuse; this.DialogResult = true;//为true时关闭这个窗口 this.Close(); } else { MessageBox.Show("用户密码错误!", "提示信息"); txtLogPwd.Focus(); } } } catch (Exception) { MessageBox.Show("服务器连接异常,登录失败!请检查您的网络!"); } #endregion }