예제 #1
0
        public bool GetModelListByCar(string strCarNo, ref T_OutStockInfo model ,ref string strError) 
        {
            string strFilter = "   erpvoucherno = ( select erpvoucherno from t_task where taskno = (select taskno from t_Pickcar where carno = '"+strCarNo+"') )";

            string strFilter1 = "erpvoucherno like '%" + strCarNo + "%'";

            //扫描批次标签
            if (strCarNo.Contains("@"))
            {
                string strSerialNo = OutBarCode.OutBarCode_DeCode.GetEndSerialNo(strCarNo);
                string strFilter2 = "   erpvoucherno = (select erpvoucherno from t_Taskdetails where id  = (select a.Taskdetailesid from t_stock a where a.Serialno = '" + strSerialNo + "'))";
                model = base.GetModelByFilter(strFilter2);
            }
            else 
            {
                //先查小车
                //model = base.GetModelByFilter(strFilter);

                //if (model == null)
                //{
                //    //再查ERP单号
                //    model = base.GetModelByFilter(strFilter1);
                //}
                //再查ERP单号
                model = base.GetModelByFilter(strFilter1);

            }

            if (model == null) 
            {
                strError = "该单据编号不存在或者小车编码未关联拣货单!" ;
                return false;
            }

            model.lstDetail = new List<T_OutStockDetailInfo>();

            T_OutTaskDetails_DB tdb = new T_OutTaskDetails_DB();
            List<T_OutStockTaskDetailsInfo> modelListTaskDetail = new List<T_OutStockTaskDetailsInfo>();

            if (tdb.GetOutTaskDetailByErpVoucherNo(model.ErpVoucherNo, ref modelListTaskDetail, ref strError) == false) 
            {
                return false;
            }

            T_OutStockDetail_DB odb = new T_OutStockDetail_DB();
            model.lstDetail = odb.CreateOutStockDetailByTaskDetail(modelListTaskDetail);
            model.ToErpWarehouse = model.lstDetail != null ? model.lstDetail[0].ToErpWarehouse : string.Empty;

            //T_OutStockDetail_DB _db = new T_OutStockDetail_DB();
            ////model.lstDetail = _db.GetModelListByHeaderIDForCar(model.ID);
            //T_OutStockDetail_Func tfunc = new T_OutStockDetail_Func();
            //model.lstDetail = tfunc.OutStockSameMaterialNoSumQty(_db.GetModelListByHeaderIDForCar(model.ID));

            return true;
        }
