コード例 #1
0
        /// <summary>
        /// 保存盘点单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Press(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(txtName.Text))
                {
                    throw new Exception("盘点单名称不能为空!");
                }
                if (btnManager.Tag == null)
                {
                    throw new Exception("盘点人不能为空!");
                }
                if (btnWareHouse.Tag == null)
                {
                    throw new Exception("仓库不能为空!");
                }

                ConInventoryInputDto conInventoryInput = new ConInventoryInputDto()
                {
                    HANDLEMAN  = btnManager.Tag.ToString(),
                    CREATEUSER = UserId,
                    WAREID     = btnWareHouse.Tag.ToString(),
                    IsEnd      = false,
                    MODIFYUSER = UserId,
                    NAME       = txtName.Text
                };
                if (btnST.Tag != null)
                {
                    conInventoryInput.STID = btnST.Tag.ToString();
                }
                if (btnSL.Tag != null)
                {
                    conInventoryInput.SLID = btnSL.Tag.ToString();
                }

                ReturnInfo returnInfo = _autofacConfig.ConInventoryService.AddConInventory(conInventoryInput);
                if (returnInfo.IsSuccess)
                {
                    ShowResult = ShowResult.Yes;
                    Toast("添加成功");
                    Close();
                }
                else
                {
                    throw new Exception(returnInfo.ErrorInfo);
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// 保存盘点单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Press(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(txtName.Text))
                {
                    throw new Exception("盘点单名称不能为空!");
                }
                if (btnManager.Tag == null)
                {
                    throw new Exception("盘点人不能为空!");
                }
                if (btnLocation.Tag == null)
                {
                    throw new Exception("区域不能为空!");
                }
                AssLocation loc = _autofacConfig.assLocationService.GetByID(btnLocation.Tag.ToString());
                if (loc.ISLOCKED == 1)
                {
                    throw new Exception("该区域已锁定, 无法创建新的盘点单!");
                }
                if (loc.ISENABLE == 0)
                {
                    throw new Exception("该区域已禁用, 无法创建新的盘点单!");
                }

                ConInventoryInputDto conInventoryInput = new ConInventoryInputDto()
                {
                    HANDLEMAN  = btnManager.Tag.ToString(),
                    CREATEUSER = UserId,
                    LOCATIONID = btnLocation.Tag.ToString(),
                    IsEnd      = false,
                    MODIFYUSER = UserId,
                    NAME       = txtName.Text
                };
                ReturnInfo returnInfo = _autofacConfig.ConInventoryService.AddConInventory(conInventoryInput);
                if (returnInfo.IsSuccess)
                {
                    ShowResult = ShowResult.Yes;
                    Toast("添加成功");
                    Close();
                }
                else
                {
                    throw new Exception(returnInfo.ErrorInfo);
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message);
            }
        }
