/** * 仅支持修改类型 * 判空,判存在 * */ private void ModifyMemberButton_Click(object sender, RoutedEventArgs e) { if (MemberName.Text == "") { MessageBox.Show("员工名不能为空"); return; } if (Assistants.IsChecked == false && Manager.IsChecked == false) { MessageBox.Show("请选择店员类型"); return; } int ModifyResult = ManagerConnector.ModifyManagerType(MemberName.Text, (Assistants.IsChecked == true) ? 0 : 1); if (ModifyResult == 1) { MessageBox.Show("修改成功"); MemberName.Text = ""; LoadAllManagers(); } else if (ModifyResult == -1) { MessageBox.Show("不存在的店员"); return; } else { MessageBox.Show("修改失败"); return; } }
/* * 添加店员或经理 * 默认密码123456不可更改 * 判空,查重 * */ private void AddMemberButton_Click(object sender, RoutedEventArgs e) { if (MemberName.Text == "") { MessageBox.Show("员工名不能为空"); return; } if (Assistants.IsChecked == false && Manager.IsChecked == false) { MessageBox.Show("请选择店员类型"); return; } int result = ManagerConnector.InsertManager(MemberName.Text, (Assistants.IsChecked == true) ? 0 : 1); if (result == 1) { MessageBox.Show("插入成功"); MemberName.Text = ""; LoadAllManagers(); } else if (result == -1) { MessageBox.Show("已存在的店员"); return; } else { MessageBox.Show("插入失败"); return; } }
private void Button1_Click(object sender, RoutedEventArgs e) { /* * 判断输入框是否为空 */ if (textBox1.Text == "") { MessageBox.Show("用户名不能为空!"); return; } else if (passwordBox1.Password == "") { MessageBox.Show("密码不能为空!"); return; } else if (textBox2.Text == "") { MessageBox.Show("验证码不能为空!"); return; } /* * 判断验证码是否正确 */ else if (!textBox2.Text.ToString().ToUpper().Equals(validCode.CheckCode)) { MessageBox.Show("验证码错误!"); validCode = new ValidCode(5, ValidCode.CodeType.Alphas); this.image1.Source = BitmapFrame.Create(validCode.CreateCheckCodeImage()); return; } int result = ManagerConnector.Login(textBox1.Text, passwordBox1.Password); if (result == -2) { MessageBox.Show("用户名或密码错误!"); textBox1.Text = ""; passwordBox1.Password = ""; textBox2.Text = ""; LoadValidCode(); } else { MainMenuWindow mainMenuWindow = new MainMenuWindow(result); mainMenuWindow.Show(); this.Close(); } }
/* * 加载所有的店员 * */ private void LoadAllManagers() { int count = ManagerList.Items.Count; for (int i = 0; i < count; i++) { ManagerList.Items.RemoveAt(0); } List <ManagerInfoData> managerInfoDatas = ManagerConnector.GetManagerInfoDatas(); foreach (ManagerInfoData manager in managerInfoDatas) { InfomationTable infomationTable = new InfomationTable(manager); ManagerList.Items.Add(infomationTable); } }
/* * 删除,判选 * */ private void DeleteMemberButton_Click(object sender, RoutedEventArgs e) { if (ManagerList.SelectedIndex == -1) { MessageBox.Show("没有选中员工"); return; } int DeleteResult = ManagerConnector.DeleteManager(((InfomationTable)ManagerList.SelectedItem).Left_TB.Text); if (DeleteResult == 1) { MessageBox.Show("删除成功"); MemberName.Text = ""; LoadAllManagers(); } else { MessageBox.Show("修改失败"); return; } }