/// <summary> /// 给角色分配权限 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnGiveRoleRights_Click(object sender, EventArgs e) { //判断是否有勾选左侧权限树 遍历权限树 或者权限Id集合 List <int> userSelectRightIds = TreeViewHelper.GetRightIds(this.tvAllRightList.TopNode); if (userSelectRightIds.Count == 0) { MessageBox.Show("请勾选权限再为当前角色分配!!!"); return; } //有勾选 先删除角色所有的权限 然后新增左侧勾选的权限 var selectRoleId = ((RoleDto)this.cboRoleList.SelectedItem).RoleId; try { var roleService = AutofacContainer.GetInstance().GetObject <IRoleService>(); var result = roleService.GiveRoleRights(selectRoleId, userSelectRightIds); if (result) { MessageBox.Show("为当前角色分配权限成功!"); cboRoleList_SelectedIndexChanged(null, null); } } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message); } }
/// <summary> /// 查询用户拥有的权限 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvUserToSearchRight_SelectionChanged(object sender, EventArgs e) { var dataGridViewRow = this.dgvUserToSeachRight.CurrentRow; int userId = 0; if (dataGridViewRow != null) { userId = ((UserDto)dataGridViewRow.DataBoundItem).UserId; this.txtUserId.Text = userId.ToString(); } try { var userService = AutofacContainer.GetInstance().GetObject <IUserService>(); List <RightDto> userRights = userService.GetUserRights(userId); //创建根节点 this.UserRightsTView.Nodes.Clear();//清空节点 TreeNode rootNode = new TreeNode() { Text = "该用户拥有的权限", ForeColor = Color.Gold, Tag = 1 }; this.UserRightsTView.Nodes.Add(rootNode); //查找一级节点 在数据中PID==0 CreateChildNode(rootNode, 0, userRights); this.UserRightsTView.Nodes[0].ExpandAll();//展开一级菜单 } catch (Exception exception) { MessageBox.Show(exception.Message); } }
/// <summary> /// 查看订单领料详细信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void BtnDetail_Click(object sender, EventArgs e) { var dgvRow = this.dgvOrderlist.CurrentRow; if (dgvRow == null) { MessageBox.Show("请选中一个订单"); return; } var dgvOrderListCurrentRow = this.dgvOrderlist.CurrentRow; if (dgvOrderListCurrentRow != null) { var orderId = ((OrderCollectionDto)dgvOrderListCurrentRow.DataBoundItem).OrderId; var collectionService = AutofacContainer.GetInstance().GetObject <ICollectionService>(); var collectionList = await collectionService.GetOrderIdCollectionList(orderId); var detailForm = new FrmDetail($"订单:{orderId}领料详情", collectionList); detailForm.ShowDialog(); } }
/// <summary> /// 查询角色拥有的权限 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cboRoleList_SelectedIndexChanged(object sender, EventArgs e) { if (_firstMenuRightList == null) { return; } var selectRoleId = ((RoleDto)this.cboRoleList.SelectedItem).RoleId; var roleService = AutofacContainer.GetInstance().GetObject <IRoleService>(); //获取角色拥有的权限 List <RightDto> roleIdRightList = roleService.GetRightListByRoleId(selectRoleId); //创建根节点 this.tvRoleRightList.Nodes.Clear();//清空节点 TreeNode rootNode = new TreeNode() { Text = "该角色拥有的权限", ForeColor = Color.Gold, Tag = 1 }; this.tvRoleRightList.Nodes.Add(rootNode); CreateChildNode(rootNode, 0, roleIdRightList); this.tvRoleRightList.ExpandAll();//展开所有菜单 }
/// <summary> /// 更新账户信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdateUser_Click(object sender, EventArgs e) { var userDto = CheckAndGetBindingDto(); if (userDto.UserId == 0) { return; } var userName = this.txtUserName.Text.Trim(); var userPwd = this.txtUserPwd.Text.Trim(); //检查 if (userName.Length == 0 || userPwd.Length == 0) { MessageBox.Show("修改为空么? 请输入用户名和密码"); return; } try { var userService = AutofacContainer.GetInstance().GetObject <IUserService>(); var userEditDto = new UserEditDto() { UserId = userDto.UserId, UserName = userName, UserPwd = userPwd, CreateTime = DateTime.Now }; var result = userService.UpdateUser(userEditDto); if (result) { MessageBox.Show($"更新用户:{userName}成功!"); #region 界面自动刷新----保留这里 var dataList = (IList <UserDto>)_dgvBindingSource.List; var first = dataList.FirstOrDefault(o => o.UserId == userDto.UserId); if (first != null) { first.UserName = userName; first.UserPwd = userPwd; dgvUserList.SelectionChanged -= dgvUserList_SelectionChanged; _dgvBindingSource.ResetBindings(true); //this.dgvUserList.ClearSelection(); dgvUserList.SelectionChanged += dgvUserList_SelectionChanged; } #endregion } } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message); } }
/// <summary> /// 删除角色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelRole_Click(object sender, EventArgs e) { if (this.ListBoxRoles.SelectedItems.Count != 1) { MessageBox.Show("不要多选或者不选 ok?,选择一项再删除"); return; } var roleId = Convert.ToInt32(this.ListBoxRoles.SelectedValue); try { var roleService = AutofacContainer.GetInstance().GetObject <IRoleService>(); var result = roleService.DeleteRole(roleId); if (result) { MessageBox.Show("删除角色 以及相应的用户角色关系 角色权限关系 成功!"); //数据绑定 var dataList = (IList <RoleDto>) this.ListBoxRoles.DataSource; var first = dataList.FirstOrDefault(o => o.RoleId == roleId); dataList.Remove(first); } } catch (Exception exception) { MessageBox.Show("异常:" + exception.Message); } }
public FrmLogin() { InitializeComponent(); //实例化单例容器 AutofacContainer.GetInstance(); }
private void GetInfo(DateTime datetime, bool month) { var dayFinishedService = AutofacContainer.GetInstance().GetObject <IDayFinishedService>(); var dto = dayFinishedService.GetFinishedInfo(datetime, month); this.lbCollection.Text = dto.CollectionCount.ToString(); this.lbAssemble.Text = dto.AssembleCount.ToString(); this.lbFirst.Text = dto.FistTestCount.ToString(); this.lbLast.Text = dto.LastTestCount.ToString(); this.lbStorage.Text = dto.StorageCount.ToString(); }
/// <summary> /// 装载角色列表 /// </summary> private async Task AsyncLoadData_RoleList() { var roleService = AutofacContainer.GetInstance().GetObject <IRoleService>(); BindingList <RoleDto> roleList = await roleService.GetRoleList(); this.cboRoleList.DataSource = roleList; this.ListBoxRoles.DataSource = roleList; //消除默认选中事件 btnClear_Click(null, null); }
/// <summary> /// 计划单号不能重复 在此检验 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PlanNoTxtBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { var orderService = AutofacContainer.GetInstance().GetObject <IOrderService>(); if (orderService.PlanNoExist(this.PlanNoTxtBox.Text.Trim())) { MessageBox.Show("当前计划单号" + this.PlanNoTxtBox.Text + "数据库已存在"); this.PlanNoTxtBox.Select(); } } }
/// <summary> /// 订单入库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// private async void textBox_StorageNumber_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (!RegexHelper.RegExpNumber.IsMatch(this.textBox_StorageNumber.Text.Trim())) { MessageBox.Show("入库数量应该是数字"); return; } var dgvOrderListCurrentRow = this.dgvOrderList.CurrentRow; if (dgvOrderListCurrentRow == null) { return; } //从界面获取计划单号 和 入库数量 var planId = this.textBox_Storage.Text.Trim(); var currentStorageCount = Convert.ToInt32(this.textBox_StorageNumber.Text); var orderStorageDto = (dgvOrderListCurrentRow.DataBoundItem as OrderStorageDto); try { var storageService = AutofacContainer.GetInstance().GetObject <IStorageService>(); var result = await storageService.OrderStorage(orderStorageDto, currentStorageCount); if (!result.IsSucceed) { MessageBox.Show(result.Message); } else { //获取今日完成数量 var datFinishedService = AutofacContainer.GetInstance().GetObject <IDayFinishedService>(); this.DayStorageCount.Text = datFinishedService.GetTodayFinishedInfo(DateTime.Now).StorageCount.ToString(); this.textBox_Storage.Text = ""; this.textBox_StorageNumber.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// 从数据库获取分页的数据 /// </summary> /// <param name="pageIndex"> 哪一页的数据</param> /// <returns></returns> private BindingList <OrderGatherSearchDto> LoadData(int pageIndex) { var gatherSearchService = AutofacContainer.GetInstance().GetObject <IGatherSearchService>(); var result = gatherSearchService.GetOrderList(pageIndex, PageSize); var totalCount = result.TotalCount; //分页数量 _pageCount = (int)(totalCount % PageSize == 0 ? totalCount / PageSize : (totalCount / PageSize) + 1); _currentPage = _pageCount == 0 ? 0 : pageIndex; return(result.CurrentPageData); }
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { //修改影响 if (((TabControl)sender).SelectedTab == tabControl1.TabPages[0]) { this.ListBoxRoles.SelectedIndex = -1; } //重新加载用户 if (((TabControl)sender).SelectedTab == tabControl1.TabPages[2]) { var userService = AutofacContainer.GetInstance().GetObject <IUserService>(); this.dgvUserToSeachRight.DataSource = userService.GetUserList(); } }
private async void BtnCollectionDetail_Click(object sender, EventArgs e) { var orderId = CheckAndGetOrder().OrderId; if (orderId != 0) { var collectionService = AutofacContainer.GetInstance().GetObject <ICollectionService>(); var collectionList = await collectionService.GetOrderIdCollectionList(orderId); var detailForm = new FrmDetail($"订单:{orderId}领料详情", collectionList); detailForm.ShowDialog(); } }
/// <summary> /// 从数据库获取分页的数据 /// </summary> /// <param name="pageIndex"> 哪一页的数据</param> /// <param name="orderStorageState">获取订单状况</param> /// <returns></returns> private BindingList <OrderStorageDto> LoadData(int pageIndex, OrderStorageState orderStorageState) { var orderService = AutofacContainer.GetInstance().GetObject <IOrderService>(); var result = orderService.GetOrders(pageIndex, PageSize, orderStorageState); var totalCount = result.TotalCount; //分页数量 _pageCount = (int)(totalCount % PageSize == 0 ? totalCount / PageSize : (totalCount / PageSize) + 1); _currentPage = _pageCount == 0 ? 0 : pageIndex; return(result.CurrentPageData); }
/// <summary> /// 从数据库获取分页的数据 /// </summary> /// <param name="pageIndex"> 哪一页的数据</param> /// <returns></returns> private BindingList <DayFinishedDto> LoadData(int pageIndex) { var dayFinishedService = AutofacContainer.GetInstance().GetObject <IDayFinishedService>(); var result = dayFinishedService.GetDayFinishedList(pageIndex, PageSize); var totalCount = result.TotalCount; //分页数量 _pageCount = (int)(totalCount % PageSize == 0 ? totalCount / PageSize : (totalCount / PageSize) + 1); _currentPage = _pageCount == 0 ? 0 : pageIndex; return(result.CurrentPageData); }
public FrmStorage() { InitializeComponent(); this.dgvOrderList.AutoGenerateColumns = false; this.dgvOrderList.DataSource = _dgvBindingSource; MultiThreadingBindingOrderData(_currentPage, _orderStorageState); //获取今日完成数量 var datFinishedService = AutofacContainer.GetInstance().GetObject <IDayFinishedService>(); this.DayStorageCount.Text = datFinishedService.GetTodayFinishedInfo(DateTime.Now).StorageCount.ToString(); }
private async void BtnStorageDetail_Click(object sender, EventArgs e) { var orderId = CheckAndGetOrderId(); if (orderId != 0) { var storageService = AutofacContainer.GetInstance().GetObject <IStorageService>(); var storageList = await storageService.GetOrderStorageList(orderId); var detailForm = new FrmDetail($"订单:{orderId}入库详情", storageList); detailForm.ShowDialog(); } }
private void DgvOrderList_SelectionChanged(object sender, EventArgs e) { var dayFinishedDto = CheckAndGetBindingDto(); if (dayFinishedDto.SynchronizationFlag == 0) { var dayFinishedService = AutofacContainer.GetInstance().GetObject <IDayFinishedService>(); var result = dayFinishedService.SynchronizeTestDataToLocal(dayFinishedDto); if (result) { MultiThreadingBindingOrderData(_currentPage); MessageBox.Show("从数据库同步测试数据成功"); } } }
private async void BtnAssembleDetail_Click(object sender, EventArgs e) { var orderId = CheckAndGetOrder().OrderId; if (orderId != 0) { var assembleService = AutofacContainer.GetInstance().GetObject <IAssembleService>(); var assembleList = await assembleService.GetOrderAssembleList(orderId); var detailForm = new FrmDetail($"订单:{orderId}组装详情", assembleList); detailForm.ShowDialog(); } }
/// <summary> /// 编辑角色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEidtRoleName_Click(object sender, EventArgs e) { var name = this.txtRoleName.Text.Trim(); var description = this.txtRoleDesc.Text.Trim(); if (name.Length == 0 || description.Length == 0) { MessageBox.Show("请输入角色名和描述再修改!!"); return; } var roleId = Convert.ToInt32(this.ListBoxRoles.SelectedValue); try { var roleService = AutofacContainer.GetInstance().GetObject <IRoleService>(); var result = roleService.UpdateRole(new RoleDto() { RoleId = roleId, RoleDesc = description, RoleName = name }); if (result) { MessageBox.Show("修改角色成功"); //更新界面 var dataList = (IList <RoleDto>)ListBoxRoles.DataSource; var first = dataList.FirstOrDefault(o => o.RoleId == roleId); if (first != null) { first.RoleDesc = description; first.RoleName = name; ((BindingList <RoleDto>)ListBoxRoles.DataSource).ResetBindings(); } } } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message); } }
public FrmAssemble() { InitializeComponent(); this.dgvOrderlist.AutoGenerateColumns = false; this.dgvOrderlist.DataSource = _dgvBindingSource; MultiThreadingBindingOrderData(_currentPage, _orderAssembleState); //组装界面 this.listRequiredFinish.DataSource = unFinishedBoxes; //获取今日完成数量 var datFinishedService = AutofacContainer.GetInstance().GetObject <IDayFinishedService>(); this.DayAssembleCount.Text = datFinishedService.GetTodayFinishedInfo(DateTime.Now).AssembleCount.ToString(); }
public FrmCollection() { InitializeComponent(); SetUserControl(Program.objCurrentLoginUser.UserId); //领料界面 this.dgvOrderlist.AutoGenerateColumns = false; this.dgvOrderlist.DataSource = _dgvBindingSource; MultiThreadingBindingOrderData(_currentPage, _orderCollectionState); //获取今日完成数量 var datFinishedService = AutofacContainer.GetInstance().GetObject <IDayFinishedService>(); this.DayCollectionCount.Text = datFinishedService.GetTodayFinishedInfo(DateTime.Now).CollectionCount.ToString(); }
/// <summary> /// 选择不同的订单时 获取已经领取的物料数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvOrderList_SelectionChanged(object sender, EventArgs e) { var dgvOrderListCurrentRow = this.dgvOrderlist.CurrentRow; if (dgvOrderListCurrentRow != null) { var orderId = ((OrderCollectionDto)dgvOrderListCurrentRow.DataBoundItem).OrderId; var orderService = AutofacContainer.GetInstance().GetObject <IOrderService>(); var collectionService = AutofacContainer.GetInstance().GetObject <ICollectionService>(); var count = collectionService.GetOrderCollectionNumber(orderId); //通过orderId 获取已经领料的数量 this.lbMaterialCount.Text = count.ToString(); orderService.UpdateOrderCollectionNumber(orderId, count); } }
private void BtnStorageTagUndo_Click(object sender, EventArgs e) { var orderStorageDto = CheckSelect(); if (orderStorageDto != null) { try { var storageService = AutofacContainer.GetInstance().GetObject <IStorageService>(); var result = storageService.ChangeOrderStorageState(orderStorageDto, false); if (result) { var orderId = orderStorageDto.OrderId; #region 刷新dgv var dataList = (IList <OrderStorageDto>)_dgvBindingSource.List; var first = dataList.FirstOrDefault(o => o.OrderId == orderId); if (first != null) { dataList.Remove(first); } //临时过渡使用 因为要用到SelectionChanged同步以前的数据 dgvOrderList.SelectionChanged -= dgvOrderList_SelectionChanged; _dgvBindingSource.ResetBindings(true); this.dgvOrderList.ClearSelection(); dgvOrderList.SelectionChanged += dgvOrderList_SelectionChanged; #endregion MessageBox.Show( $"订单:{orderStorageDto.PlanNo} 入库数量:{orderStorageDto.OrderStorageCount ?? 0}取消标记成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// 删除用户 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelUser_Click(object sender, EventArgs e) { var userDto = CheckAndGetBindingDto(); if (userDto.UserId == 0) { return; } DialogResult dialogResult = MessageBox.Show(" 此操作非常危险 您正在删除账号:" + userDto.UserName + " 该账号关联的用户角色删除?确定么", "谨慎操作", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.Cancel) { return; } try { var userService = AutofacContainer.GetInstance().GetObject <IUserService>(); var result = userService.DeleteUser(userDto); if (result) { MessageBox.Show("删除用户:" + userDto.UserName + "及角色信息成功!"); //数据绑定 var dataList = (IList <UserDto>)_dgvBindingSource.List; var first = dataList.FirstOrDefault(o => o.UserId == userDto.UserId); dataList.Remove(first); dgvUserList.SelectionChanged -= dgvUserList_SelectionChanged; _dgvBindingSource.ResetBindings(true); this.dgvUserList.ClearSelection(); dgvUserList.SelectionChanged += dgvUserList_SelectionChanged; } } catch (Exception ex) { MessageBox.Show(" 出现异常:" + ex.Message); } }
/// <summary> /// 添加角色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddRole_Click(object sender, EventArgs e) { var name = this.txtRoleName.Text.Trim(); var description = this.txtRoleDesc.Text.Trim(); if (name.Length == 0 || description.Length == 0) { MessageBox.Show("请输入角色名和描述再添加!!"); return; } try { var roleService = AutofacContainer.GetInstance().GetObject <IRoleService>(); var roleDto = new RoleDto() { RoleName = name, RoleDesc = description }; var result = roleService.AddRole(roleDto); if (result) { MessageBox.Show("添加角色成功"); //更新界面 var dataList = (IList <RoleDto>)ListBoxRoles.DataSource; dataList.Add(roleDto); ListBoxRoles.ClearSelected(); ListBoxRoles.SelectedIndex = dataList.Count - 1; //消除默认选中事件 //btnClear_Click(null, null); } } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message); } }
//临时存放 private void dgvOrderList_SelectionChanged(object sender, EventArgs e) { var dgvOrderlistCurrentRow = this.dgvOrderlist.CurrentRow; if (dgvOrderlistCurrentRow != null) { var orderId = ((OrderAssembleDto)dgvOrderlistCurrentRow.DataBoundItem).OrderId; var orderService = AutofacContainer.GetInstance().GetObject <IOrderService>(); var assembleService = AutofacContainer.GetInstance().GetObject <IAssembleService>(); var finishedCount = assembleService.GetOrderAssembleFinishedCount(orderId); var order = orderService.GetEditOrderById(orderId); order.OrderAssembleCount = finishedCount; orderService.EditOrder(order); } }
/// <summary> /// 启用账号 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEnable_Click(object sender, EventArgs e) { var userDto = CheckAndGetBindingDto(); if (userDto.UserId == 0) { return; } if (userDto.StatusId == 1) { MessageBox.Show("本身就没禁用,无需启用!!"); return; } var userService = AutofacContainer.GetInstance().GetObject <IUserService>(); var result = userService.UpdateUserState(userDto); if (result) { MessageBox.Show("账号启用成功!"); #region 界面自动刷新----保留这里 var dataList = (IList <UserDto>)_dgvBindingSource.List; var first = dataList.FirstOrDefault(o => o.UserId == userDto.UserId); if (first != null) { first.StatusId = 1; dgvUserList.SelectionChanged -= dgvUserList_SelectionChanged; _dgvBindingSource.ResetBindings(true); //this.dgvUserList.ClearSelection(); dgvUserList.SelectionChanged += dgvUserList_SelectionChanged; } #endregion //this.dgvUserList.Rows[_dgvBindingSource.Count - 1].Selected = true; } }
private void Register(UserRegisterDto registerDto) { try { var loginService = AutofacContainer.GetInstance().GetObject <IUserService>(); var notifications = AutofacContainer.GetInstance().GetObject <INotificationHandler <DomainNotification> >(); // 强类型转换 var _notifications = (DomainNotificationHandler)notifications; loginService.UserRegister(registerDto); var notifyList = _notifications.GetNotifications(); var list = notifyList.Where(o => o.Key == "success").ToList(); if (list.Count > 0) { var str = string.Join(" ", list.Select(o => o.Value).ToList()); MessageBox.Show(str); rBtnLogin.Checked = true; this.lbPwdConfirm.Visible = false; this.txtUserPwdConfirm.Visible = false; this.btnLogin.Text = "登录"; } else { var str = string.Join(" ", notifyList.Select(o => o.Value).ToList()); MessageBox.Show(str); } //清空领域通知 _notifications.Dispose(); } catch (Exception e) { MessageBox.Show(e.Message); } }