コード例 #3
0
        /// <summary>
        /// 添加盘点单
        /// </summary>
        /// <param name="inputDto">盘点单信息</param>
        /// <returns></returns>
        public ReturnInfo AddConInventory(ConInventoryInputDto inputDto)
        {
            //验证
            ReturnInfo    rInfo = new ReturnInfo();
            StringBuilder sb    = new StringBuilder();
            string        maxId = _conInventoryRepository.GetMaxId();
            string        IId   = Helper.GenerateIDEx("CI", maxId);

            inputDto.IID = IId;
            sb.Append(Helper.BasicValidate(inputDto).ToString());
            if (sb.Length == 0)
            {
                var assbo = Mapper.Map <ConInventoryInputDto, ConInventory>(inputDto);
                assbo.STATUS     = (int)InventoryStatus.盘点未开始;
                assbo.CREATEDATE = DateTime.Now;
                assbo.MODIFYDATE = DateTime.Now;

                AssLocation loc = _assLocationRepository.GetByID(inputDto.LOCATIONID).FirstOrDefault();
                if (loc.ISLOCKED == 1)
                {
                    throw new Exception("该区域已锁定,无法创建新的盘点单!");
                }
                try
                {
                    _unitOfWork.RegisterNew(assbo);

                    loc.ISLOCKED = 1;
                    _unitOfWork.RegisterDirty(loc);        //锁定区域

                    bool result = _unitOfWork.Commit();
                    rInfo.IsSuccess = result;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    rInfo.IsSuccess = false;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
            }
            else
            {
                rInfo.IsSuccess = false;
                rInfo.ErrorInfo = sb.ToString();
                return(rInfo);
            }
        }
コード例 #4
0
        /// <summary>
        /// 添加盘点单
        /// </summary>
        /// <param name="inputDto">盘点单信息</param>
        /// <returns></returns>
        public ReturnInfo AddConInventory(ConInventoryInputDto inputDto)
        {
            //验证
            ReturnInfo    rInfo = new ReturnInfo();
            StringBuilder sb    = new StringBuilder();
            string        maxId = _conInventoryRepository.GetMaxId();
            string        IId   = Helper.GenerateIDEx("CI", maxId);

            inputDto.IID = IId;
            sb.Append(Helper.BasicValidate(inputDto).ToString());
            if (sb.Length == 0)
            {
                var assbo = Mapper.Map <ConInventoryInputDto, ConInventory>(inputDto);
                assbo.STATUS     = (int)InventoryStatus.盘点未开始;
                assbo.CREATEDATE = DateTime.Now;
                assbo.MODIFYDATE = DateTime.Now;

                try
                {
                    _unitOfWork.RegisterNew(assbo);

                    bool result = _unitOfWork.Commit();
                    rInfo.IsSuccess = result;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    rInfo.IsSuccess = false;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
            }
            else
            {
                rInfo.IsSuccess = false;
                rInfo.ErrorInfo = sb.ToString();
                return(rInfo);
            }
        }
コード例 #5
0
        /// <summary>
        /// 上传结果
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void plSave_Press(object sender, EventArgs e)
        {
            ReturnInfo rInfo = new ReturnInfo();
            //上传结果
            ConInventoryInputDto inputDto = new ConInventoryInputDto
            {
                IID           = IID,
                IsEnd         = false,
                ConDictionary = conDictionary,
                WAREID        = lblWareHouse.Tag.ToString(),
                MODIFYUSER    = UserId
            };

            if (lblST.Tag != null)
            {
                inputDto.STID = lblST.Tag.ToString();
            }
            if (lblSL.Tag != null)
            {
                inputDto.SLID = lblSL.Tag.ToString();
            }
            rInfo = _autofacConfig.ConInventoryService.UpdateInventory(inputDto);
            Toast(rInfo.IsSuccess ? "上传结果成功!" : rInfo.ErrorInfo);
        }
コード例 #6
0
        /// <summary>
        /// 盘点上传或盘点结束
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmConInventoryResult_ActionButtonPress(object sender, ActionButtonPressEventArgs e)
        {
            try
            {
                ReturnInfo rInfo = new ReturnInfo();
                switch (e.Index)
                {
                case 0:
                    //上传结果
                    ConInventoryInputDto inputDto = new ConInventoryInputDto
                    {
                        IID           = IID,
                        IsEnd         = false,
                        ConDictionary = conDictionary,
                        LOCATIONID    = LocationId,
                        CREATEUSER    = UserId
                    };
                    inputDto.IsEnd = false;
                    rInfo          = _autofacConfig.ConInventoryService.UpdateInventory(inputDto);
                    Toast(rInfo.IsSuccess ? "上传结果成功!" : rInfo.ErrorInfo);
                    break;

                case 1:
                    //盘点结束
                    Dictionary <string, List <decimal> > conDictionary2 = new Dictionary <string, List <decimal> >();
                    foreach (var key in conDictionary.Keys)
                    {
                        if (conDictionary[key][1] == (int)ResultStatus.待盘点)
                        {
                            List <decimal> list = new List <decimal>();
                            list.Add(0);
                            list.Add(Convert.ToDecimal((int)ResultStatus.盘亏));
                            conDictionary2.Add(key, list);
                        }
                        else
                        {
                            conDictionary2.Add(key, conDictionary[key]);
                        }
                    }

                    ConInventoryInputDto inputDto2 = new ConInventoryInputDto
                    {
                        IID           = IID,
                        LOCATIONID    = LocationId,
                        IsEnd         = false,
                        ConDictionary = conDictionary2
                    };
                    inputDto2.IsEnd = true;
                    rInfo           = _autofacConfig.ConInventoryService.UpdateInventory(inputDto2);
                    if (rInfo.IsSuccess)
                    {
                        ShowResult = ShowResult.Yes;
                        Close();
                        Toast("盘点结束成功.");
                    }
                    else
                    {
                        Toast(rInfo.ErrorInfo);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message);
            }
        }
コード例 #7
0
        /// <summary>
        /// 开始盘点/结束盘点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void plAction_Press(object sender, EventArgs e)
        {
            try
            {
                ReturnInfo rInfo = new ReturnInfo();
                if (Status == InventoryStatus.未盘点)
                {
                    AddCIResultInputDto inputDto = new AddCIResultInputDto
                    {
                        IID    = IID,
                        UserId = Client.Session["UserID"].ToString()
                    };
                    var inventory = _autofacConfig.ConInventoryService.GetConInventoryById(IID);
                    rInfo = _autofacConfig.ConInventoryService.AddConInventoryResult(inputDto);
                    if (rInfo.IsSuccess)
                    {
                        Toast("盘点开始");
                        Bind();
                    }
                    else
                    {
                        throw new Exception(rInfo.ErrorInfo);
                    }
                }
                else
                {
                    //盘点结束
                    Dictionary <string, List <decimal> > conDictionary2 = new Dictionary <string, List <decimal> >();
                    foreach (var key in conDictionary.Keys)
                    {
                        if (conDictionary[key][1] == (int)ResultStatus.待盘点)
                        {
                            List <decimal> list = new List <decimal>();
                            list.Add(0);
                            list.Add(Convert.ToDecimal((int)ResultStatus.盘亏));
                            conDictionary2.Add(key, list);
                        }
                        else
                        {
                            conDictionary2.Add(key, conDictionary[key]);
                        }
                    }

                    ConInventoryInputDto inputDto2 = new ConInventoryInputDto
                    {
                        IID           = IID,
                        WAREID        = lblWareHouse.Tag.ToString(),
                        IsEnd         = true,
                        ConDictionary = conDictionary2
                    };
                    inputDto2.IsEnd = true;
                    rInfo           = _autofacConfig.ConInventoryService.UpdateInventory(inputDto2);
                    if (rInfo.IsSuccess)
                    {
                        ShowResult = ShowResult.Yes;
                        Close();
                        Toast("盘点结束成功.");
                    }
                    else
                    {
                        Toast(rInfo.ErrorInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                Form.Toast(ex.Message);
            }
        }
コード例 #8
0
        /// <summary>
        /// 更新盘点单
        /// </summary>
        /// <param name="inputDto">盘点单信息</param>
        /// <returns></returns>
        public ReturnInfo UpdateInventory(ConInventoryInputDto inputDto)
        {
            ReturnInfo    rInfo     = new ReturnInfo();
            StringBuilder sb        = new StringBuilder();
            var           inventory = _conInventoryRepository.GetConInventoryByID(inputDto.IID).FirstOrDefault();

            if (inventory == null)
            {
                sb.Append("未找到该编号的盘点单.");
                rInfo.IsSuccess = false;
                rInfo.ErrorInfo = sb.ToString();
                return(rInfo);
            }
            else
            {
                if (inventory.STATUS == (int)InventoryStatus.盘点结束)
                {
                    sb.Append("该盘点单已经盘点结束.");
                    rInfo.IsSuccess = false;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
                try
                {
                    List <string> assList = _conInventoryResultRepository.GetResultsByStatus(inputDto.IID, null).Select(a => a.CID).ToList();
                    int           count   = inputDto.ConDictionary.Count;
                    //更新盘点单结果行项
                    foreach (var key in inputDto.ConDictionary.Keys)
                    {
                        if (assList.Contains(key))
                        {
                            //更新
                            var inventoryresult = _conInventoryResultRepository.GetResultsByCID(inputDto.IID, key)
                                                  .FirstOrDefault();
                            if (inventoryresult != null)
                            {
                                inventoryresult.RESULT     = Convert.ToInt32(inputDto.ConDictionary[key][1]);
                                inventoryresult.REALAMOUNT = inputDto.ConDictionary[key][0];
                                if (inventoryresult.RESULT == (int)ResultStatus.待盘点)
                                {
                                    count--;
                                }
                            }

                            _unitOfWork.RegisterDirty(inventoryresult);
                        }
                        else
                        {
                            //添加
                            ConInventoryResult result = new ConInventoryResult
                            {
                                IID        = inputDto.IID,
                                CID        = key,
                                REALAMOUNT = inputDto.ConDictionary[key][0],
                                RESULT     = Convert.ToInt32(inputDto.ConDictionary[key][1]),
                                CREATEDATE = DateTime.Now,
                                MODIFYDATE = DateTime.Now,
                                CREATEUSER = inputDto.MODIFYUSER,
                                MODIFYUSER = inputDto.MODIFYUSER
                            };
                            _unitOfWork.RegisterNew(result);
                        }
                        if (inputDto.IsEnd)
                        {
                            //如果盘点结束,就更新资产状态为非锁定
                            var conqs = _conQuantRepository.GetQuants(inputDto.LOCATIONID, key).FirstOrDefault();
                            if (conqs != null)
                            {
                                conqs.ISLOCKED = 0;
                                _unitOfWork.RegisterDirty(conqs);
                            }

                            AssLocation loc = _assLocationRepository.GetByID(inputDto.LOCATIONID).FirstOrDefault();
                            if (loc != null)
                            {
                                loc.ISLOCKED = 0;
                                _unitOfWork.RegisterDirty(loc);
                            }
                        }
                    }
                    //如果盘点结束,就更新盘点单状态
                    inventory.MODIFYUSER  = inputDto.MODIFYUSER;
                    inventory.MODIFYDATE  = DateTime.Now;
                    inventory.RESULTCOUNT = count;
                    if (inputDto.IsEnd)
                    {
                        inventory.STATUS = (int)InventoryStatus.盘点结束;
                    }
                    _unitOfWork.RegisterDirty(inventory);

                    _unitOfWork.Commit();
                    rInfo.IsSuccess = true;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    rInfo.IsSuccess = false;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// 更新盘点单
        /// </summary>
        /// <param name="inputDto">盘点单信息</param>
        /// <returns></returns>
        public ReturnInfo UpdateInventory(ConInventoryInputDto inputDto)
        {
            ReturnInfo    rInfo     = new ReturnInfo();
            StringBuilder sb        = new StringBuilder();
            var           inventory = _conInventoryRepository.GetConInventoryByID(inputDto.IID).FirstOrDefault();

            if (inventory == null)
            {
                sb.Append("未找到该编号的盘点单.");
                rInfo.IsSuccess = false;
                rInfo.ErrorInfo = sb.ToString();
                return(rInfo);
            }
            else
            {
                if (inventory.STATUS == (int)InventoryStatus.盘点结束)
                {
                    sb.Append("该盘点单已经盘点结束.");
                    rInfo.IsSuccess = false;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
                try
                {
                    List <ConInventoryResult> resultList = _conInventoryResultRepository.GetResultsByStatus(inputDto.IID, null).ToList();
                    List <String>             keyList    = new List <string>();
                    if (resultList.Count > 0)
                    {
                        foreach (ConInventoryResult row in resultList)
                        {
                            keyList.Add(row.CID + "/" + row.WAREID + "/" + row.STID + "/" + row.SLID);
                        }
                    }
                    int count = inputDto.ConDictionary.Count;
                    //更新盘点单结果行项
                    foreach (var key in inputDto.ConDictionary.Keys)
                    {
                        if (keyList.Contains(key))
                        {
                            String[] keys = key.Split('/');
                            //更新
                            ConInventoryResult inventoryresult = _conInventoryResultRepository.GetResultBySL
                                                                     (inputDto.IID, keys[0], keys[1], keys[2], keys[3]).FirstOrDefault();
                            if (inventoryresult != null)
                            {
                                inventoryresult.RESULT     = Convert.ToInt32(inputDto.ConDictionary[key][1]);
                                inventoryresult.REALAMOUNT = inputDto.ConDictionary[key][0];
                                if (inventoryresult.RESULT == (int)ResultStatus.待盘点)
                                {
                                    count--;
                                }
                            }
                            _unitOfWork.RegisterDirty(inventoryresult);
                        }
                        else
                        {
                            //添加
                            ConInventoryResult result = new ConInventoryResult
                            {
                                IID        = inputDto.IID,
                                CID        = key.Split('/')[0],
                                WAREID     = key.Split('/')[1],
                                STID       = key.Split('/')[2],
                                SLID       = key.Split('/')[3],
                                REALAMOUNT = inputDto.ConDictionary[key][0],
                                RESULT     = Convert.ToInt32(inputDto.ConDictionary[key][1]),
                                CREATEDATE = DateTime.Now,
                                MODIFYDATE = DateTime.Now,
                                CREATEUSER = inputDto.MODIFYUSER,
                                MODIFYUSER = inputDto.MODIFYUSER
                            };
                            _unitOfWork.RegisterNew(result);
                        }
                        if (inputDto.IsEnd)
                        {
                            //如果盘点结束,就更新资产状态为非锁定
                            var conqs = _conQuantRepository.GetQuants(inputDto.WAREID, key).FirstOrDefault();
                            if (conqs != null)
                            {
                                conqs.ISLOCKED = 0;
                                _unitOfWork.RegisterDirty(conqs);
                            }
                        }
                    }
                    //如果盘点结束,就更新盘点单状态
                    inventory.MODIFYUSER  = inputDto.MODIFYUSER;
                    inventory.MODIFYDATE  = DateTime.Now;
                    inventory.RESULTCOUNT = count;
                    if (inputDto.IsEnd)
                    {
                        inventory.STATUS = (int)InventoryStatus.盘点结束;
                    }
                    _unitOfWork.RegisterDirty(inventory);

                    _unitOfWork.Commit();
                    rInfo.IsSuccess = true;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    rInfo.IsSuccess = false;
                    rInfo.ErrorInfo = sb.ToString();
                    return(rInfo);
                }
            }
        }