/// <summary> /// 初始化父级类别下拉框 /// </summary> private void LoadUnitTypeList() { string keywords = txtKeywords.Text.Trim(); bool isShowDel = chkShowDel.Checked; //设置数据表的操作列显示以及工具项的可用状态 SetColumnsAndToolBtns(isShowDel); //获取数据 List <UnitTypeInfoModel> typeList = RequestStar.LoadUnitTypeList(keywords, isShowDel); dgvUnitTypeList.AutoGenerateColumns = false; if (typeList.Count > 0) { dgvUnitTypeList.DataSource = typeList; } else { dgvUnitTypeList.DataSource = null; } dgvUnitTypeList.AllowUserToAddRows = false; }
private void LoadTMenuList() { string keywords = txtKeyWords.Text.Trim(); bool blShow = chkShowDel.Checked; SetActColsShow(blShow);//控制操作列的显示 //获取数据 List <ToolMenuInfoModel> list = RequestStar.GetToolMenuInfos(keywords, blShow); //判断是否有数据,处理工具栏中按钮项 启用处理 if (list.Count > 0) { dgvTMenus.AutoGenerateColumns = false; dgvTMenus.DataSource = list; SetToolBtnsEnable(true); } else { dgvTMenus.DataSource = null; SetToolBtnsEnable(false); } }
private void LoadGoodsStockData() { int storeId = 0; string storeName = ""; if (storeInfo != null) { storeId = storeInfo.StoreId; storeName = storeInfo.StoreName; } storeStockData = RequestStar.GetGoodsStoreStock(goodsStockInfo.GoodsId, storeId, storeName); if (storeStockData.Count > 0) { dgvList.AutoGenerateColumns = false; dgvList.DataSource = storeStockData; } else { dgvList.DataSource = null; dgvList.AllowUserToAddRows = false; } }
private void LoadSaleDataByCustomer() { QueryParaModel pModel = GetParaModel(); PageModel <SaleQueryCustomerModel> pageModel = RequestStar.GetSaleDataByCustomer(pModel, ucPager1.StartRecord, ucPager1.PageSize); if (pageModel != null) { if (pageModel.ReList.Count > 0) { dgvGoodsList.AutoGenerateColumns = false; dgvGoodsList.DataSource = pageModel.ReList; ucPager1.Visible = true; ucPager1.Record = pageModel.TotalCount; } else { dgvGoodsList.DataSource = null; dgvGoodsList.AllowUserToAddRows = false; ucPager1.Visible = false; } } }
/// <summary> /// 加载商品信息 /// </summary> /// <param name="fId"></param> private void InitGoodsInfo(int goodsId) { GoodsInfoModel goodsInfo = RequestStar.GetGoodsInfo(goodsId); if (goodsInfo != null) { txtBidPrice.Text = goodsInfo.BidPrice.ToString(); txtDiscount.Text = goodsInfo.Discount.ToString(); txtGoodsName.Text = goodsInfo.GoodsName; oldName = goodsInfo.GoodsName; txtGoodsNo.Text = goodsInfo.GoodsNo; txtGoodsPYNo.Text = goodsInfo.GoodsPYNo; txtGoodsSName.Text = goodsInfo.GoodsSName; string gtypeName = RequestStar.GetGoodsType(goodsInfo.GTypeId).GTypeName; txtGoodsType.Text = gtypeName; gTypeInfo = new GoodsTypeInfoModel() { GTypeId = goodsInfo.GTypeId, GTypeName = gtypeName }; txtGoodTXNo.Text = goodsInfo.GoodsTXNo; txtLowPrice.Text = goodsInfo.LowPrice.ToString(); txtPrePrice.Text = goodsInfo.PrePrice.ToString(); txtRemark.Text = goodsInfo.Remark; txtRetailPrice.Text = goodsInfo.RetailPrice.ToString(); if (goodsInfo.IsStopped == 1) { chkStop.Checked = true; } cboGoodsProperties.Text = goodsInfo.GProperties; cboGUnits.Text = goodsInfo.GUnit; if (!string.IsNullOrEmpty(goodsInfo.GoodsPic)) { string picPath = Application.StartupPath + "/" + goodsInfo.GoodsPic; picGoods.ImageLocation = picPath; oldPic = picPath; } } }
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> private void LoadUnitList() { string keywords = txtKeyWords.Text.Trim(); int uTypeId = 0; if (tvUTypes.SelectedNode != null) { uTypeId = tvUTypes.SelectedNode.Name.GetInt(); } PageModel <ViewUnitInfoModel> pageModel = RequestStar.GetUnitList(uTypeId, keywords, chkShowDel.Checked, ucPager1.StartRecord, ucPager1.PageSize); SetColsAndToolBtns(chkShowDel.Checked);//设置工具项的可用与操作列的显示 if (pageModel != null) { if (pageModel.ReList.Count > 0) { dgvUnitList.AutoGenerateColumns = false; dgvUnitList.DataSource = pageModel.ReList; tsbtnInfo.Enabled = true; } else { dgvUnitList.DataSource = null; dgvUnitList.AllowUserToAddRows = false; tsbtnInfo.Enabled = false; } if (pageModel.TotalCount > 0) { ucPager1.Visible = true; ucPager1.Record = pageModel.TotalCount; } else { ucPager1.Visible = false; } } }
/// <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 tsmiNoUse_Click(object sender, EventArgs e) { Action act = () => { if (actType == 1) { MsgBoxHelper.MsgErrorShow("期初入库单还未保存,不能进行作废操作!"); return; } if (MsgBoxHelper.MsgBoxConfirm("期初入库单审核", "你确定要作废该入库单吗?") == DialogResult.Yes) { bool bl = RequestStar.NoUseStockInfo(stockId); if (bl) { lblCheckState.Text = "已作废"; lblCheckState.ForeColor = Color.Gray; SetBtnsEnabled(2); } } }; act.TryCatch("作废入库单出现异常!"); }
/// <summary> /// 审核入库单 状态:待审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnCheck_Click(object sender, EventArgs e) { Action act = () => { if (actType == 1) { MsgBoxHelper.MsgErrorShow("期初入库单还未保存,不能审核!"); return; } if (MsgBoxHelper.MsgBoxConfirm("期初入库单审核", "你确定要审核该入库单吗?") == DialogResult.Yes) { bool bl = RequestStar.CheckStockInfo(stockId, uName, store.StoreId); if (bl) { lblCheckState.Text = "已审核"; lblCheckState.ForeColor = Color.Red; SetBtnsEnabled(1); } } }; act.TryCatch("审核入库单出现异常!"); }
/// <summary> /// 销售单作废 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmiNoUse_Click(object sender, EventArgs e) { Action act = () => { if (actType == 1) { MsgBoxHelper.MsgErrorShow("销售单还未保存,不能作废!"); return; } if (MsgBoxHelper.MsgBoxConfirm("销售单作废", "你确定要作废该销售单吗?") == DialogResult.Yes) { bool bl = RequestStar.NoUseSaleInfo(saleId); if (bl) { lblCheckState.Text = "已作废"; lblCheckState.ForeColor = Color.Gray; SetBtnsEnabled(2);//更新页面按钮的可用 } } }; act.TryCatch("作废销售单出现异常!"); }
/// <summary> /// 条件查询单据列表 /// </summary> private void LoadSheetList() { ShQueryParaModel paraModel = GetParaModel(); //调用查询方法 PageModel <SheetInfoModel> pageModel = RequestStar.GetSheetList(paraModel, ucPager1.StartRecord, ucPager1.PageSize); if (pageModel != null) { if (pageModel.ReList.Count > 0) { dgvList.AutoGenerateColumns = false; dgvList.DataSource = pageModel.ReList; ucPager1.Visible = true; ucPager1.Record = pageModel.TotalCount; } else { dgvList.DataSource = null; dgvList.AllowUserToAddRows = false; ucPager1.Visible = false; } } }
/// <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> private void LoadTypeInfos() { tvUTypes.Nodes.Clear(); string rootName = ""; if (cModel.TypeCode.Contains("Goods"))//加载商品类别信息 { this.Text = "请选择商品类别"; rootName = "商品类别"; } else if (cModel.TypeCode == "Units") { this.Text = "请选择单位类别"; rootName = "单位类别"; } TreeNode rootNode = FormUtility.CreateNode("0", rootName); tvUTypes.Nodes.Add(rootNode); if (cModel.TypeCode.Contains("Goods"))//加载商品类别信息 { List <GoodsTypeInfoModel> gtList = RequestStar.LoadAllGoodsTypes(); if (gtList.Count > 0) { FormUtility.AddTvGTypesNode(gtList, rootNode, 0); } } else if (cModel.TypeCode == "Units") { List <UnitTypeInfoModel> utList = RequestStar.LoadAllTVUnitTypes(); if (utList.Count > 0) { FormUtility.AddTvUTypesNode(utList, rootNode, 0); } } tvUTypes.SelectedNode = rootNode; tvUTypes.ExpandAll(); }
/// <summary> /// 加载所有商品信息 /// </summary> private void LoadGoodsList() { string keywords = txtKeyWords.Text.Trim(); int gTypeId = 0; if (tvGTypes.SelectedNode != null) { gTypeId = tvGTypes.SelectedNode.Name.GetInt(); } PageModel <ViewGoodsInfoModel> pageModel = RequestStar.LoadGoodsList(gTypeId, keywords, chkStop.Checked, chkShowDel.Checked, ucPager1.StartRecord, ucPager1.PageSize); SetColsAndToolBtns(chkShowDel.Checked); if (pageModel != null) { if (pageModel.ReList.Count > 0) { dgvGoodsList.AutoGenerateColumns = false; dgvGoodsList.DataSource = pageModel.ReList; } else { dgvGoodsList.DataSource = null; dgvGoodsList.AllowUserToAddRows = false; } if (pageModel.TotalCount > 0) { ucPager1.Visible = true; ucPager1.Record = pageModel.TotalCount; } else { ucPager1.Visible = false; } } }
/// <summary> /// 加载用户信息 /// </summary> /// <param name="userId"></param> private void InitUserInfo(int userId) { UserInfoModel user = RequestStar.GetUserInfo(userId); if (user != null) { txtUName.Text = user.UserName; oldUserName = user.UserName; if (user.UserState == 1) { rbEnabed.Checked = true; } else { rbStop.Checked = true; } //已有角色的选项勾选 var userRoles = RequestStar.GetUserRoleList(userId); if (userRoles.Count > 0) { foreach (var ur in userRoles) { for (int i = 0; i < chkList.Items.Count; i++) { RoleInfoModel role = chkList.Items[i] as RoleInfoModel; if (role.RoleId == ur.RoleId) { chkList.SetItemChecked(i, true); roleIds.Add(role.RoleId); break; } } } } } }
private void FrmPayFor_Load(object sender, EventArgs e) { if (this.Tag != null) { PayModel pModel = this.Tag as PayModel; if (pModel != null) { paytype = pModel.PayType; fInfo = pModel.FGet; strPayFor = pModel.StrPayFor; } List <PayInfoModel> payList = RequestStar.GetFirstPayInfos(paytype, strPayFor); dgvPay.AutoGenerateColumns = false; dgvPay.DataSource = payList; if (string.IsNullOrEmpty(strPayFor)) { lblTotal.Text = "0"; } else { lblTotal.Text = GetTotal(payList).ToString(); } } }
/// <summary> /// 页面初始化 /// </summary> private void InitInfo() { if (stockId == 0) { ClearInfo(); } else//加载单据信息 { //获取指定入库单信息 StockStoreInfoModel stockInfo = RequestStar.GetStockInfo(stockId); if (stockInfo != null) { //选择仓库 仓库编号 store = new StoreInfoModel() { StoreId = stockInfo.StoreId, StoreName = RequestStar.GetStoreInfo(stockInfo.StoreId).StoreName }; txtInStore.Text = store.StoreName; txtDealPerson.Text = stockInfo.DealPerson; txtRemark.Text = stockInfo.Remark; lblStockNo.Text = stockInfo.StockNo; txtCreator.Text = stockInfo.Creator; txtCreateTime.Text = stockInfo.CreateTime.ToShortDateString(); //单据状态 switch (stockInfo.IsChecked) { case 0: lblCheckState.Text = "待审核"; break; case 1: lblCheckState.Text = "已审核"; break; case 2: lblCheckState.Text = "作废"; //未审核作废 break; case 3: lblCheckState.Text = "已红冲"; //已审核作废称红冲 break; } //在不同审核状态下工具项的可用 SetBtnsEnabled(stockInfo.IsChecked); //获取该单据相关的商品明细列表 List <ViewStStockGoodsInfoModel> stockGoods = RequestStar.GetStockGoodsList(stockId); if (stockGoods.Count > 0) { dgvGoods.AutoGenerateColumns = false; dgvGoods.DataSource = stockGoods; SetTotalInfo(stockGoods); } else { dgvGoods.DataSource = null; dgvGoods.AllowUserToAddRows = false; } } } isOpened = RequestStar.GetOpenState(1); if (isOpened) { tsbtnAdd.Enabled = false; tsbtnSave.Enabled = false; tsbtnCheck.Enabled = false; tsddbtnAct.Enabled = false; btnAddGoods.Enabled = false; btnDelete.Enabled = false; storeList.Visible = false; lblOpenDesp.Visible = true; } else { lblOpenDesp.Visible = false; } }
/// <summary> /// 提交功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { Action act = () => { //信息获取 int parentId = cboParents.SelectedValue.GetInt(); string parentName = parentId == 0 ? null : cboParents.Text.Trim(); string typeName = txtGTypeName.Text.Trim(); string typeNo = txtGTypeNo.Text.Trim(); string pyNo = txtGTPYNo.Text.Trim(); int gorder = txtGTOrder.Text.GetInt(); //判空处理 if (string.IsNullOrEmpty(typeName)) { MsgBoxHelper.MsgErrorShow("请输入商品类别名称!"); txtGTypeName.Focus(); return; } //判断已存在 if (gTypeId == 0 || (!string.IsNullOrEmpty(oldName) && oldName != typeName)) { if (RequestStar.ExistName(typeName)) { MsgBoxHelper.MsgErrorShow("该类别名称已存在!"); txtGTypeName.Focus(); return; } } //信息封装 GoodsTypeInfoModel gtInfo = new GoodsTypeInfoModel() { GTypeId = gTypeId, GTypeName = typeName, GTypeNo = typeNo, GTPYNo = pyNo, GTOrder = gorder, ParentId = parentId, ParentName = parentName, Creator = uName }; //方法执行 bool bl = false; int gTypeIdNew = 0; if (gTypeId == 0) { gTypeIdNew = RequestStar.AddGoodsType(gtInfo); if (gTypeIdNew > 0) { bl = true; gtInfo.GTypeId = gTypeIdNew; } } else { if (CheckGoodsTypeInfo(gtInfo, oldInfo)) { bl = RequestStar.UpdateGoodsType(gtInfo, oldName); } else { MsgBoxHelper.MsgErrorShow("没有要提交的信息"); return; } } string actType = gTypeId == 0 ? "添加" : "修改"; string sucType = bl ? "成功" : "失败"; string actMsg = $"商品类别信息:{typeName} {actType} {sucType}"; string msgTitle = $"{actType}商品类别"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, actMsg); LoadGoodsTypeList(); ReloadCboParents(gtInfo, false, 0);//刷新下拉框 } else { MsgBoxHelper.MsgErrorShow(actMsg); 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("批量删除商品类别信息异常!"); }
/// <summary> /// 批量删除或单条删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnDelete_Click(object sender, EventArgs e) { Action act = () => { //SelectedRows 选定行的集合(MultiSelect True ) 多个行 if (dgvStoreTypeList.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow("请选择要删除的仓库类别信息"); return; } string title = "删除仓库类别"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要删除选择的这些仓库类别信息吗?") == DialogResult.Yes) { List <int> typeIds = new List <int>(); string hasAddStoresNames = ""; foreach (DataGridViewRow row in dgvStoreTypeList.SelectedRows) { StoreTypeInfoModel stInfo = row.DataBoundItem as StoreTypeInfoModel; //如果该类别添加了仓库,不允许删除 bool hasAddStores = RequestStar.IsAddStores(stInfo.STypeId); if (!hasAddStores) { typeIds.Add(stInfo.STypeId); } else { if (hasAddStoresNames.Length > 0) { hasAddStoresNames += ","; } hasAddStoresNames += stInfo.STypeName; } } if (typeIds.Count > 0) { bool bl = RequestStar.StoreTypeLogicDeleteList(typeIds);//执行批量删除 string sucMsg = bl ? "成功" : "失败"; string msg = $"选择的类别信息中符合删除要求的信息 删除 {sucMsg}!"; if (bl) { if (!string.IsNullOrEmpty(hasAddStoresNames)) { msg += $" {hasAddStoresNames} 已经添加了仓库,不能删除!"; } MsgBoxHelper.MsgBoxShow(title, msg); LoadStoreTypeList(); } else { MsgBoxHelper.MsgErrorShow(msg); } } else { MsgBoxHelper.MsgErrorShow("没有符合删除要求的类别信息!"); } } }; act.TryCatch("批量删除仓库类别信息异常!"); }
/// <summary> /// 新增、修改提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { //信息获取 string typeName = txtSTypeName.Text.Trim(); string pyNo = txtSTPYNo.Text.Trim(); int stOrder = txtSTOrder.Text.GetInt(); //判空处理 if (string.IsNullOrEmpty(typeName)) { MsgBoxHelper.MsgErrorShow("请输入仓库类别名称!"); txtSTypeName.Focus(); return; } //判断已存在 if (storeTypeId == 0 || (!string.IsNullOrEmpty(oldName) && oldName != typeName)) { if (RequestStar.ExistsStoreType(typeName)) { MsgBoxHelper.MsgErrorShow("该仓库类别已存在!"); txtSTypeName.Focus(); return; } } //信息封装 StoreTypeInfoModel stInfo = new StoreTypeInfoModel() { STypeId = storeTypeId, STypeName = typeName, STPYNo = pyNo, STypeOrder = stOrder, Creator = uName }; //方法执行 bool bl = false; if (storeTypeId == 0) { bl = RequestStar.AddStoreType(stInfo); } else { bl = RequestStar.UpdateStoreType(stInfo); } string actType = storeTypeId == 0 ? "添加" : "修改"; string sucType = bl ? "成功" : "失败"; string actMsg = $"仓库类别信息:{typeName} {actType} {sucType}"; string msgTitle = $"{actType}仓库类别"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, actMsg); LoadStoreTypeList(); if (storeTypeId == 0) { txtSTOrder.Clear(); txtSTPYNo.Clear(); txtSTypeName.Clear(); } } else { MsgBoxHelper.MsgErrorShow(actMsg); return; } }
/// <summary> /// 提交用户信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { Action act = () => { //接收页面信息 string uName = txtUName.Text.Trim(); string uPwd = txtUPwd.Text.Trim(); int userState = rbEnabed.Checked ? 1 : 0; //判断账号是否为空 if (string.IsNullOrEmpty(uName)) { MsgBoxHelper.MsgErrorShow("账号不能为空!"); txtUName.Focus(); return; } else if (userId == 0 || (!string.IsNullOrEmpty(oldUserName) && oldUserName != uName)) { //判断用户名是否已存在---存在---错误提示 } if (userId == 0 && string.IsNullOrEmpty(uPwd)) { MsgBoxHelper.MsgErrorShow("密码不能为空!"); txtUPwd.Focus(); return; } string enPwd = ""; if (uPwd != "") { enPwd = MD5Encrypt.Encrypt(uPwd); } //封装信息实体 UserInfoModel userInfo = new UserInfoModel() { UserName = uName, UserPwd = enPwd, Creator = fModel.UName, UserState = userState }; if (userId > 0) { userInfo.UserId = userId; } //角色列表获取 List <UserRoleInfoModel> urList = new List <UserRoleInfoModel>(); for (int i = 0; i < chkList.Items.Count; i++) { if (chkList.GetItemCheckState(i) == CheckState.Checked) { RoleInfoModel role = chkList.Items[i] as RoleInfoModel; UserRoleInfoModel ur = new UserRoleInfoModel() { RoleId = role.RoleId, UserId = userId, Creator = fModel.UName }; urList.Add(ur); } } //提交操作 if (fModel.ActType == 1) { //提交新增 bool blAdd = RequestStar.AddUserInfo(userInfo, urList); if (blAdd) { MsgBoxHelper.MsgBoxShow("添加用户", $"用户:{uName} 添加成功!"); fModel.ReLoad?.Invoke(); } else { MsgBoxHelper.MsgErrorShow($"用户:{uName} 添加失败!"); return; } } else { //筛选角色列表设置 List <UserRoleInfoModel> urListNew = new List <UserRoleInfoModel>(); foreach (var ur in urList) { bool ebl = false; foreach (int rId in roleIds) { if (ur.RoleId == rId) { ebl = true; break; } } if (!ebl) { urListNew.Add(ur); } } if (urList.Count == roleIds.Count && urListNew.Count == 0) { urList.RemoveRange(0, urList.Count); } //提交修改 bool blEdit = RequestStar.UpdateUserInfo(userInfo, urList, urListNew); if (blEdit) { MsgBoxHelper.MsgBoxShow("修改用户", $"用户:{uName} 修改成功!"); fModel.ReLoad?.Invoke(); } else { MsgBoxHelper.MsgErrorShow($"用户:{uName} 修改失败!"); return; } } }; act.TryCatch("提交用户信息异常!"); }
private void tsbtnSave_Click(object sender, EventArgs e) { //1.接收页面输入 string mName = txtMName.Text.Trim(); int parentId = cboParents.SelectedValue.GetInt(); string parentName = cboParents.Text.Trim(); if (parentId == 0) { parentName = null; } string mUrl = cboUrls.SelectedValue.ToString(); if (string.IsNullOrEmpty(mUrl)) { mUrl = null; } string mKey = txtMKey.Text.Trim(); int mOrder = txtMKey.Text.GetInt(); string mDesp = txtMDesp.Text.Trim(); if (string.IsNullOrEmpty(mDesp)) { mDesp = null; } int isTop = chkTop.Checked ? 1 : 0; //2.判断菜单名称不能为空 if (string.IsNullOrEmpty(mName)) { MsgBoxHelper.MsgErrorShow("菜单名称不能为空!"); txtMName.Focus(); return; } //3.判断菜单名称是否已存在 (oldName=""||(oldName!="" && oleName!=mName)) if (string.IsNullOrEmpty(oldName) || (!string.IsNullOrEmpty(oldName) && oldName != mName)) { //判断名称是否已存在 if (RequestStar.ExistMenu(mName)) { MsgBoxHelper.MsgErrorShow("菜单名称已存在!"); txtMName.Focus(); return; } } //4.信息的封装 MenuInfoModel menuInfo = new MenuInfoModel() { MName = mName, ParentId = parentId, ParentName = parentName, MUrl = mUrl, MOrder = mOrder, MKey = mKey, IsTop = isTop, MDesp = mDesp, Creator = fModel.UName }; //5.执行方法(添加、修改) bool bl = false; string actMsg = fModel.ActType == 2 ? "修改" : "新增"; if (fModel.ActType == 1 || fModel.ActType == 3) { //新增操作 bl = RequestStar.AddMenuInfo(menuInfo); } else if (fModel.ActType == 2) { //修改操作 menuInfo.MId = menuId; bool blUpdate = false; if (oldName != mName) { blUpdate = true; } bl = RequestStar.UpdateMenuInfo(menuInfo, blUpdate); } if (bl) { MsgBoxHelper.MsgBoxShow($"{actMsg}菜单", $"菜单:{mName} 信息 {actMsg}成功!"); fModel.ReLoad?.Invoke();//刷新列表数据 } else { MsgBoxHelper.MsgErrorShow($"菜单:{mName} 信息 {actMsg}失败!"); return; } }
/// <summary> /// 销售单保存:新增 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnSave_Click(object sender, EventArgs e) { Action act = () => { //信息接收 int storeId = 0; if (store != null) { storeId = store.StoreId; } int unitId = 0; if (selCust != null) { unitId = selCust.UnitId; } string dealPerson = txtDealPerson.Text.Trim(); string payDesp = txtCollectType.Text.Trim(); decimal thisAmount = txtThisAmount.Text.GetDecimal(); string remark = txtRemark.Text.Trim(); decimal totalAmount = txtTotalAmount.Text.GetDecimal(); decimal yhAmount = txtYHAmount.Text.GetDecimal(); string creator = txtCreator.Text.Trim(); DateTime createTime = DateTime.Today; DateTime?payTime = null; if (storeId == 0) { MsgBoxHelper.MsgErrorShow("请选择出货仓库!"); txtOutStore.Focus(); return; } if (unitId == 0) { MsgBoxHelper.MsgErrorShow("请选择客户!"); txtCustomers.Focus(); return; } if (thisAmount > totalAmount) { MsgBoxHelper.MsgErrorShow("收款金额不能大于应收金额!"); txtThisAmount.Focus(); return; } else if (thisAmount > 0 && thisAmount <= totalAmount) { hasPay = 1;//已收款 if (thisAmount == totalAmount) { hasFullPay = 1;//已收完 } payTime = DateTime.Now; } if (dgvGoods.DataSource == null) { MsgBoxHelper.MsgErrorShow("请选择销售商品!"); return; } else { List <ViewSaleGoodsInfoModel> list = dgvGoods.DataSource as List <ViewSaleGoodsInfoModel>; List <ViewSaleGoodsInfoModel> list2 = list; foreach (var vpi in list) { if (string.IsNullOrEmpty(vpi.GoodsName)) { DialogResult dr = MsgBoxHelper.MsgBoxConfirm("销售商品", $"商品不能为空,是否删除这行?"); if (dr == DialogResult.Yes) { dgvGoods.DataSource = null; list2.Remove(vpi); dgvGoods.DataSource = list2; } return; } else if (vpi.SalePrice == 0) { MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的销售单价不能为0!"); return; } else if (vpi.Count == 0) { MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的销售数量不能为0!"); return; } } } //信息封装:单据信息 明细信息 SaleOutStoreInfoModel saleInfo = new SaleOutStoreInfoModel() { StoreId = storeId, UnitId = unitId, PayDesp = payDesp, ThisAmount = thisAmount, TotalAmount = totalAmount, YHAmount = yhAmount, DealPerson = dealPerson, Remark = remark, IsPayed = hasPay, IsPayFull = hasFullPay, Creator = creator, CreateTime = createTime }; if (hasPay == 1) { saleInfo.PayTime = payTime; } //获取采购商品列表 List <ViewSaleGoodsInfoModel> listGoods = dgvGoods.DataSource as List <ViewSaleGoodsInfoModel>; //提交 if (saleId == 0) //新单保存 { //reStr saleId,SaleNo string reStr = RequestStar.AddSaleInfo(saleInfo, listGoods); if (!string.IsNullOrEmpty(reStr)) { MsgBoxHelper.MsgBoxShow("销售单保存", "销售单新增保存成功!"); string[] reStrs = reStr.Split(','); saleId = reStrs[0].GetInt(); //生成的销售单编号 lblSaleNo.Text = reStrs[1]; //生成的销售单号 actType = 2; //修改页面 tsddbtnAct.Enabled = true; SetBtnsEnabled(0); //更新页面按钮的可用状态 this.ReloadListHandler(); } else { MsgBoxHelper.MsgErrorShow("销售单保存失败!"); return; } } else//修改保存 新增后修改 单据列表页进来 { saleInfo.SaleId = saleId; bool bl = RequestStar.UpdateSaleInfo(saleInfo, listGoods); if (bl) { MsgBoxHelper.MsgBoxShow("销售单保存", "销售单修改保存成功!"); this.ReloadListHandler(); } } }; act.TryCatch("销售单提交出现异常!"); }
/// <summary> /// 初始化工作 /// </summary> private void InitInfo() { if (saleId == 0) { //清空处理 ClearInfo(); SetBtnsEnabled(0); } else //修改状态 { //加载指定的销售单信息 SaleOutStoreInfoModel saleInfo = RequestStar.GetSaleInfo(saleId); if (saleInfo != null) { txtCustomers.Text = RequestStar.GetUnitInfo(saleInfo.UnitId).UnitName; selCust = new UnitInfoModel() { UnitId = saleInfo.UnitId, UnitName = txtCustomers.Text }; txtOutStore.Text = RequestStar.GetStoreInfo(saleInfo.StoreId).StoreName; store = new StoreInfoModel() { StoreId = saleInfo.StoreId, StoreName = txtOutStore.Text }; txtDealPerson.Text = saleInfo.DealPerson; txtCollectType.Text = saleInfo.PayDesp; txtThisAmount.Text = saleInfo.ThisAmount.ToString("0.00"); txtRemark.Text = saleInfo.Remark; txtTotalAmount.Text = saleInfo.TotalAmount.ToString("0.00"); txtYHAmount.Text = saleInfo.YHAmount.ToString("0.00"); txtCreator.Text = saleInfo.Creator; txtCreateTime.Text = saleInfo.CreateTime.ToShortDateString(); lblSaleNo.Text = saleInfo.SaleOutNo; switch (saleInfo.IsChecked) { case 0: lblCheckState.Text = "待审核"; break; case 1: lblCheckState.Text = "已审核"; break; case 2: lblCheckState.Text = "已作废"; //未审核作废 break; case 3: lblCheckState.Text = "已红冲"; //已审核作废称红冲 break; } SetBtnsEnabled(saleInfo.IsChecked); //设置页面工具项或页面按钮的可用 if (saleInfo.IsPayed == 1) //已经付款但并不定付完 { hasPay = 1; } if (saleInfo.IsPayFull == 1) //付完 { hasFullPay = 1; } //加载商品列表 List <ViewSaleGoodsInfoModel> saleGoodsList = RequestStar.GetSaleGoodsList(saleId); dgvGoods.AutoGenerateColumns = false; dgvGoods.DataSource = saleGoodsList; SetTotalInfo(saleGoodsList);//总计 数量 金额 } } isOpened = RequestStar.GetOpenState(1);//获取开账状态 if (!isOpened) { tsbtnAdd.Enabled = false; tsbtnSave.Enabled = false; tsbtnCheck.Enabled = false; tsddbtnAct.Enabled = false; btnAddGoods.Enabled = false; btnDelete.Enabled = false; storeList.Visible = false; customersList.Visible = false; picPayType.Visible = false; lblUnOpenDesp.Visible = true; } else { lblUnOpenDesp.Visible = false; } }
/// <summary> /// 仓库信息的提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnSave_Click(object sender, EventArgs e) { Action act = () => { //信息获取 string storeName = txtStoreName.Text.Trim(); string storeNo = txtStoreNo.Text.Trim(); string storePYNo = txtStorePYNo.Text.Trim(); int sTypeId = cboSTypes.SelectedValue != null?cboSTypes.SelectedValue.GetInt() : 0; string remark = txtRemark.Text.Trim(); int order = txtStoreOrder.Text.GetInt(); //判断 if (string.IsNullOrEmpty(storeName)) { MsgBoxHelper.MsgErrorShow("请输入仓库名称"); txtStoreName.Focus(); return; } //判断是否已存在 if (fModel.ActType == 1 || (!string.IsNullOrEmpty(oldName) && oldName != storeName) || (!string.IsNullOrEmpty(oldName) && (oldName == storeName) && (oldTypeId != sTypeId))) { if (RequestStar.ExistsStore(storeName, sTypeId)) { MsgBoxHelper.MsgErrorShow("该仓库已存在!"); txtStoreName.Focus(); return; } } if (sTypeId == 0) { MsgBoxHelper.MsgErrorShow("请选择仓库类别!"); cboSTypes.Focus(); return; } //信息的封装 StoreInfoModel storeInfo = new StoreInfoModel() { StoreId = fModel.FId, StoreName = storeName, StoreNo = storeNo, StorePYNo = storePYNo, STypeId = sTypeId, StoreRemark = remark, StoreOrder = order, Creator = fModel.UName }; //调用方法 bool bl = false; bl = fModel.ActType == 1 ? RequestStar.AddStoreInfo(storeInfo) : RequestStar.UpdateStoreInfo(storeInfo); string actMsg = fModel.ActType == 1 ? "添加" : "修改"; string titleMsg = $"{actMsg}仓库信息"; string sucType = bl ? "成功" : "失败"; string msg = $"仓库信息{actMsg} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(titleMsg, msg); this.ReLoadHandler?.Invoke(); } else { MsgBoxHelper.MsgErrorShow(msg); return; } }; act.TryCatch("仓库信息提交出现异常"); }
/// <summary> /// 单据保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnSave_Click(object sender, EventArgs e) { Action act = () => { //信息接收 int storeId = 0; if (store != null) { storeId = store.StoreId; } string dealPerson = txtDealPerson.Text.Trim(); string remark = txtRemark.Text.Trim(); string creator = txtCreator.Text.Trim(); DateTime createTime = DateTime.Today; if (storeId == 0) { MsgBoxHelper.MsgErrorShow("请选择入货仓库!"); txtInStore.Focus(); return; } if (dgvGoods.DataSource == null) { MsgBoxHelper.MsgErrorShow("请选择商品!"); return; } else { List <ViewStStockGoodsInfoModel> list = dgvGoods.DataSource as List <ViewStStockGoodsInfoModel>; List <ViewStStockGoodsInfoModel> list2 = list; foreach (var vpi in list) { if (string.IsNullOrEmpty(vpi.GoodsName)) { DialogResult dr = MsgBoxHelper.MsgBoxConfirm("入库商品", $"商品不能为空,是否删除这行?"); if (dr == DialogResult.Yes) { dgvGoods.DataSource = null; list2.Remove(vpi); dgvGoods.DataSource = list2; } return; } else if (vpi.StPrice == 0) { MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的成本单价不能为0!"); return; } else if (vpi.StCount == 0) { MsgBoxHelper.MsgErrorShow($"商品:{vpi.GoodsName}的入库数量不能为0!"); return; } } } //信息封装:单据信息 明细信息 StockStoreInfoModel stockInfo = new StockStoreInfoModel() { StoreId = storeId, DealPerson = dealPerson, Remark = remark, Creator = creator, CreateTime = createTime }; //保存期初商品列表 List <ViewStStockGoodsInfoModel> listGoods = dgvGoods.DataSource as List <ViewStStockGoodsInfoModel>; foreach (var goods in listGoods) { goods.Creator = uName; } //提交 if (stockId == 0) //新单保存 { //reStr stockId,StockNo string reStr = RequestStar.AddStockInfo(stockInfo, listGoods); if (!string.IsNullOrEmpty(reStr)) { MsgBoxHelper.MsgBoxShow("期初入库单保存", "期初入库单新增保存成功!"); string[] reStrs = reStr.Split(','); stockId = reStrs[0].GetInt(); //生成的入库单编号 lblStockNo.Text = reStrs[1]; //生成的入库单号 actType = 2; tsddbtnAct.Enabled = true; SetBtnsEnabled(0); this.ReloadListHandler(); } else { MsgBoxHelper.MsgErrorShow("期初入库单保存失败!"); return; } } else//修改保存 新增后修改 单据列表页进来 { stockInfo.StockId = stockId; bool bl = RequestStar.UpdateStockInfo(stockInfo, listGoods); if (bl) { MsgBoxHelper.MsgBoxShow("期初入库单保存", "期初入库单修改保存成功!"); this.ReloadListHandler(); } } }; 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 (dgvUnitList.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow("请选择要删除的单位信息"); return; } string title = "删除单位信息"; if (MsgBoxHelper.MsgBoxConfirm(title, "您确定要删除选择的这些单位信息吗?") == DialogResult.Yes) { List <int> unitIds = new List <int>(); string IsUseUnitNames = ""; foreach (DataGridViewRow row in dgvUnitList.SelectedRows) { ViewUnitInfoModel uInfo = row.DataBoundItem as ViewUnitInfoModel; //如果该类别添加了商品,不允许删除 bool isUnitUse = RequestStar.CheckUnitUse(uInfo.UnitId); if (!isUnitUse) { unitIds.Add(uInfo.UnitId); } else { if (IsUseUnitNames.Length > 0) { IsUseUnitNames += ","; } IsUseUnitNames += uInfo.UnitName; } } if (unitIds.Count > 0) { bool bl = RequestStar.UnitLogicDeleteList(unitIds);//执行批量删除 string sucMsg = bl ? "成功" : "失败"; string msg = $"选择的单位信息中符合删除要求的信息 删除 {sucMsg}!"; if (bl) { if (!string.IsNullOrEmpty(IsUseUnitNames)) { msg += $" {IsUseUnitNames} 已经使用,不能删除!"; } MsgBoxHelper.MsgBoxShow(title, msg); LoadUnitList(); } else { MsgBoxHelper.MsgErrorShow(msg); } } else { MsgBoxHelper.MsgErrorShow("没有符合删除要求的单位信息!"); } } }; act.TryCatch("批量删除单位信息异常!"); }