예제 #2
0
파일: Box_Func.cs 프로젝트: shew990/TaiBang
        /// <summary>
        /// 生成物流箱码
        /// </summary>
        /// <param name="user"></param>
        /// <param name="lstErpVoucherNo"></param>
        /// <param name="HeadName"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        public bool CreatePrintBoxInfo(UserModel user, List <string> lstID, string HeadName, ref string strError)
        {
            try
            {
                List <T_BoxInfo> lstBox             = new List <T_BoxInfo>();//存放需要提交的数据
                List <T_BoxInfo> CreateLstBox       = new List <T_BoxInfo>();
                T_Box_DB         _tdb               = new T_Box_DB();
                string           strErpNote         = string.Empty;
                string           strCustomerName    = string.Empty;
                string           strErpNoteCat      = string.Empty;
                string           strErpVoucherNoCat = string.Empty;
                int  iDelNo = 0;
                bool bSucc  = true;
                List <T_OutStockInfo> outNewStockList = new List <T_OutStockInfo>();

                if (lstID == null || lstID.Count == 0)
                {
                    strError = "提交的生成箱子数据为空!";
                    return(false);
                }

                string strFilter = string.Empty;//"erpvoucherno = '" + ErpVoucherNo + "'";

                T_OutStock_Func       tfunc        = new T_OutStock_Func();
                List <T_OutStockInfo> outStockList = new List <T_OutStockInfo>();
                foreach (var item in lstID)
                {
                    T_OutStockInfo model = new T_OutStockInfo();
                    strFilter = "id = '" + item + "'";
                    tfunc.GetModelByFilter(ref model, strFilter, ref strError);
                    outStockList.Add(model);
                }

                if (outStockList == null || outStockList.Count == 0)
                {
                    strError = "未能获取订单数据";
                    return(false);
                }



                GetPinErpvoucherNo(ref outNewStockList, CreateNewOutStock(outStockList));

                if (outNewStockList != null && outNewStockList.Count > 0)
                {
                    foreach (var item in outNewStockList)
                    {
                        T_OutStockInfo model1 = new T_OutStockInfo();
                        strFilter = "erpvoucherno = '" + item.ErpVoucherNo + "'";
                        tfunc.GetModelByFilter(ref model1, strFilter, ref strError);
                        outStockList.Add(model1);
                    }
                }


                if (CheckVoucherTypeIsSame(outStockList, ref strError) == false)
                {
                    return(false);
                }

                foreach (var item in outStockList)
                {
                    if (item.Status == 1)
                    {
                        strError += "订单号:" + item.ErpVoucherNo + "处于新建状态,不能生成物流标签!" + "\r\n";
                        bSucc     = false;
                    }
                }

                if (bSucc == false)
                {
                    return(false);
                }

                T_OutTaskDetails_DB tdb = new T_OutTaskDetails_DB();
                List <T_OutStockTaskDetailsInfo> modelListTaskDetail = new List <T_OutStockTaskDetailsInfo>();

                foreach (var item in outStockList)
                {
                    if (tdb.GetOutTaskDetailByErpVoucherNo(item.ErpVoucherNo, ref modelListTaskDetail, ref strError) == false)
                    {
                        return(false);
                    }

                    if (modelListTaskDetail.Where(t => t.UnReviewQty > 0).Count() > 0)
                    {
                        strError = "订单:" + item.ErpVoucherNo + "没有全部复核完成,不能生成物流标签!";
                        bSucc    = false;
                        break;
                    }
                }

                if (bSucc == false)
                {
                    return(false);
                }

                T_Box_DB boxdb = new T_Box_DB();
                foreach (var item in outStockList)
                {
                    if (boxdb.GetErpVoucherNoIsPrint(item.ErpVoucherNo, ref strError) == false)
                    {
                        bSucc = false;
                        break;
                    }
                }

                if (bSucc == false)
                {
                    return(false);
                }


                //其他出库单,需要判断客户是否相同
                if (outStockList[0].VoucherType == 24)
                {
                    if (CheckCustomerIsSame(outStockList, ref strError) == false)
                    {
                        return(false);
                    }
                    strCustomerName = outStockList[0].CustomerName;
                }
                else ///调拨出库单,验证调入仓库是否相同
                {
                    T_OutStockDetail_Func       tfuncd               = new T_OutStockDetail_Func();
                    List <T_OutStockDetailInfo> lstOutStockDetail    = new List <T_OutStockDetailInfo>();
                    List <T_OutStockDetailInfo> lstOutStockDetailSum = new List <T_OutStockDetailInfo>();
                    foreach (var item in lstID)
                    {
                        strFilter = "headerid = '" + item + "'";
                        tfuncd.GetModelListByFilter(ref lstOutStockDetail, ref strError, "", strFilter, "*");
                        lstOutStockDetailSum.AddRange(lstOutStockDetail);
                    }

                    if (CheckWarehouseIsSame(lstOutStockDetailSum, ref strError) == false)
                    {
                        return(false);
                    }
                    strCustomerName = lstOutStockDetailSum[0].ToErpWarehouseName;
                }

                foreach (var item in outStockList)
                {
                    CreateLstBox.AddRange(GetNeBox(_tdb.GetPrintBoxInfo(item.ErpVoucherNo), item.ErpVoucherNo, strCustomerName, item.ERPNote, HeadName));
                }

                if (CreateLstBox == null || CreateLstBox.Count == 0)
                {
                    strError = "可以生成箱子的数据为空!";
                    return(false);
                }

                List <T_BoxInfo> lstNewCreateBox = ModelListGroupBy(CreateLstBox);
                List <T_BoxInfo> lstFserialNo    = new List <T_BoxInfo>();
                string           strFserialNoCat = string.Empty;

                foreach (var item in lstNewCreateBox)
                {
                    lstFserialNo = _tdb.GetSerialNoByFserialNo(item.SerialNo);
                    if (lstFserialNo != null && lstFserialNo.Count > 0)
                    {
                        foreach (var item1 in lstFserialNo)
                        {
                            strFserialNoCat += item1.SerialNo + ",";
                        }
                        item.SerialNo = strFserialNoCat.TrimEnd(',');
                    }
                }

                foreach (var item in lstNewCreateBox)
                {
                    iDelNo    += 1;
                    item.DelNo = iDelNo.ToString().PadLeft(4, '0');
                    //item.Remark = strErpNoteCat;
                    //item.ErpVoucherNo = strErpVoucherNoCat;
                }

                //lstNewCreateBox.OrderBy(t => t.IsAmount);

                return(_tdb.SaveBoxByModelList(user, lstNewCreateBox.OrderBy(t => t.IsAmount).ToList(), ref strError));
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
예제 #3
0
        public string Post(string ErpVoucherNo, string Remark, string Guid, string Creater)
        {
            LogNet.LogInfo("-------------------------------------------直发公司ErpVoucherNo:【" + ErpVoucherNo + "】,  Remark:【" + Remark + "】, Guid:【" + Guid + "】, Creater::【" + Creater + "】");
            BaseMessage_Model <string> messageModel = new BaseMessage_Model <string>();

            try
            {
                T_Material_Batch_DB _db = new T_Material_Batch_DB();
                //成品需要检验库存
                string Msg  = "";
                bool   isOK = _db.isChengpin(ErpVoucherNo, ref Msg);
                if (isOK)
                {
                    if (!string.IsNullOrEmpty(Msg))
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = Msg;
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }

                    T_OutBarcode_DB         OutBarcodeDB    = new T_OutBarcode_DB();
                    List <T_OutBarCodeInfo> OutBarCodeInfos = OutBarcodeDB.GetModelListByFilter("", " dimension='" + ErpVoucherNo + "'", " * ");
                    if (OutBarCodeInfos == null || OutBarCodeInfos.Count == 0)
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = "WMS不存在属于该成品入库单【" + ErpVoucherNo + "】的条码!";
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }
                }

                string strERP = _db.Post(ErpVoucherNo, Remark, Guid, Creater);
                if (strERP.Substring(0, 1) == "0")
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = strERP;
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                }

                if (isOK)
                {
                    string strError = "";
                    T_OutTaskDetails_DB _dbOutTaskDetails = new T_OutTaskDetails_DB();
                    LogNet.LogInfo("-------------------------------------------直发公司ERP成功凭证号:" + strERP.Substring(1, strERP.Length - 1));
                    if (_dbOutTaskDetails.DelStockForU9(ErpVoucherNo, strERP.Substring(1, strERP.Length - 1), ref strError) == false)
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = "ERP操作成功,ERP凭证号:" + strERP.Substring(1, strERP.Length - 1) + "WMS失败:" + strError;
                        LogNet.LogInfo("-------------------------------------------直发公司ERP成功凭证号:" + messageModel.Message);
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }
                    else
                    {
                        messageModel.HeaderStatus = "S";
                        messageModel.Message      = "操作成功!ERP凭证号:" + strERP.Substring(1, strERP.Length - 1);
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                    }
                }
                else
                {
                    messageModel.HeaderStatus = "S";
                    messageModel.Message      = "操作成功!ERP凭证号:" + strERP.Substring(1, strERP.Length - 1);
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
                }
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <string> >(messageModel));
            }
        }