Exemplo n.º 1
0
        public bool Add(DateTime datetime, out string strResult)
        {
            bool result = false;

            strResult = string.Empty;

            var moveBillMaster = MoveBillMasterRepository.GetQueryable().Where(i => i.BillDate <= datetime);
            var moveBillDetail = MoveBillDetailRepository.GetQueryable().Where(i => i.MoveBillMaster.BillDate <= datetime);

            if (moveBillMaster.Any())
            {
                #region 主表移入历史表
                try
                {
                    foreach (var item in moveBillMaster.ToArray())
                    {
                        MoveBillMasterHistory history = new MoveBillMasterHistory();
                        history.BillNo          = item.BillNo;
                        history.BillDate        = item.BillDate;
                        history.BillTypeCode    = item.BillTypeCode;
                        history.WarehouseCode   = item.WarehouseCode;
                        history.OperatePersonID = item.OperatePersonID;
                        history.Status          = item.Status;
                        history.VerifyPersonID  = item.VerifyPersonID;
                        history.VerifyDate      = item.VerifyDate;
                        history.Description     = item.Description;
                        history.IsActive        = item.IsActive;
                        history.UpdateTime      = item.UpdateTime;
                        history.Origin          = item.Origin;
                        MoveBillMasterHistoryRepository.Add(history);
                    }
                    result = true;
                }
                catch (Exception e)
                {
                    strResult = "主库单:" + e.InnerException.ToString();
                    result    = false;
                }
                #endregion

                if (moveBillDetail.Any())
                {
                    #region 细表移入历史表
                    try
                    {
                        foreach (var item in moveBillDetail.ToArray())
                        {
                            MoveBillDetailHistory history = new MoveBillDetailHistory();
                            history.BillNo          = item.BillNo;
                            history.ProductCode     = item.ProductCode;
                            history.OutCellCode     = item.OutCellCode;
                            history.OutStorageCode  = item.OutStorageCode;
                            history.InCellCode      = item.InCellCode;
                            history.InStorageCode   = item.InStorageCode;
                            history.UnitCode        = item.UnitCode;
                            history.RealQuantity    = item.RealQuantity;
                            history.OperatePersonID = item.OperatePersonID;
                            history.StartTime       = item.StartTime;
                            history.FinishTime      = item.FinishTime;
                            history.Status          = item.Status;
                            history.Operator        = item.Operator;
                            history.CanRealOperate  = item.CanRealOperate;
                            history.PalletTag       = item.PalletTag;
                            MoveBillDetailHistoryRepository.Add(history);
                        }
                        result = true;
                    }
                    catch (Exception e)
                    {
                        strResult = "细库单:" + e.InnerException.ToString();;
                    }
                    #endregion
                }
                if (result == true)
                {
                    #region  除主细分配表
                    try
                    {
                        foreach (var item in moveBillMaster.ToList())
                        {
                            Del(MoveBillDetailRepository, item.MoveBillDetails);
                            MoveBillMasterRepository.Delete(item);
                            result = true;
                        }
                    }
                    catch (Exception e)
                    {
                        strResult = "删除情况" + e.InnerException.ToString();
                    }
                    MoveBillMasterHistoryRepository.SaveChanges();
                    #endregion
                }
            }
            else
            {
                strResult = "数据不存在!";
            }
            return(result);
        }
Exemplo n.º 2
0
        public ActionResult MoveDataIsHistory(string dateTime, string billType)
        {
            string   msg = string.Empty;
            bool     bResult;
            string   strResult = string.Empty;
            DateTime time      = Convert.ToDateTime(dateTime);

            switch (billType)
            {
            case "1":    //入库单据
                bResult = InBillMasterHistory.Add(time, out strResult);
                if (!bResult)
                {
                    msg = "入库操作:" + strResult;
                }
                break;

            case "2":    //出库单据
                bResult = OutBillMasterHistory.Add(time, out strResult);
                if (!bResult)
                {
                    msg = "出库操作:" + strResult;
                }
                break;

            case "3":    //移库单据
                bResult = MoveBillMasterHistory.Add(time, out strResult);
                if (!bResult)
                {
                    msg = "移库操作:" + strResult;
                }
                break;

            case "4":    //盘点单据
                bResult = CheckBillMasterHistory.Add(time, out strResult);
                if (!bResult)
                {
                    msg = "盘点操作:" + strResult;
                }
                break;

            case "5":    //损益单据
                bResult = ProfitLossBillMasterHistory.Add(time, out strResult);
                if (!bResult)
                {
                    msg = "损益操作:" + strResult;
                }
                break;

            case "6":    //日结
                bResult = DailyBalanceHistoryService.Add(time, out strResult);
                if (!bResult)
                {
                    msg = "出库操作:" + strResult;
                }
                break;

            default:
                msg = "调用了未定义的方法!";
                break;
            }
            return(new ContentResult()
            {
                Content = msg, ContentEncoding = Encoding.GetEncoding("GB2312"), ContentType = "text"
            });
        }