/// <summary> /// 单个或多个删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDel_Click(object sender, EventArgs e) { if (dgvRoles.SelectedRows.Count > 0) { string titleMsg = "删除角色"; if (MsgBoxHelper.MsgBoxConfirm(titleMsg, "您确定要删除选择的角色吗?会连同与角色相关的数据一并删除?") == DialogResult.Yes) { List <int> roleIds = new List <int>(); foreach (DataGridViewRow row in dgvRoles.SelectedRows) { RoleInfoModel roleInfo = row.DataBoundItem as RoleInfoModel; roleIds.Add(roleInfo.RoleId); } bool bl = RequestStar.DeleteRoles(roleIds, 0); if (bl) { MsgBoxHelper.MsgBoxShow(titleMsg, $"选择角色信息删除成功!"); LoadAllRoles(); } else { MsgBoxHelper.MsgErrorShow($"选择角色信息删除失败!"); return; } } } else { MsgBoxHelper.MsgErrorShow("请选择要删除的角色信息!"); return; } }
/// <summary> /// 删除工具组 /// </summary> /// <param name="tgInfo"></param> private void DeleteToolGroupInfo(ToolGroupInfoModel tgInfo) { string title = "删除工具组"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要删除该工具组数据吗?") == DialogResult.Yes) { //先检查是否已添加工具菜单数据 List <int> tgIds = new List <int>(); tgIds.Add(tgInfo.TGroupId); if (!RequestStar.HasToolMenus(tgIds)) { bool bl = RequestStar.LogicDeleteToolGroup(tgInfo.TGroupId); if (bl) { MsgBoxHelper.MsgBoxShow(title, $"工具组:{tgInfo.TGroupName} 删除成功!"); LoadToolGroups(); } else { MsgBoxHelper.MsgErrorShow($"工具组:{tgInfo.TGroupName} 删除失败!"); return; } } else { MsgBoxHelper.MsgErrorShow($"工具组:{tgInfo.TGroupName} 已添加工具菜单项,不能删除!"); return; } } }
/// <summary> /// 删除菜单信息 一条或多条都可以 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnDelete_Click(object sender, EventArgs e) { if (dgvMenus.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow("请选择要删除的菜单信息!"); return; } if (MsgBoxHelper.MsgBoxConfirm("菜单删除", "您确定要删除选择的菜单信息吗?删除菜单会连同菜单及其角色菜单关系数据一并删除?") == DialogResult.Yes) { List <int> menuIds = new List <int>(); foreach (DataGridViewRow row in dgvMenus.SelectedRows) { MenuInfoModel menuInfo = row.DataBoundItem as MenuInfoModel; menuIds.Add(menuInfo.MId); } bool bl = RequestStar.DeleteMenu(menuIds, 0); if (bl) { MsgBoxHelper.MsgBoxShow("删除菜单", "选择的菜单信息删除成功!"); LoadMenuList(); } else { MsgBoxHelper.MsgErrorShow("选择的菜单信息删除失败!"); return; } } }
/// <summary> /// 恢复 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnRecover_Click(object sender, EventArgs e) { if (dgvTMenus.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow("您没有选择要恢复的工具菜单项!"); return; } string title = "恢复工具菜单项"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要恢复这些工具菜单项数据吗?会连同角色工具菜单关系数据一并恢复?") == DialogResult.Yes) { //获取要恢复的工具菜单编号 List <int> delIds = new List <int>(); foreach (DataGridViewRow row in dgvTMenus.SelectedRows) { ToolMenuInfoModel tmInfo = row.DataBoundItem as ToolMenuInfoModel; delIds.Add(tmInfo.TMenuId); } //恢复操作 bool bl = RequestStar.RecoverToolMenus(delIds); if (bl) { MsgBoxHelper.MsgBoxShow(title, "选择的工具菜单项恢复成功!"); LoadTMenuList(); } else { MsgBoxHelper.MsgErrorShow("选择的工具菜单项恢复失败!"); return; } } }
/// <summary> /// 启用或停用用户 /// </summary> /// <param name="type"></param> /// <param name="userId"></param> private void UpdateUserState(int type, int userId) { string msg = ""; if (type == 1) { msg = "启用"; } else { msg = "停用"; } if (MsgBoxHelper.MsgBoxConfirm($"用户{msg}", $"您确定要{msg}该账号吗?") == DialogResult.Yes) { bool bl = false; if (type == 1) { bl = RequestStar.EnableUser(userId); } else { bl = RequestStar.StopUser(userId); } if (bl) { MsgBoxHelper.MsgBoxShow($"用户{msg}", $"该用户{msg}成功!"); LoadUserList(); } else { MsgBoxHelper.MsgErrorShow($"该用户{msg}失败!"); return; } } }
private void btnRecover_Click(object sender, EventArgs e) { string title = "恢复工具组"; if (dgvGroups.SelectedRows.Count > 0) { if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要恢复这些工具组数据吗?") == DialogResult.Yes) { //获取要恢复的Id List <int> tgIds = new List <int>(); foreach (DataGridViewRow row in dgvGroups.SelectedRows) { ToolGroupInfoModel tgInfo = row.DataBoundItem as ToolGroupInfoModel; tgIds.Add(tgInfo.TGroupId); } bool bl = RequestStar.RecoverToolGroups(tgIds); if (bl) { MsgBoxHelper.MsgBoxShow(title, "这些工具组恢复成功!"); LoadToolGroups(); } else { MsgBoxHelper.MsgErrorShow("这些工具组恢复失败!"); return; } } } }
/*/// <summary> * /// 递归加载单位类别节点 * /// </summary> * /// <param name="list"></param> * /// <param name="pNode"></param> * /// <param name="pId"></param> * public static void AddTvUTypesNode(List<UnitTypeInfoModel> list, TreeNode pNode, int pId) * { * var pList = list.Where(ut => ut.ParentId == pId); * foreach (UnitTypeInfoModel ut in pList) * { * TreeNode node = FormUtility.CreateNode(ut.UTypeId.ToString(), ut.UTypeName); * pNode.Nodes.Add(node); * AddTvUTypesNode(list, node, ut.UTypeId); * } * } * * /// <summary> * /// 递归加载商品类别节点 * /// </summary> * /// <param name="list"></param> * /// <param name="pNode"></param> * /// <param name="pId"></param> * public static void AddTvGTypesNode(List<GoodsTypeInfoModel> list, TreeNode pNode, int pId) * { * var pList = list.Where(ut => ut.ParentId == pId); * foreach (GoodsTypeInfoModel gt in pList) * { * TreeNode node = FormUtility.CreateNode(gt.GTypeId.ToString(), gt.GTypeName); * pNode.Nodes.Add(node); * AddTvGTypesNode(list, node, gt.GTypeId); * } * }*/ /// <summary> /// 将DataGridView中数据导出到Excel /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list"></param> /// <param name="dgv"></param> /// <param name="fileName"></param> /// <param name="sheetName"></param> /// <param name="msg"></param> /// <param name="title"></param> public static void DataToExcel <T>(List <T> list, DataGridView dgv, string fileName, string sheetName, string msg, string title) { if (list != null && list.Count > 0) { string filePath = ""; FolderBrowserDialog fbdChoose = new FolderBrowserDialog(); if (fbdChoose.ShowDialog() == DialogResult.OK) { filePath = fbdChoose.SelectedPath; } if (string.IsNullOrEmpty(filePath)) { MsgBoxHelper.MsgErrorShow("请选择导出的位置!"); return; } if (filePath.LastIndexOf('/') != filePath.Length - 1) { filePath += "/"; } Dictionary <string, string> colsName = new Dictionary <string, string>(); foreach (DataGridViewColumn dc in dgv.Columns) { colsName.Add(dc.Name, dc.HeaderText); } int count = ExcelHelper.ListToExcel <T>(list, filePath + fileName, sheetName, colsName); if (count > 0) { MsgBoxHelper.MsgBoxShow(title, msg + "数据导出成功!"); } else { MsgBoxHelper.MsgErrorShow(msg + "数据导出失败!"); } } }
/// <summary> /// 处理行删除 恢复 永久删除 /// </summary> /// <param name="guInfo"></param> /// <param name="actType">0--恢复 1--假删除 2---真删除</param> private void DeleteUnit(GoodsUnitInfoModel guInfo, int actType) { string actMsg = ""; switch (actType) { case 0: actMsg = "恢复"; break; case 1: actMsg = "删除"; break; case 2: actMsg = "永久删除"; break; } string title = actMsg + "单位"; if (MsgBoxHelper.MsgBoxConfirm(title, $"您确定要{actMsg}该计量单位吗?") == DialogResult.Yes) { bool bl = false; switch (actType) { case 0: bl = RequestStar.GoodsUnitRecover(guInfo.GUnitId); break; case 1: if (!RequestStar.GetGoodsUnitUse(guInfo.GUnitName)) { bl = RequestStar.GoodsUnitLogicDelete(guInfo.GUnitId); } else { MsgBoxHelper.MsgErrorShow($"计量单位:{guInfo.GUnitName} 已经应用,不能删除!"); return; } break; case 2: bl = RequestStar.GoodsUnitDelete(guInfo.GUnitId); break; } string sucMsg = bl ? "成功" : "失败"; string msg = $"计量单位:{guInfo.GUnitName} {actMsg}{sucMsg}!"; if (bl) { MsgBoxHelper.MsgBoxShow(title, msg); LoadGUnitList(); } else { MsgBoxHelper.MsgErrorShow(msg); return; } } }
/// <summary> /// 删除、恢复、移除处理 /// </summary> /// <param name="isDeleted"></param> /// <param name="utInfo"></param> private void DeleteUnitType(int isDeleted, UnitTypeInfoModel utInfo) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"往来单位类别{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该往来单位类别?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果该类别添加了单位,不允许删除 bool hasAddUnits = RequestStar.IsAddUnits(utInfo.UTypeId); //如果该类别添加了子类别,不允许删除 bool hasChilds = RequestStar.IsAddChilds(utInfo.UTypeId); if (!hasAddUnits && !hasChilds) { bl = RequestStar.UnitTypeLogicDelete(utInfo.UTypeId); } else if (hasAddUnits) { MsgBoxHelper.MsgErrorShow($"该类别:{utInfo.UTypeName} 已经添加了单位,不能删除!"); return; } else if (hasChilds) { MsgBoxHelper.MsgErrorShow($"该类别:{utInfo.UTypeName} 已经添加了子类别,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.UnitTypeRecover(utInfo.UTypeId); break; case 2: //移除 bl = RequestStar.UnitTypeDelete(utInfo.UTypeId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"往来单位类别:{utInfo.UTypeName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadUnitTypeList(); if (isDeleted != 2) { ReloadCboParents(utInfo, true, isDeleted); } } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }
//isdeleted 1-LogicDelete 0 Recover 2 Delete private void DeleteGType(int isDeleted, GoodsTypeInfoModel gt) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"商品类别{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该商品类别?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果该类别添加了商品,不允许删除 bool hasAddGoods = RequestStar.CheckIsAddGoods(gt.GTypeId); //如果该类别添加了子类别,不允许删除 bool hasChilds = RequestStar.HasChildTypes(gt.GTypeId); if (!hasAddGoods && !hasChilds) { bl = RequestStar.GoodsTypeLogicDelete(gt.GTypeId); } else if (hasAddGoods) { MsgBoxHelper.MsgErrorShow($"该类别:{gt.GTypeName} 已经添加商品,不能删除!"); return; } else if (hasChilds) { MsgBoxHelper.MsgErrorShow($"该类别:{gt.GTypeName} 已经添加了子类别,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.GoodsTypeRecover(gt.GTypeId); break; case 2: //移除 bl = RequestStar.GoodsTypeDelete(gt.GTypeId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"商品类别:{gt.GTypeName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadGoodsTypeList(); if (isDeleted != 2) { ReloadCboParents(gt, true, isDeleted); } } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }
/// <summary> /// 提交响应 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { //接收页面信息输入 string roleName = txtRName.Text.Trim(); string remark = txtRemark.Text.Trim(); //判空处理 ---角色名称 if (string.IsNullOrEmpty(roleName)) { MsgBoxHelper.MsgErrorShow("角色名称不能为空!"); txtRName.Focus(); return; } //角色名称存在性---add 不能是已存在 update 没有修改名称(不用判断存在性) 名称已修改的情况(要判断) if (fModel.FId == 0 || (!string.IsNullOrEmpty(oldName) && oldName != roleName)) { if (RequestStar.ExistRoleName(roleName)) { MsgBoxHelper.MsgErrorShow("角色名称已经存在!"); txtRName.Focus(); return; } } //封装 RoleInfoModel roleInfo = new RoleInfoModel() { RoleName = roleName, Remark = remark, Creator = fModel.UName }; //调用方法(add) (update) bool bl = false; if (fModel.FId == 0) { bl = RequestStar.AddRoleInfo(roleInfo); } else if (fModel.FId > 0) { roleInfo.RoleId = fModel.FId; bl = RequestStar.UpdateRoleInfo(roleInfo); } //判断结果给出提示 if (bl) { MsgBoxHelper.MsgBoxShow($"{btnText}角色", $"角色:{roleName} 信息{btnText}成功!"); //刷新列表页面数据 fModel.ReLoad?.Invoke(); } else { MsgBoxHelper.MsgErrorShow($"角色:{roleName} 信息{btnText}失败!"); return; } }
/// <summary> /// 提交权限设置数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { int rId = cboRoles.SelectedValue.GetInt(); CheckIsAdmin(rId); if (rId == 0) { MsgBoxHelper.MsgErrorShow("请选择要设置权限的角色!"); return; } else { //1.获取菜单编号,工具栏菜单编号 List <int> tMenuIds = GetToolMenuIds(rId); List <int> menuIds = new List <int>(); menuIds = GetMenuIds(rId, menuIds, tvMenus.Nodes[0]); bool bl = false;//执行结果 if (menuIds.Count == 0 && tMenuIds.Count == 0) { MsgBoxHelper.MsgErrorShow("请设置该角色的菜单和工具栏权限!"); return; } else if (menuIds.Count == 0 && tMenuIds.Count > 0) { if (MsgBoxHelper.MsgBoxConfirm("权限设置", "您没有设置系统菜单权限,将会无法使用系统菜单功能!是否继续?") == DialogResult.Yes) { //设置工具栏权限 bl = RequestStar.SetRoleRight(rId, null, tMenuIds, uName); } } else if (menuIds.Count > 0 && tMenuIds.Count == 0) { if (MsgBoxHelper.MsgBoxConfirm("权限设置", "您没有设置工具菜单权限,将会无法使用工具栏菜单功能!是否继续?") == DialogResult.Yes) { //设置菜单权限 bl = RequestStar.SetRoleRight(rId, menuIds, null, uName); } } else { //设置菜单和工具栏权限 bl = RequestStar.SetRoleRight(rId, menuIds, tMenuIds, uName); } if (bl) { MsgBoxHelper.MsgBoxShow("权限设置", "权限设置保存成功!"); } else { MsgBoxHelper.MsgErrorShow("权限设置保存失败!"); return; } } }
/// <summary> /// 仓库信息删除处理(删除、恢复、移除) /// </summary> /// <param name="v"></param> /// <param name="storeInfo"></param> private void DeleteStoreInfo(int isDeleted, ViewStoreInfoModel storeInfo) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"仓库信息{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该仓库信息?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果仓库在使用中,不允许删除 bool isStoreUse = RequestStar.CheckStoreUse(storeInfo.StoreId); if (!isStoreUse) { bl = RequestStar.DeleteStoreInfo(storeInfo.StoreId); } else { MsgBoxHelper.MsgErrorShow($"该仓库:{storeInfo.StoreName} 在使用中,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.RecoverStoreInfo(storeInfo.StoreId, uName); break; case 2: //移除 bl = RequestStar.RemoveStoreInfo(storeInfo.StoreId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"仓库信息:{storeInfo.StoreName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadStoreList(); } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }
/// <summary> /// 删除商品信息处理(删除、恢复、移除) /// </summary> /// <param name="isDeleted"></param> /// <param name="goodsInfo"></param> private void DeleteGoodsInfo(int isDeleted, ViewGoodsInfoModel goodsInfo) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"商品信息{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该商品信息?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果商品在使用中,不允许删除 bool IsGoodsUse = RequestStar.CheckIsGoodsUse(goodsInfo.GoodsId); if (!IsGoodsUse) { bl = RequestStar.DeleteGoodsInfo(goodsInfo.GoodsId); } else { MsgBoxHelper.MsgErrorShow($"该商品:{goodsInfo.GoodsName}在使用中,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.RecoverGoodsInfo(goodsInfo.GoodsId, uName); break; case 2: //移除 bl = RequestStar.RemoveGoodsInfo(goodsInfo.GoodsId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"商品信息:{goodsInfo.GoodsName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadGoodsList(); } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }
/// <summary> /// 删除单位信息(删除、恢复、移除) /// </summary> /// <param name="isDeleted"></param> /// <param name="unitInfo"></param> private void DeleteUnitInfo(int isDeleted, ViewUnitInfoModel unitInfo) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"单位信息{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该单位信息?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果单位在使用中,不允许删除 bool isUnitUse = RequestStar.CheckUnitUse(unitInfo.UnitId); if (!isUnitUse) { bl = RequestStar.UnitLogicDelete(unitInfo.UnitId); } else { MsgBoxHelper.MsgErrorShow($"该单位:{unitInfo.UnitName} 在使用中,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.UnitRecover(unitInfo.UnitId); break; case 2: //移除 bl = RequestStar.UnitDelete(unitInfo.UnitId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"单位信息:{unitInfo.UnitName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadUnitList(); } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }
/// <summary> /// 提交响应 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { string gName = txtGroupName.Text.Trim(); if (string.IsNullOrEmpty(gName)) { MsgBoxHelper.MsgErrorShow("请输入组名!"); txtGroupName.Focus(); return; } if (tgId == 0 || (tgId > 0 && oldName != gName)) { if (RequestStar.ExistName(gName)) { MsgBoxHelper.MsgErrorShow("该组名已存在,请重新输入组名!"); txtGroupName.Focus(); return; } } ToolGroupInfoModel tgInfo = new ToolGroupInfoModel() { TGroupName = gName, Creator = uName, TGroupId = tgId }; bool bl = false; bl = RequestStar.ConfirmToolGroup(tgInfo); string actMsg = ""; actMsg = tgId == 0 ? "添加" : "修改"; string msgTitle = $"{actMsg}工具组"; string sucMsg = bl ? "成功" : "失败"; string msg = $"工具组:{gName} {actMsg} {sucMsg}!"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, msg); LoadToolGroups(); } else { MsgBoxHelper.MsgErrorShow(msg); return; } }
/// <summary> /// 删除类别信息处理(删除、恢复、移除) /// </summary> /// <param name="isDeleted"></param> /// <param name="st"></param> private void DeleteStoreType(int isDeleted, StoreTypeInfoModel st) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"仓库类别{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该仓库类别?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果该类别添加了仓库,不允许删除 bool hasAddStores = RequestStar.IsAddStores(st.STypeId); if (!hasAddStores) { bl = RequestStar.StoreTypeLogicDelete(st.STypeId); } else { MsgBoxHelper.MsgErrorShow($"该类别:{st.STypeName} 已经添加了仓库,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.StoreTypeRecover(st.STypeId); break; case 2: //移除 bl = RequestStar.StoreTypeDelete(st.STypeId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"仓库类别:{st.STypeName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadStoreTypeList(); } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }
/// <summary> /// 保存设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { int down = txtStockDown.Text.GetInt(); int up = txtStockUp.Text.GetInt(); bool blSave = RequestStar.SetMoreGoodsStockUpDown(sModel.StoreUpDownList, up, down); if (blSave) { MsgBoxHelper.MsgBoxShow("批量设置库存上下限", "保存成功!"); this.ReloadList?.Invoke(); this.Close(); } else { MsgBoxHelper.MsgErrorShow("保存失败!"); return; } }
private void dgvMenus_CellContentClick(object sender, DataGridViewCellEventArgs e) { Action act = () => { if (e.RowIndex >= 0) { DataGridViewCell curCell = dgvMenus.Rows[e.RowIndex].Cells[e.ColumnIndex]; string cellVal = curCell.FormattedValue.ToString(); MenuInfoModel menuInfo = dgvMenus.Rows[e.RowIndex].DataBoundItem as MenuInfoModel; switch (cellVal) { case "添加子菜单": ShowMenuInfoPage(3, menuInfo.MId); break; case "修改": ShowMenuInfoPage(2, menuInfo.MId); break; case "删除": if (MsgBoxHelper.MsgBoxConfirm("删除菜单", "您确定要删除该菜单信息吗?删除菜单会连同菜单及其角色菜单关系数据一并删除?") == DialogResult.Yes) { //删除 List <int> menuIds = new List <int>(); menuIds.Add(menuInfo.MId); bool bl = RequestStar.DeleteMenu(menuIds, 0); if (bl) { MsgBoxHelper.MsgBoxShow("删除菜单", $"菜单:{menuInfo.MName} 删除成功!"); LoadMenuList(); } else { MsgBoxHelper.MsgErrorShow($"菜单:{menuInfo.MName} 删除失败!"); return; } } break; } } }; act.TryCatch("菜单数据操作异常!"); }
/// <summary> /// 永久删除工具组 /// </summary> /// <param name="tgInfo"></param> private void RemoveToolGroupInfo(ToolGroupInfoModel tgInfo) { string title = "永久删除工具组"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要永久删除该工具组数据吗,删除了就无法再恢复?") == DialogResult.Yes) { bool bl = RequestStar.DeleteToolGroup(tgInfo.TGroupId); if (bl) { MsgBoxHelper.MsgBoxShow(title, $"工具组:{tgInfo.TGroupName} 永久删除成功!"); LoadToolGroups(); } else { MsgBoxHelper.MsgErrorShow($"工具组:{tgInfo.TGroupName} 永久删除失败!"); return; } } }
private void RecoverToolGroupInfo(ToolGroupInfoModel tgInfo) { string title = "恢复工具组"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要恢复该工具组数据吗?") == DialogResult.Yes) { bool bl = RequestStar.RecoverToolGroup(tgInfo.TGroupId); if (bl) { MsgBoxHelper.MsgBoxShow(title, $"工具组:{tgInfo.TGroupName} 恢复成功!"); LoadToolGroups(); } else { MsgBoxHelper.MsgErrorShow($"工具组:{tgInfo.TGroupName} 恢复失败!"); return; } } }
/// <summary> /// 单个角色信息删除 /// </summary> /// <param name="roleInfo"></param> private void DeleteRole(RoleInfoModel roleInfo) { string titleMsg = "删除角色"; if (MsgBoxHelper.MsgBoxConfirm(titleMsg, "您确定要删除该角色吗?会连同与角色相关的数据一并删除?") == DialogResult.Yes) { bool bl = RequestStar.DeleteRoleLogic(roleInfo.RoleId); if (bl) { MsgBoxHelper.MsgBoxShow(titleMsg, $"角色:{roleInfo.RoleName} 信息删除成功!"); LoadAllRoles(); } else { MsgBoxHelper.MsgErrorShow($"角色:{roleInfo.RoleName} 信息删除失败!"); return; } } }
/// <summary> /// 删除(批量) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnDelete_Click(object sender, EventArgs e) { Action act = () => { if (dgvGUnitList.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow("请选择要删除的单位信息"); return; } string title = "删除计量单位"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要删除选择的这些计量单位信息吗?") == DialogResult.Yes) { List <int> guIds = new List <int>(); foreach (DataGridViewRow row in dgvGUnitList.SelectedRows) { GoodsUnitInfoModel guInfo = row.DataBoundItem as GoodsUnitInfoModel; if (RequestStar.GetGoodsUnitUse(guInfo.GUnitName)) { MsgBoxHelper.MsgErrorShow($"计量单位:{guInfo.GUnitName} 已经应用,不能删除!"); return; } else { guIds.Add(guInfo.GUnitId); } } bool bl = RequestStar.GoodsUnitLogicDeleteList(guIds); string sucMsg = bl ? "成功" : "失败"; string msg = $"选择的单位信息删除 {sucMsg}"; if (bl) { MsgBoxHelper.MsgBoxShow(title, msg); LoadGUnitList(); } else { MsgBoxHelper.MsgErrorShow(msg); } } }; act.TryCatch("批量删除计量单位信息异常!"); }
/// <summary> /// 工具菜单数据恢复 /// </summary> /// <param name="tmInfo"></param> private void RecoverToolMenuInfo(ToolMenuInfoModel tmInfo) { string title = "恢复工具菜单项"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要恢复该工具菜单项数据吗?会连同角色工具菜单关系数据一并恢复?") == DialogResult.Yes) { //角色工具菜单关系数据 工具菜单信息 bool bl = RequestStar.RecoverToolMenu(tmInfo.TMenuId); if (bl) { MsgBoxHelper.MsgBoxShow(title, $"工具菜单项:{tmInfo.TMenuName} 恢复成功!"); LoadTMenuList(); } else { MsgBoxHelper.MsgErrorShow($"工具菜单项:{tmInfo.TMenuName} 恢复失败!"); return; } } }
private void DeleToolMenuInfo(ToolMenuInfoModel tmInfo) { string title = "删除工具菜单项"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要删除该工具菜单项数据吗?会连同角色工具菜单关系数据一并删除?") == DialogResult.Yes) { //删除操作 //角色工具菜单关系数据 工具菜单信息 bool bl = RequestStar.DeleteToolMenuLogic(tmInfo.TMenuId); if (bl) { MsgBoxHelper.MsgBoxShow(title, $"工具菜单项:{tmInfo.TMenuName} 删除成功!"); LoadTMenuList(); } else { MsgBoxHelper.MsgErrorShow($"工具菜单项:{tmInfo.TMenuName} 删除失败!"); return; } } }
private void btnDel_Click(object sender, EventArgs e) { string title = "删除工具组"; if (dgvGroups.SelectedRows.Count > 0) { if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要删除这些工具组数据吗?") == DialogResult.Yes) { //获取要删除的Id List <int> tgIds = new List <int>(); foreach (DataGridViewRow row in dgvGroups.SelectedRows) { ToolGroupInfoModel tgInfo = row.DataBoundItem as ToolGroupInfoModel; tgIds.Add(tgInfo.TGroupId); } //先检查是否已添加工具菜单数据 if (!RequestStar.HasToolMenus(tgIds)) { bool bl = RequestStar.LogicDeleteToolGroups(tgIds); if (bl) { MsgBoxHelper.MsgBoxShow(title, "这些工具组删除成功!"); LoadToolGroups(); } else { MsgBoxHelper.MsgErrorShow("这些工具组删除失败!"); return; } } else { MsgBoxHelper.MsgErrorShow($"选择的工具组中有的已添加工具菜单项,不能删除!"); return; } } } }
/// <summary> /// 修改多用户状态 /// </summary> /// <param name="type"></param> private void UpdateUsersState(int type) { string actMsg = type == 1 ? "启用" : "停用"; if (dgvUsers.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow($"请选择要{actMsg}的用户!"); return; } if (MsgBoxHelper.MsgBoxConfirm($"用户{actMsg}", $"您确定要{actMsg}这些选择的用户吗?") == DialogResult.Yes) { List <int> userIds = new List <int>(); foreach (DataGridViewRow row in dgvUsers.SelectedRows) { UserInfoModel userInfo = row.DataBoundItem as UserInfoModel; userIds.Add(userInfo.UserId); } bool bl = false; if (type == 1) { bl = RequestStar.EnableUsers(userIds); } else { bl = RequestStar.StopUsers(userIds); } if (bl) { MsgBoxHelper.MsgBoxShow($"用户{actMsg}", $"该用户{actMsg}成功!"); LoadUserList(); } else { MsgBoxHelper.MsgErrorShow($"该用户{actMsg}失败!"); return; } } }
/// <summary> /// 备份数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { string path = txtPath.Text.Trim(); if (string.IsNullOrEmpty(path)) { MsgBoxHelper.MsgErrorShow("请选择备份文件存放的位置!"); return; } if (MsgBoxHelper.MsgBoxConfirm("备份数据", "您确定要备份数据库吗?") == DialogResult.Yes) { bool bl = RequestStar.BackupData(path); if (bl) { MsgBoxHelper.MsgBoxShow("备份数据", "系统数据备份完毕!"); } else { MsgBoxHelper.MsgErrorShow("数据备份失败!"); return; } } }
/// <summary> /// 保存上下限设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnSave_Click(object sender, EventArgs e) { Action act = () => { //获取列表数据,判断是否有修改的数据,移除未修改的数据,保存提交 List <ViewStoreStockUpDownModel> list = dgvList.DataSource as List <ViewStoreStockUpDownModel>; List <ViewStoreStockUpDownModel> list2 = new List <ViewStoreStockUpDownModel>(); foreach (var gupdown in list) { foreach (var vsud in listStart) { if (vsud.StoreGoodsId == gupdown.StoreGoodsId && (vsud.StockUp != gupdown.StockUp || vsud.StockDown != gupdown.StockDown)) { list2.Add(gupdown); break; } } } if (list2.Count == 0) { MsgBoxHelper.MsgErrorShow("没有需要保存的信息!"); return; } bool blSave = RequestStar.SetGoodsStockUpDown(list2); if (blSave) { MsgBoxHelper.MsgBoxShow("保存库存上下限", "库存上下限设置保存成功!"); } else { MsgBoxHelper.MsgErrorShow("库存上下限设置保存失败!"); return; } }; act.TryCatch("保存库存上下限设置出现异常!"); }
/// <summary> /// 批量删除(逻辑删除) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnDelete_Click(object sender, EventArgs e) { Action act = () => { //SelectedRows 选定行的集合(MultiSelect True ) 多个行 if (dgvGoodsTypeList.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow("请选择要删除的商品类别信息"); return; } string title = "删除商品类别"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要删除选择的这些商品类别信息吗?") == DialogResult.Yes) { List <int> typeIds = new List <int>(); string hasChildsNames = ""; string hasAddGoodsNames = ""; foreach (DataGridViewRow row in dgvGoodsTypeList.SelectedRows) { GoodsTypeInfoModel gtInfo = row.DataBoundItem as GoodsTypeInfoModel; //如果该类别添加了商品,不允许删除 bool hasAddGoods = RequestStar.CheckIsAddGoods(gtInfo.GTypeId); //如果该类别添加了子类别,不允许删除 bool hasChilds = RequestStar.HasChildTypes(gtInfo.GTypeId); if (!hasAddGoods && !hasChilds) { typeIds.Add(gtInfo.GTypeId); } else if (hasAddGoods) { //MsgBoxHelper.MsgErrorShow($"该类别:{gtInfo.GTypeName} 已经添加商品,不能删除!"); if (hasAddGoodsNames.Length > 0) { hasAddGoodsNames += ","; } hasAddGoodsNames += gtInfo.GTypeName; } else if (hasChilds) { //MsgBoxHelper.MsgErrorShow($"该类别:{gtInfo.GTypeName} 已经添加了子类别,不能删除!"); //return; if (hasChildsNames.Length > 0) { hasChildsNames += ","; } hasChildsNames += gtInfo.GTypeName; } } if (typeIds.Count > 0) { bool bl = RequestStar.GoodsTypeLogicDeleteList(typeIds);//执行批量删除 string sucMsg = bl ? "成功" : "失败"; string msg = $"选择的类别信息中符合删除要求的信息 删除 {sucMsg}!"; if (bl) { if (!string.IsNullOrEmpty(hasChildsNames)) { msg += $" {hasChildsNames} 已经添加了子类别,不能删除!"; } if (!string.IsNullOrEmpty(hasAddGoodsNames)) { msg += $" {hasAddGoodsNames} 已经添加商品,不能删除!"; } MsgBoxHelper.MsgBoxShow(title, msg); LoadGoodsTypeList(); ReloadCboParents(typeIds); } else { MsgBoxHelper.MsgErrorShow(msg); } } else { MsgBoxHelper.MsgErrorShow("没有符合删除要求的商品类别信息!"); } } }; act.TryCatch("批量删除商品类别信息异常!"); }