예제 #1
0
        //行项目
        protected override void BindingOrderItem(object[] array)
        {
            if (_stockIn.StockDetail == null)
            {
                _stockIn.StockDetail = new EntityCollection <StockDetail>();
            }

            if (_itemDefine == null)
            {
                throw new ApplicationException("未发现行项目字段定义!");
            }

            if (_itemDefine.Count() == array.Count())
            {
                StockDetail stockItem = new StockDetail();
                for (int i = 0; i < array.Count(); i++)
                {
                    string fieldName  = Regex.Replace(_itemDefine[i].ToString(), @"\s", "");
                    string fieldValue = Regex.Replace(array[i].ToString(), @"\s", "");

                    switch (fieldName)
                    {
                    case "商品编码":
                        stockItem.CargoCode = fieldValue;
                        string cargoCode = DbCommonMethod.ParsingCargoCode(fieldValue);
                        if (string.IsNullOrEmpty(cargoCode))
                        {
                            throw new ApplicationException("商品不存在:" + fieldValue);
                        }
                        break;

                    case "商品名称":
                        stockItem.CargoName = fieldValue;
                        break;

                    case "规格":
                        stockItem.CargoSpec = fieldValue;
                        break;

                    case "型号":
                        //过滤型号值,如果型号是90.000,则去90,去掉小数点后面的0
                        double dou;
                        string strModel = fieldValue;
                        double douModel = 0;
                        if (double.TryParse(fieldValue, out dou))
                        {
                            douModel = dou;
                        }

                        if (douModel != 0 && strModel.Contains("."))
                        {
                            string sdecimal = strModel.Substring(strModel.IndexOf(".") + 1, strModel.Length - strModel.IndexOf(".") - 1);
                            int    istring  = Convert.ToInt32(sdecimal);
                            if (istring == 0)
                            {
                                strModel = fieldValue.Substring(0, fieldValue.IndexOf("."));
                            }
                        }
                        stockItem.CargoModel = strModel;
                        break;

                    case "单位":
                        stockItem.CargoUnits = fieldValue;
                        break;

                    case "数量":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                stockItem.NumOriginalPlan = d;
                            }
                        }
                        break;

                    case "备注":
                        stockItem.Comment = fieldValue;
                        break;

                    default:
                        break;
                    }
                }
                if (string.IsNullOrEmpty(stockItem.BillRowNumber))
                {
                    stockItem.BillRowNumber = _rowNum.ToString();
                }

                //if (string.IsNullOrEmpty(_order.SICode))
                //    _order.SICode = KeyGenerator.Instance.GetStockInKey();

                stockItem.NumCurrentPlan = stockItem.NumOriginalPlan; //订单数量=应收数量,默认值
                stockItem.CargoStatus    = 0;                         //手持机未完成
                stockItem.BillCode       = _stockIn.SICode;
                stockItem.SICode         = _stockIn.SICode;
                stockItem.BillType       = "02";//入库单
                stockItem.InOutWHCode    = _stockIn.WHCode;
                stockItem.StockIn        = _stockIn;

                IEnumerable <KeyValuePair <string, object> > entityKeyValues =
                    new KeyValuePair <string, object>[] {
                    new KeyValuePair <string, object>("BillCode", stockItem.BillCode),
                    new KeyValuePair <string, object>("BillRowNumber", stockItem.BillRowNumber)
                };
                stockItem.EntityKey = new EntityKey("GoldEntities.StockDetail", entityKeyValues);
                _stockIn.StockDetail.Add(stockItem);
            }
        }
예제 #2
0
        //设置抬头数据
        protected override void BindingOrderHeader(string fieldName, string fieldValue)
        {
            switch (fieldName)
            {
            case "入库单号":
                _stockIn.FromBillNo = fieldValue;
                _stockIn.SICode     = DbCommonMethod.GetStockInCode(fieldValue);
                break;

            case "日期":
                if (!string.IsNullOrEmpty(fieldValue))
                {
                    DateTime dt;
                    if (DateTime.TryParse(fieldValue, out dt))
                    {
                        _stockIn.SIDate = dt;
                    }
                }
                break;

            case "供货单位":
                _stockIn.Supplier = fieldValue;
                break;

            case "业务部门":
                _stockIn.BusinessDepartmentName = fieldValue;
                break;

            case "业务员":
                _stockIn.Operator = fieldValue;
                break;

            case "仓库":
                _stockIn.WHName = fieldValue;
                _stockIn.WHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                if (string.IsNullOrEmpty(_stockIn.WHCode))
                {
                    throw new ApplicationException("仓库不存在:" + fieldValue);
                }
                break;

            case "库管员":
                _stockIn.StoreKeeper = fieldValue;
                break;

            case "备注":
                _stockIn.Comment = fieldValue;
                break;

            case "合计数量":
                if (!string.IsNullOrEmpty(fieldValue))
                {
                    double d;
                    if (double.TryParse(fieldValue, out d))
                    {
                        _stockIn.TotalNumber = d;
                    }
                }
                break;

            case "仓管":
                // _order.BusinessManager = fieldValue;
                break;

            case "验收":
                _stockIn.Checker = fieldValue;
                break;

            default:
                break;
            }
        }
예제 #3
0
        /// <summary>
        /// 从DataTable中获取实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.StockIn> GetModelFromDataTable(DataTable dt, out string msg)
        {
            try
            {
                List <DAL.StockIn> list = new List <DAL.StockIn>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();
                dataFieldNameDic.Add("BillCode", "其他入库单号");
                dataFieldNameDic.Add("BillDate", "日期");
                dataFieldNameDic.Add("InCategory", "收发类别");
                dataFieldNameDic.Add("Supplier", "供货单位");
                dataFieldNameDic.Add("BusinessDepartmentName", "业务部门");
                dataFieldNameDic.Add("Operator", "业务员姓名");
                dataFieldNameDic.Add("WHName", "仓库名称");
                dataFieldNameDic.Add("StoreKeeper", "库管员");
                dataFieldNameDic.Add("Comment", "备注");
                dataFieldNameDic.Add("TotalNumber", "合计数量");
                dataFieldNameDic.Add("WareHouseKeeper", "仓管");
                dataFieldNameDic.Add("Checker", "验收");

                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <StockIn>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <StockIn>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    StockIn newModel = new StockIn();
                    //newModel.SICode = KeyGenerator.Instance.GetStockInKey();
                    newModel.FromBillNo = DataCheckHelper.GetCellString(dr["BillCode"]);

                    //日期
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["BillDate"])))
                    {
                        DateTime d;
                        if (DateTime.TryParse(DataCheckHelper.GetCellString(dr["BillDate"]), out d))
                        {
                            newModel.SIDate = d;
                        }
                    }

                    //收发类别
                    newModel.InCategory = DbCommonMethod.GetInCategory(DataCheckHelper.GetCellString(dr["InCategory"]));

                    newModel.Supplier = DataCheckHelper.GetCellString(dr["Supplier"]);
                    newModel.BusinessDepartmentName = DataCheckHelper.GetCellString(dr["BusinessDepartmentName"]);
                    newModel.Operator = DataCheckHelper.GetCellString(dr["Operator"]);

                    //仓库
                    newModel.WHName = DataCheckHelper.GetCellString(dr["WHName"]);
                    newModel.WHCode = DbCommonMethod.ParsingWarehouse(newModel.WHName);
                    if (string.IsNullOrEmpty(newModel.WHCode))
                    {
                        throw new ApplicationException("单号" + newModel.FromBillNo + ",仓库不存在:" + newModel.WHName);
                    }

                    newModel.StoreKeeper = DataCheckHelper.GetCellString(dr["StoreKeeper"]);
                    newModel.Comment     = DataCheckHelper.GetCellString(dr["Comment"]);

                    //合计数量
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalNumber"])))
                    {
                        double d;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["TotalNumber"]), out d))
                        {
                            newModel.TotalNumber = d;
                        }
                    }

                    //newModel = DataCheckHelper.GetCellString(dr["WareHouseKeeper"]);
                    newModel.Checker = DataCheckHelper.GetCellString(dr["Checker"]);

                    newModel.SIStatus     = 1;    //已保存
                    newModel.FromBillType = "23"; //21采购入库单、22调拨入库单、23其他入库单
                    newModel.SIType       = CommonConvert.GetSIOTypeCode("其他入库单");
                    newModel.FromType     = CommonConvert.GetFromTypeCode("源于Excel导入的入库单");

                    List <StockIn> existStockIn = (from r in list where r.FromBillNo == newModel.FromBillNo select r).ToList <StockIn>();
                    if (existStockIn == null || existStockIn.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <StockIn>());;
            }
        }
예제 #4
0
        /// <summary>
        /// 从DataTable中获取采购订单明细实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.StockDetail> GetModelDetailFromDataTable(DataTable dt, out string msg, string SICode, string WHCode)
        {
            try
            {
                List <DAL.StockDetail> list = new List <DAL.StockDetail>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();
                dataFieldNameDic.Add("BillCode", "其他入库单号");
                dataFieldNameDic.Add("DetailRowNumber", "行号");
                dataFieldNameDic.Add("CargoCode", "商品编码");
                dataFieldNameDic.Add("CargoName", "商品名称");
                dataFieldNameDic.Add("CargoSpec", "规格");
                dataFieldNameDic.Add("CargoModel", "型号");
                dataFieldNameDic.Add("CargoUnits", "单位");
                dataFieldNameDic.Add("NumOriginalPlan", "数量");
                dataFieldNameDic.Add("Remark", "备注");

                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <StockDetail>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <StockDetail>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    StockDetail newModel = new StockDetail();

                    //newModel.BillCode= DataCheckHelper.GetCellString(dr["BillCode"]);
                    newModel.BillRowNumber = DataCheckHelper.GetCellString(dr["DetailRowNumber"]);
                    //商品编码
                    newModel.CargoCode = DataCheckHelper.GetCellString(dr["CargoCode"]);
                    string cargoCode = DbCommonMethod.ParsingCargoCode(newModel.CargoCode);
                    if (string.IsNullOrEmpty(cargoCode))
                    {
                        throw new ApplicationException("单号" + DataCheckHelper.GetCellString(dr["BillCode"]) + ",商品不存在:" + newModel.CargoCode);
                    }

                    newModel.CargoName  = DataCheckHelper.GetCellString(dr["CargoName"]);
                    newModel.CargoSpec  = DataCheckHelper.GetCellString(dr["CargoSpec"]);
                    newModel.CargoModel = DataCheckHelper.GetCellString(dr["CargoModel"]);
                    newModel.CargoUnits = DataCheckHelper.GetCellString(dr["CargoUnits"]);

                    //数量
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["NumOriginalPlan"])))
                    {
                        double d;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["NumOriginalPlan"]), out d))
                        {
                            newModel.NumOriginalPlan = d;
                        }
                    }

                    newModel.Comment = DataCheckHelper.GetCellString(dr["Remark"]);

                    newModel.NumCurrentPlan = newModel.NumOriginalPlan; //订单数量=应收数量,默认值
                    newModel.CargoStatus    = 0;                        //手持机未完成
                    newModel.SICode         = SICode;
                    newModel.BillCode       = newModel.SICode;
                    newModel.BillType       = CommonConvert.GetBillTypeCode("入库单");
                    newModel.InOutWHCode    = WHCode;

                    string             bill             = DataCheckHelper.GetCellString(dr["BillCode"]);
                    List <StockDetail> existStockDetail = (from r in list where r.BillCode == bill && r.BillRowNumber == newModel.BillRowNumber select r).ToList <StockDetail>();
                    if (existStockDetail == null || existStockDetail.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <StockDetail>());;
            }
        }
예제 #5
0
        protected override void BindingOrderHeader(string fieldName, string fieldValue)
        {
            switch (fieldName)
            {
            case "转库单号":
                _order.NCOrderCode = fieldValue;
                _order.OrderCode   = fieldValue;
                break;

            case "日期":
                if (!string.IsNullOrEmpty(fieldValue))
                {
                    DateTime dt;
                    if (DateTime.TryParse(fieldValue, out dt))
                    {
                        _order.OrderDate = dt;
                    }
                }
                break;

            case "摘要":
                _order.Comment = fieldValue;
                break;

            case "调出仓库":
                _order.OutWHName = fieldValue;
                _order.OutWHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                //string whCode=DbCommonMethod.ParsingWarehouse(fieldValue);
                //if (whCode != string.Empty && whCode != null)
                //{
                //    _order.OutWHCode = whCode;
                //}
                if (string.IsNullOrEmpty(_order.OutWHCode))
                {
                    throw new ApplicationException("调出仓库不存在:" + fieldValue);
                }
                break;

            case "调入仓库":
                _order.InWHName = fieldValue;
                _order.InWHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                //string whInCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                //if (whInCode != string.Empty && whInCode != null)
                //{
                //    _order.InWHCode = whInCode;
                //}
                if (string.IsNullOrEmpty(_order.InWHCode))
                {
                    throw new ApplicationException("调入仓库不存在:" + fieldValue);
                }
                break;

            case "领导":
                _order.LeaderName = fieldValue;
                break;

            case "发货人":
                _order.SenderName = fieldValue;
                break;

            case "收货人":
                _order.ReceiverName = fieldValue;
                break;

            case "业务经理":
                _order.BusinessManager = fieldValue;
                break;

            default:
                break;
            }
        }
예제 #6
0
        //行项目
        protected override void BindingOrderItem(object[] array)
        {
            if (_order.PurchaseOrderDetail == null)
            {
                _order.PurchaseOrderDetail = new EntityCollection <PurchaseOrderDetail>();
            }

            if (_itemDefine == null)
            {
                throw new ApplicationException("未发现行项目字段定义!");
            }

            if (_itemDefine.Count() == array.Count())
            {
                PurchaseOrderDetail orderItem = new PurchaseOrderDetail();
                for (int i = 0; i < array.Count(); i++)
                {
                    string fieldName  = Regex.Replace(_itemDefine[i].ToString(), @"\s", "");
                    string fieldValue = Regex.Replace(array[i].ToString(), @"\s", "");

                    switch (fieldName)
                    {
                    case "行号":
                        if (fieldValue.Contains("."))    //如果行号是10.000,则取10,去掉小数点后面的0
                        {
                            orderItem.DetailRowNumber = fieldValue.Substring(0, fieldValue.IndexOf("."));
                        }
                        else
                        {
                            orderItem.DetailRowNumber = fieldValue;
                        }
                        break;

                    case "合同号":
                        orderItem.ContractNo = fieldValue;
                        break;

                    case "存货编码":
                        orderItem.CargoCode = fieldValue;
                        string cargoCode = DbCommonMethod.ParsingCargoCode(fieldValue);
                        if (string.IsNullOrEmpty(cargoCode))
                        {
                            throw new ApplicationException("商品不存在:" + fieldValue);
                        }
                        break;

                    case "存货名称":
                        orderItem.CargoName = fieldValue;
                        break;

                    case "规格":
                        orderItem.CargoSpec = fieldValue;
                        break;

                    case "型号":
                        //过滤型号值,如果型号是90.000,则去90,去掉小数点后面的0
                        double dou;
                        string strModel = fieldValue;
                        double douModel = 0;
                        if (double.TryParse(fieldValue, out dou))
                        {
                            douModel = dou;
                        }

                        if (douModel != 0 && strModel.Contains("."))
                        {
                            string sdecimal = strModel.Substring(strModel.IndexOf(".") + 1, strModel.Length - strModel.IndexOf(".") - 1);
                            int    istring  = Convert.ToInt32(sdecimal);
                            if (istring == 0)
                            {
                                strModel = fieldValue.Substring(0, fieldValue.IndexOf("."));
                            }
                        }
                        orderItem.CargoModel = strModel;
                        break;

                    //case "自由项":
                    //    orderItem.FreedomItem = fieldValue;
                    //    break;
                    case "收货仓库":
                        orderItem.WHName = fieldValue;
                        orderItem.WHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                        if (string.IsNullOrEmpty(orderItem.WHCode))
                        {
                            throw new ApplicationException("仓库不存在:" + fieldValue);
                        }
                        break;

                    case "计量单位":
                        orderItem.CargoUnits = fieldValue;
                        break;

                    case "数量":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                orderItem.NumOriginalPlan = d;
                            }
                        }
                        break;

                    case "含税单价":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal d;
                            if (decimal.TryParse(fieldValue, out d))
                            {
                                orderItem.PriceOfTax = d;
                            }
                        }
                        break;

                    case "单价":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal d;
                            if (decimal.TryParse(fieldValue, out d))
                            {
                                orderItem.Price = d;
                            }
                        }
                        break;

                    case "扣率":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                orderItem.DeductRate = d;
                            }
                        }
                        break;

                    case "净含税单价":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal d;
                            if (decimal.TryParse(fieldValue, out d))
                            {
                                orderItem.PriceOfNetTax = d;
                            }
                        }
                        break;

                    case "净单价":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal d;
                            if (decimal.TryParse(fieldValue, out d))
                            {
                                orderItem.NetPrice = d;
                            }
                        }
                        break;

                    case "金额":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal d;
                            if (decimal.TryParse(fieldValue, out d))
                            {
                                orderItem.TotalPrice = d;
                            }
                        }
                        break;

                    case "税率":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                orderItem.TaxRate = d;
                            }
                        }
                        break;

                    case "税额":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal d;
                            if (decimal.TryParse(fieldValue, out d))
                            {
                                orderItem.TotalTax = d;
                            }
                        }
                        break;

                    case "价税合计":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal d;
                            if (decimal.TryParse(fieldValue, out d))
                            {
                                orderItem.TotalTaxAndPrice = d;
                            }
                        }
                        break;

                    case "计划到货日期":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            DateTime d;
                            if (DateTime.TryParse(fieldValue, out d))
                            {
                                orderItem.PlanArrivalDate = d;
                            }
                        }
                        break;

                    case "币种":
                        orderItem.CurrencyType = fieldValue;
                        break;

                    case "折本汇率":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                orderItem.ExchangeRate = d;
                            }
                        }
                        break;

                    case "收货公司":
                        orderItem.ReceiveCompany = fieldValue;
                        break;

                    case "收货库存组织":
                        orderItem.ReceiveOrg = fieldValue;
                        break;

                    case "收票公司":
                        orderItem.ReceiveBillCompany = fieldValue;
                        break;

                    default:
                        break;
                    }
                }

                orderItem.DetailRowStatus = 2;//初始态
                orderItem.OrderCode       = _order.OrderCode;
                orderItem.NCOrderCode     = _order.NCOrderCode;
                orderItem.PurchaseOrder   = _order;
                IEnumerable <KeyValuePair <string, object> > entityKeyValues =
                    new KeyValuePair <string, object>[] {
                    new KeyValuePair <string, object>("OrderCode", orderItem.OrderCode),
                    new KeyValuePair <string, object>("DetailRowNumber", orderItem.DetailRowNumber)
                };
                orderItem.EntityKey = new EntityKey("GoldEntities.PurchaseOrderDetail", entityKeyValues);
                _order.PurchaseOrderDetail.Add(orderItem);
            }
        }
예제 #7
0
        protected override void BindingOrderHeader(string fieldName, string fieldValue)
        {
            switch (fieldName)
            {
            case "单据号":
                _order.FromBillNo = fieldValue;
                _order.SOCode     = DbCommonMethod.GetStockOutCode(fieldValue);
                break;

            case "日期":
                if (!string.IsNullOrEmpty(fieldValue))
                {
                    DateTime dt;
                    if (DateTime.TryParse(fieldValue, out dt))
                    {
                        _order.SODate = dt;
                    }
                }
                break;

            case "发出仓库":
                _order.WHName = fieldValue;
                _order.WHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                if (string.IsNullOrEmpty(_order.WHCode))
                {
                    throw new ApplicationException("仓库不存在:" + fieldValue);
                }
                break;

            case "备注":
                _order.Comment = fieldValue;
                break;

            case "收发类别":
                _order.OutCategory = DbCommonMethod.GetOutCategory(fieldValue);
                break;

            case "领导":
                _order.LeaderSign = fieldValue;
                break;

            case "仓管":
                _order.WarehouseSign = fieldValue;
                break;

            case "财务":
                _order.AccountSign = fieldValue;
                break;

            case "经办人":
                _order.BusinessSign = fieldValue;
                break;

            case "制单人":
                _order.EditorSign = fieldValue;
                break;

            case "合            计  (RMB)":
                if (!string.IsNullOrEmpty(fieldValue))
                {
                    decimal d;
                    if (decimal.TryParse(fieldValue, out d))
                    {
                        _order.TotalMoney = d;
                    }
                }
                break;

            default:
                break;
            }
        }
예제 #8
0
        /// <summary>
        /// 从DataTable中获取采购订单明细实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.TransferOrderDetail> GetModelDetailFromDataTable(DataTable dt, out string msg)
        {
            try
            {
                List <DAL.TransferOrderDetail> list = new List <DAL.TransferOrderDetail>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();

                dataFieldNameDic.Add("NCOrderCode", "订单编号");
                dataFieldNameDic.Add("DetailRowNumber", "行号");
                dataFieldNameDic.Add("CargoCode", "存货编码");
                dataFieldNameDic.Add("CargoName", "存货名称");
                dataFieldNameDic.Add("CargoSpec", "规格");
                dataFieldNameDic.Add("CargoModel", "型号");
                dataFieldNameDic.Add("CargoUnits", "主计量单位");
                dataFieldNameDic.Add("CargoUnitsAssist", "辅单位");
                dataFieldNameDic.Add("ChangeRatio", "换算率");
                dataFieldNameDic.Add("NumOriginalPlanAssist", "辅数量");
                dataFieldNameDic.Add("NumOriginalPlan", "数量");
                dataFieldNameDic.Add("Lot", "批次号");
                dataFieldNameDic.Add("ProductDate", "生产日期");
                dataFieldNameDic.Add("OutWHName", "调出仓库");
                dataFieldNameDic.Add("InWHName", "调入仓库");
                dataFieldNameDic.Add("OutWHNameAssist", "出货仓库");
                dataFieldNameDic.Add("OutDept", "调出部门");
                dataFieldNameDic.Add("OutOperator", "调出部门业务员");
                dataFieldNameDic.Add("InDept", "调入部门");
                dataFieldNameDic.Add("InOperator", "调入部门业务员");
                dataFieldNameDic.Add("OutDeptAssist", "出货部门");
                dataFieldNameDic.Add("OutOperatorAssist", "出货部门业务员姓名");
                dataFieldNameDic.Add("OutArea", "调出货位");
                dataFieldNameDic.Add("InArea", "调入货位");
                dataFieldNameDic.Add("OutAreaAssist", "出货货位");

                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <TransferOrderDetail>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <TransferOrderDetail>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    TransferOrderDetail newModel = new TransferOrderDetail();

                    newModel.NCOrderCode     = DataCheckHelper.GetCellString(dr["NCOrderCode"]);
                    newModel.DetailRowNumber = DataCheckHelper.GetCellString(dr["DetailRowNumber"]);

                    newModel.CargoCode = DataCheckHelper.GetCellString(dr["CargoCode"]);
                    string cargoCode = DbCommonMethod.ParsingCargoCode(newModel.CargoCode);
                    if (string.IsNullOrEmpty(cargoCode))
                    {
                        throw new ApplicationException("单号" + newModel.NCOrderCode + ",商品不存在:" + newModel.CargoCode);
                    }

                    newModel.CargoName  = DataCheckHelper.GetCellString(dr["CargoName"]);
                    newModel.CargoSpec  = DataCheckHelper.GetCellString(dr["CargoSpec"]);
                    newModel.CargoModel = DataCheckHelper.GetCellString(dr["CargoModel"]);
                    newModel.CargoUnits = DataCheckHelper.GetCellString(dr["CargoUnits"]);
                    //newModel = DataCheckHelper.GetCellString(dr["CargoUnitsAssist"]);
                    //newModel = DataCheckHelper.GetCellString(dr["ChangeRatio"]);
                    //newModel = DataCheckHelper.GetCellString(dr["NumOriginalPlanAssist"]);

                    //数量
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["NumOriginalPlan"])))
                    {
                        double d;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["NumOriginalPlan"]), out d))
                        {
                            newModel.NumOriginalPlan = d;
                        }
                    }

                    //newModel = DataCheckHelper.GetCellString(dr["Lot"]);
                    //newModel = DataCheckHelper.GetCellString(dr["ProductDate"]);

                    newModel.OutWHName = DataCheckHelper.GetCellString(dr["OutWHName"]);
                    if (newModel.OutWHName != "")
                    {
                        newModel.OutWHCode = DbCommonMethod.ParsingWarehouse(newModel.OutWHName);
                        throw new ApplicationException("单号" + newModel.NCOrderCode + ",仓库不存在:" + newModel.OutWHName);
                    }

                    newModel.InWHName = DataCheckHelper.GetCellString(dr["InWHName"]);
                    if (newModel.InWHName != "")
                    {
                        newModel.InWHCode = DbCommonMethod.ParsingWarehouse(newModel.InWHName);
                        throw new ApplicationException("单号" + newModel.NCOrderCode + ",仓库不存在:" + newModel.InWHName);
                    }

                    //newModel = DataCheckHelper.GetCellString(dr["OutWHNameAssist"]);
                    //newModel = DataCheckHelper.GetCellString(dr["OutDept"]);
                    //newModel = DataCheckHelper.GetCellString(dr["OutOperator"]);
                    //newModel = DataCheckHelper.GetCellString(dr["InDept"]);
                    //newModel = DataCheckHelper.GetCellString(dr["InOperator"]);
                    //newModel = DataCheckHelper.GetCellString(dr["OutDeptAssist"]);
                    //newModel = DataCheckHelper.GetCellString(dr["OutOperatorAssist"]);
                    //newModel = DataCheckHelper.GetCellString(dr["OutArea"]);
                    //newModel = DataCheckHelper.GetCellString(dr["InArea"]);
                    //newModel = DataCheckHelper.GetCellString(dr["OutAreaAssist"]);

                    newModel.DetailRowStatus = 2;//初始态
                    newModel.OrderCode       = newModel.OrderCode;
                    newModel.NCOrderCode     = newModel.NCOrderCode;

                    List <TransferOrderDetail> existTransferOrderDetail = (from r in list where r.NCOrderCode == newModel.NCOrderCode && r.DetailRowNumber == newModel.DetailRowNumber select r).ToList <TransferOrderDetail>();
                    if (existTransferOrderDetail == null || existTransferOrderDetail.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <TransferOrderDetail>());;
            }
        }
예제 #9
0
        /// <summary>
        /// 从DataTable中获取采购订单明细实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.PurchaseOrderDetail> GetModelDetailFromDataTable(DataTable dt, out string msg)
        {
            try
            {
                List <DAL.PurchaseOrderDetail> list = new List <DAL.PurchaseOrderDetail>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();
                dataFieldNameDic.Add("NCOrderCode", "NC系统订单号");
                dataFieldNameDic.Add("DetailRowNumber", "行号");
                dataFieldNameDic.Add("ContractNo", "合同号");
                dataFieldNameDic.Add("CargoCode", "商品编码");
                dataFieldNameDic.Add("CargoName", "商品名称");
                dataFieldNameDic.Add("CargoModel", "商品型号");
                dataFieldNameDic.Add("CargoSpec", "商品规格");
                dataFieldNameDic.Add("WHName", "收货仓库");
                dataFieldNameDic.Add("CargoUnits", "商品单位");
                dataFieldNameDic.Add("PlanNumber", "应收数量");
                dataFieldNameDic.Add("PriceOfTax", "含税单价");
                dataFieldNameDic.Add("Price", "单价");
                dataFieldNameDic.Add("DeductRate", "折扣");
                dataFieldNameDic.Add("PriceOfNetTax", "净含税单价");
                dataFieldNameDic.Add("NetPrice", "净单价");
                dataFieldNameDic.Add("TotalPrice", "金额");
                dataFieldNameDic.Add("TaxRate", "税率");
                dataFieldNameDic.Add("TotalTax", "税额");
                dataFieldNameDic.Add("TotalTaxAndPrice", "价税合计");
                dataFieldNameDic.Add("PlanArrivalDate", "计划到货日期");
                dataFieldNameDic.Add("CurrencyType", "币种");
                dataFieldNameDic.Add("ExchangeRate", "汇率");
                dataFieldNameDic.Add("ReceiveCompany", "收货公司");
                dataFieldNameDic.Add("ReceiveOrg", "收货库存组织");
                dataFieldNameDic.Add("ReceiveBillCompany", "收票公司");

                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <PurchaseOrderDetail>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <PurchaseOrderDetail>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    PurchaseOrderDetail newModel = new PurchaseOrderDetail();

                    newModel.NCOrderCode     = DataCheckHelper.GetCellString(dr["NCOrderCode"]);
                    newModel.DetailRowNumber = DataCheckHelper.GetCellString(dr["DetailRowNumber"]);
                    newModel.ContractNo      = DataCheckHelper.GetCellString(dr["ContractNo"]);

                    //商品编码
                    newModel.CargoCode = DataCheckHelper.GetCellString(dr["CargoCode"]);
                    string cargoCode = DbCommonMethod.ParsingCargoCode(newModel.CargoCode);
                    if (string.IsNullOrEmpty(cargoCode))
                    {
                        throw new ApplicationException("单号" + newModel.NCOrderCode + ",商品不存在:" + newModel.CargoCode);
                    }

                    newModel.CargoName  = DataCheckHelper.GetCellString(dr["CargoName"]);
                    newModel.CargoModel = DataCheckHelper.GetCellString(dr["CargoModel"]);
                    newModel.CargoSpec  = DataCheckHelper.GetCellString(dr["CargoSpec"]);

                    //仓库
                    newModel.WHName = DataCheckHelper.GetCellString(dr["WHName"]);
                    if (newModel.WHName != "")
                    {
                        newModel.WHCode = DbCommonMethod.ParsingWarehouse(newModel.WHName);
                        if (string.IsNullOrEmpty(newModel.WHCode))
                        {
                            throw new ApplicationException("单号" + newModel.NCOrderCode + ",仓库不存在:" + newModel.WHName);
                        }
                    }

                    newModel.CargoUnits = DataCheckHelper.GetCellString(dr["CargoUnits"]);

                    //数量
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PlanNumber"])))
                    {
                        Double number;
                        if (Double.TryParse(DataCheckHelper.GetCellString(dr["PlanNumber"]), out number))
                        {
                            newModel.NumOriginalPlan = number;
                        }
                    }

                    //含税单价
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PriceOfTax"])))
                    {
                        decimal priceOfTax;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["PriceOfTax"]), out priceOfTax))
                        {
                            newModel.PriceOfTax = priceOfTax;
                        }
                    }

                    //单价
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["Price"])))
                    {
                        decimal price;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["Price"]), out price))
                        {
                            newModel.Price = price;
                        }
                    }

                    //折扣率
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["DeductRate"])))
                    {
                        double deductRate;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["DeductRate"]), out deductRate))
                        {
                            newModel.DeductRate = deductRate;
                        }
                    }

                    //净含税单价
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PriceOfNetTax"])))
                    {
                        decimal priceOfNetTax;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["PriceOfNetTax"]), out priceOfNetTax))
                        {
                            newModel.PriceOfNetTax = priceOfNetTax;
                        }
                    }

                    //净单价
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["NetPrice"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["NetPrice"]), out d))
                        {
                            newModel.NetPrice = d;
                        }
                    }

                    //金额
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalPrice"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["TotalPrice"]), out d))
                        {
                            newModel.TotalPrice = d;
                        }
                    }

                    //税率
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TaxRate"])))
                    {
                        double d;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["TaxRate"]), out d))
                        {
                            newModel.TaxRate = d;
                        }
                    }

                    //税额
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalTax"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["TotalTax"]), out d))
                        {
                            newModel.TotalTax = d;
                        }
                    }

                    //价税合计
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalTaxAndPrice"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["TotalTaxAndPrice"]), out d))
                        {
                            newModel.TotalTaxAndPrice = d;
                        }
                    }

                    //计划到货日期
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["PlanArrivalDate"])))
                    {
                        DateTime d;
                        if (DateTime.TryParse(DataCheckHelper.GetCellString(dr["PlanArrivalDate"]), out d))
                        {
                            newModel.PlanArrivalDate = d;
                        }
                    }

                    newModel.CurrencyType = DataCheckHelper.GetCellString(dr["CurrencyType"]);

                    //折本汇率
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["ExchangeRate"])))
                    {
                        double d;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["ExchangeRate"]), out d))
                        {
                            newModel.ExchangeRate = d;
                        }
                    }

                    newModel.ReceiveCompany     = DataCheckHelper.GetCellString(dr["ReceiveCompany"]);
                    newModel.ReceiveOrg         = DataCheckHelper.GetCellString(dr["ReceiveOrg"]);
                    newModel.ReceiveBillCompany = DataCheckHelper.GetCellString(dr["ReceiveBillCompany"]);

                    newModel.DetailRowStatus = 2;//初始态
                    newModel.OrderCode       = newModel.OrderCode;
                    newModel.NCOrderCode     = newModel.NCOrderCode;

                    List <PurchaseOrderDetail> existPurchaseOrderDetail = (from r in list where r.NCOrderCode == newModel.NCOrderCode && r.DetailRowNumber == newModel.DetailRowNumber select r).ToList <PurchaseOrderDetail>();
                    if (existPurchaseOrderDetail == null || existPurchaseOrderDetail.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <PurchaseOrderDetail>());;
            }
        }
예제 #10
0
        protected override void BindingOrderItem(object[] array)
        {
            if (_order.StockDetail == null)
            {
                _order.StockDetail = new EntityCollection <StockDetail>();
            }

            if (_itemDefine == null)
            {
                throw new ApplicationException("未发现行项目字段定义!");
            }

            if (_itemDefine.Count() == array.Count())
            {
                StockDetail orderItem = new StockDetail();
                for (int i = 0; i < array.Count(); i++)
                {
                    string fieldName  = Regex.Replace(_itemDefine[i].ToString(), @"\s", "");
                    string fieldValue = Regex.Replace(array[i].ToString(), @"\s", "");

                    switch (fieldName)
                    {
                    case "存货编码":
                        orderItem.CargoCode = fieldValue;
                        string cargoCode = DbCommonMethod.ParsingCargoCode(fieldValue);
                        if (string.IsNullOrEmpty(cargoCode))
                        {
                            throw new ApplicationException("商品不存在:" + fieldValue);
                        }
                        break;

                    case "商品名称":
                        orderItem.CargoName = fieldValue;
                        break;

                    case "规格":
                        orderItem.CargoSpec = fieldValue;
                        break;

                    case "型号":
                        //过滤型号值,如果型号是90.000,则去90,去掉小数点后面的0
                        double dou;
                        string strModel = fieldValue;
                        double douModel = 0;
                        if (double.TryParse(fieldValue, out dou))
                        {
                            douModel = dou;
                        }

                        if (douModel != 0 && strModel.Contains("."))
                        {
                            string sdecimal = strModel.Substring(strModel.IndexOf(".") + 1, strModel.Length - strModel.IndexOf(".") - 1);
                            int    istring  = Convert.ToInt32(sdecimal);
                            if (istring == 0)
                            {
                                strModel = fieldValue.Substring(0, fieldValue.IndexOf("."));
                            }
                        }
                        orderItem.CargoModel = strModel;
                        break;

                    case "单位":
                        orderItem.CargoUnits = fieldValue;
                        break;

                    case "数量":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                orderItem.NumOriginalPlan = d;
                            }
                        }
                        break;

                    //暂留空,因为没看到有字段保存单价信息的(因为系统只管商品,不管金额,所以暂时不用存单价)
                    //case "销售单价":
                    //    if (!string.IsNullOrEmpty(fieldValue))
                    //    {
                    //        decimal d;
                    //        if (decimal.TryParse(fieldValue, out d))
                    //            orderItem.Price = d;
                    //    }
                    //    break;

                    case "销售金额":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            decimal de;
                            if (decimal.TryParse(fieldValue, out de))
                            {
                                orderItem.RowTotalMoney = de;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                if (string.IsNullOrEmpty(orderItem.BillRowNumber))
                {
                    orderItem.BillRowNumber = _rowNum.ToString();
                }

                orderItem.NumCurrentPlan = orderItem.NumOriginalPlan; //订单数量=应收数量,默认值
                orderItem.CargoStatus    = 0;                         //手持机未完成
                orderItem.BillCode       = _order.SOCode;
                orderItem.SOCode         = _order.SOCode;
                orderItem.BillType       = CommonConvert.GetBillTypeCode("出库单");
                orderItem.InOutWHCode    = _order.WHCode;
                orderItem.StockOut       = _order;
                IEnumerable <KeyValuePair <string, object> > entityKeyValues =
                    new KeyValuePair <string, object>[] {
                    new KeyValuePair <string, object>("BillCode", orderItem.BillCode),
                    new KeyValuePair <string, object>("BillRowNumber", orderItem.BillRowNumber)
                };
                orderItem.EntityKey = new EntityKey("GoldEntities.StockDetail", entityKeyValues);
                _order.StockDetail.Add(orderItem);
            }
        }
예제 #11
0
        //抬头
        protected override void BindingOrderHeader(string fieldName, string fieldValue)
        {
            switch (fieldName)
            {
            case "单据号":
                _order.OrderCode   = fieldValue;
                _order.NCOrderCode = fieldValue;
                break;

            //单据类型,因数据库缺少字段
            case "单据日期":
                if (!string.IsNullOrEmpty(fieldValue))
                {
                    DateTime dt;
                    if (DateTime.TryParse(fieldValue, out dt))
                    {
                        _order.OrderDate = dt;
                    }
                }
                break;

            //case "单据状态":
            //    _order.OrderStatus = fieldValue == "关闭" ? 0 : 1;
            //    break;
            case "调入仓库":
                _order.InWHName = fieldValue;
                _order.InWHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                if (string.IsNullOrEmpty(_order.InWHCode))
                {
                    throw new ApplicationException("仓库不存在:" + fieldValue);
                }
                break;

            case "调入组织":
                _order.InOrganization = fieldValue;
                break;

            case "调入公司":
                _order.InCompany = fieldValue;
                break;

            //case "是否退回":
            case "调出组织":
                _order.OutOrganization = fieldValue;
                break;

            case "调出公司":
                _order.OutCompany = fieldValue;
                break;

            case "调出仓库":
                _order.OutWHName = fieldValue;
                _order.OutWHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                if (string.IsNullOrEmpty(_order.OutWHCode))
                {
                    throw new ApplicationException("仓库不存在:" + fieldValue);
                }
                break;

            //case"出货仓库":
            //case "出货组织":
            //case "出货公司":
            //case "调拨类型":
            //case "币种":
            //case "调入调出在途归属":
            //case "调出出货在途归属":
            //case "H-UDC1":
            //case "H-UDC2":
            //case "H-UDC3":
            //case "H-UDC4":
            //case "H-UDC5":
            //case "H-UDC6":
            //case "H-UDC7":
            //case "H-UDC8":
            //case "H-UDC9":
            //case "H-UDC10":
            //case "H-UDC11":
            //case "H-UDC12":
            //case "H-UDC13":
            //case "H-UDC14":
            //case "H-UDC15":
            //case "H-UDC16":
            //case "H-UDC17":
            //case "H-UDC18":
            //case "H-UDC19":
            //case "H-UDC20":
            case "备注":
                _order.Comment = fieldValue;
                break;

            //case "制单人":
            //case "制单时间":
            //case "审批人":
            //case "审批日期":
            //case "审核时间":
            //case "打印次数":
            //case "最后修改人":
            case "最后修改时间":
                if (!string.IsNullOrEmpty(fieldValue))
                {
                    DateTime dt;
                    if (DateTime.TryParse(fieldValue, out dt))
                    {
                        _order.LastModifyTime = dt;
                    }
                }
                break;

            default:
                break;
            }
        }
예제 #12
0
        //行项目
        protected override void BindingOrderItem(object[] array)
        {
            if (_order.TransferOrderDetail == null)
            {
                _order.TransferOrderDetail = new EntityCollection <TransferOrderDetail>();
            }

            if (_itemDefine == null)
            {
                throw new ApplicationException("未发现行项目字段定义!");
            }

            if (_itemDefine.Count() == array.Count())
            {
                TransferOrderDetail orderItem = new TransferOrderDetail();
                for (int i = 0; i < array.Count(); i++)
                {
                    string fieldName  = Regex.Replace(_itemDefine[i].ToString(), @"\s", "");
                    string fieldValue = Regex.Replace(array[i].ToString(), @"\s", "");

                    switch (fieldName)
                    {
                    case "行号":
                        if (fieldValue.Contains("."))    //如果行号是10.000,则取10,去掉小数点后面的0
                        {
                            orderItem.DetailRowNumber = fieldValue.Substring(0, fieldValue.IndexOf("."));
                        }
                        else
                        {
                            orderItem.DetailRowNumber = fieldValue;
                        }
                        break;

                    case "存货编码":
                        orderItem.CargoCode = fieldValue;
                        string cargoCode = DbCommonMethod.ParsingCargoCode(fieldValue);
                        if (string.IsNullOrEmpty(cargoCode))
                        {
                            throw new ApplicationException("商品不存在:" + fieldValue);
                        }
                        break;

                    case "存货名称":
                        orderItem.CargoName = fieldValue;
                        break;

                    //case "产地":
                    //    break;
                    case "规格":
                        orderItem.CargoSpec = fieldValue;
                        break;

                    case "型号":
                        //过滤型号值,如果型号是90.000,则去90,去掉小数点后面的0
                        double dou;
                        string strModel = fieldValue;
                        double douModel = 0;
                        if (double.TryParse(fieldValue, out dou))
                        {
                            douModel = dou;
                        }

                        if (douModel != 0 && strModel.Contains("."))
                        {
                            string sdecimal = strModel.Substring(strModel.IndexOf(".") + 1, strModel.Length - strModel.IndexOf(".") - 1);
                            int    istring  = Convert.ToInt32(sdecimal);
                            if (istring == 0)
                            {
                                strModel = fieldValue.Substring(0, fieldValue.IndexOf("."));
                            }
                        }
                        orderItem.CargoModel = strModel;
                        break;

                    case "主计量单位":
                        orderItem.CargoUnits = fieldValue;
                        break;

                    //case "辅单位":
                    //    break;
                    //case "换算率":
                    //    break;
                    //case "辅数量":
                    //    break;
                    case "数量":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                orderItem.NumOriginalPlan = d;
                            }
                        }
                        break;

                    //case "自由项":
                    //    break;
                    //case "批次号":
                    //    break;
                    case "生产日期":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            DateTime dt;
                            if (DateTime.TryParse(fieldValue, out dt))
                            {
                                orderItem.ReleaseYear = dt.Year.ToString();
                            }
                        }

                        break;

                    //case "失效日期":
                    //    break;
                    //case "是否赠品":
                    //    break;
                    case "调出仓库":
                        orderItem.InWHName = fieldValue;
                        orderItem.InWHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                        break;

                    case "调入仓库":
                        orderItem.OutWHName = fieldValue;
                        orderItem.OutWHCode = DbCommonMethod.ParsingWarehouse(fieldValue);
                        break;

                    //case "出货仓库":
                    //    break;
                    //case "调出部门":
                    //    break;
                    //case "业务员":
                    //    break;
                    //case "调入部门":
                    //    break;
                    //case "业务员":
                    //    break;
                    //case "出货部门":
                    //    break;
                    //case "业务员":
                    //    break;
                    //case "调出货位":
                    //    break;
                    //case "调入货位":
                    //    break;
                    //case "出货货位":
                    //    break;
                    //case "计划发货日":
                    //    break;
                    //case "计划到货日":
                    //    break;
                    //case "收货客户":
                    //    break;
                    //case "收货地区":
                    //    break;
                    //case "收货地址":
                    //    break;
                    //case "收货地点":
                    //    break;
                    //case "项目":
                    //    break;
                    //case "项目阶段":
                    //    break;
                    //case "发运方式":
                    //    break;
                    //case "非含税单价":
                    //    break;
                    //case "税率":
                    //    break;
                    //case "非含税金额":
                    //    break;
                    //case "含税金额":
                    //    break;
                    //case "询价含税价":
                    //    break;
                    //case "含税单价":
                    //    break;
                    //case "加价率":
                    //    break;
                    //case "询价非含税价":
                    //    break;
                    //case "已调出主数量":
                    //    break;
                    //case "已调出辅数量":
                    //    break;
                    //case "已调入主数量":
                    //    break;
                    //case "已调入辅数量":
                    //    break;
                    //case "调拨在途主数量":
                    //    break;
                    //case "调拨在途辅数量":
                    //    break;
                    //case "已发货主数量":
                    //    break;
                    //case "已发货辅数量":
                    //    break;
                    //case "签收主数量":
                    //    break;
                    //case "签收辅数量":
                    //    break;
                    //case "调出与调入已结算数量":
                    //    break;
                    //case "调出与出货方已经结算数量":
                    //    break;
                    //case "调出与出货方已经结算金额":
                    //    break;
                    //case "发运退回主数量":
                    //    break;
                    //case "发运退回辅数量":
                    //    break;
                    //case "发运途损主数量":
                    //    break;
                    //case "发运途损辅数量":
                    //    break;
                    //case "累计退回数量":
                    //    break;
                    //case "应发未出库数量":
                    //    break;
                    //case "来源单据类型":
                    //    break;
                    //case "来源单据号":
                    //    break;
                    //case "来源单据行号":
                    //    break;
                    //case "B-UDC1":
                    //    break;
                    //case "B-UDC2":
                    //    break;
                    //case "B-UDC3":
                    //    break;
                    //case "B-UDC4":
                    //    break;
                    //case "B-UDC5":
                    //    break;
                    //case "B-UDC6":
                    //    break;
                    //case "B-UDC7":
                    //    break;
                    //case "B-UDC8":
                    //    break;
                    //case "B-UDC9":
                    //    break;
                    //case "B-UDC10":
                    //    break;
                    //case "B-UDC11":
                    //    break;
                    //case "B-UDC12":
                    //    break;
                    //case "B-UDC13":
                    //    break;
                    //case "B-UDC14":
                    //    break;
                    //case "B-UDC15":
                    //    break;
                    //case "B-UDC16":
                    //    break;
                    //case "B-UDC17":
                    //    break;
                    //case "B-UDC18":
                    //    break;
                    //case "B-UDC19":
                    //    break;
                    //case "B-UDC20":
                    //    break;
                    //case "报价计量单位":
                    //    break;
                    //case "报价计量单位数量":
                    //    break;
                    //case "报价计量单位换算率":
                    //    break;
                    //case "报价计量单位原币含税净价":
                    //    break;
                    //case "报价计量单位原币无税净价":
                    default:
                        break;
                    }
                }

                orderItem.DetailRowStatus = 2;//初始态
                orderItem.OrderCode       = _order.OrderCode;
                orderItem.NCOrderCode     = _order.NCOrderCode;
                orderItem.TransferOrder   = _order;

                IEnumerable <KeyValuePair <string, object> > entityKeyValues =
                    new KeyValuePair <string, object>[] {
                    new KeyValuePair <string, object>("OrderCode", orderItem.OrderCode),
                    new KeyValuePair <string, object>("DetailRowNumber", orderItem.DetailRowNumber)
                };
                orderItem.EntityKey = new EntityKey("GoldEntities.TransferOrderDetail", entityKeyValues);
                _order.TransferOrderDetail.Add(orderItem);
            }
        }
예제 #13
0
        /// <summary>
        /// 从DataTable中获取实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.StockOut> GetModelFromDataTable(DataTable dt, out string msg)
        {
            try
            {
                List <DAL.StockOut> list = new List <DAL.StockOut>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();
                dataFieldNameDic.Add("BillCode", "其他出库单号");
                dataFieldNameDic.Add("BillDate", "日期");
                dataFieldNameDic.Add("OutCategory", "收发类别");
                dataFieldNameDic.Add("OutWHName", "发出仓库");
                dataFieldNameDic.Add("Comment", "备注");
                dataFieldNameDic.Add("TotalNumber", "合计数量");
                dataFieldNameDic.Add("LeaderSign", "领导");
                dataFieldNameDic.Add("WareHouseKeeper", "仓管");
                dataFieldNameDic.Add("AccountSign", "财务");
                dataFieldNameDic.Add("BusinessSign", "经办人");
                dataFieldNameDic.Add("EditorSign", "制单人");

                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <StockOut>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <StockOut>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    StockOut newModel = new StockOut();
                    //newModel.SOCode = KeyGenerator.Instance.GetStockOutKey();
                    newModel.FromBillNo = DataCheckHelper.GetCellString(dr["BillCode"]);

                    //日期
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["BillDate"])))
                    {
                        DateTime d;
                        if (DateTime.TryParse(DataCheckHelper.GetCellString(dr["BillDate"]), out d))
                        {
                            newModel.SODate = d;
                        }
                    }

                    //收发类别
                    newModel.OutCategory = DbCommonMethod.GetOutCategory(DataCheckHelper.GetCellString(dr["OutCategory"]));

                    newModel.WHName = DataCheckHelper.GetCellString(dr["OutWHName"]);
                    newModel.WHCode = DbCommonMethod.ParsingWarehouse(newModel.WHName);
                    if (string.IsNullOrEmpty(newModel.WHCode))
                    {
                        throw new ApplicationException("单号" + newModel.FromBillNo + ",仓库不存在:" + newModel.WHName);
                    }

                    newModel.Comment = DataCheckHelper.GetCellString(dr["Comment"]);

                    //合计数量
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalNumber"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["TotalNumber"]), out d))
                        {
                            newModel.TotalMoney = d;
                        }
                    }

                    newModel.LeaderSign    = DataCheckHelper.GetCellString(dr["LeaderSign"]);
                    newModel.WarehouseSign = DataCheckHelper.GetCellString(dr["WareHouseKeeper"]);
                    newModel.AccountSign   = DataCheckHelper.GetCellString(dr["AccountSign"]);
                    newModel.BusinessSign  = DataCheckHelper.GetCellString(dr["BusinessSign"]);
                    newModel.EditorSign    = DataCheckHelper.GetCellString(dr["EditorSign"]);

                    newModel.SOStatus     = 1;    //已保存
                    newModel.FromBillType = "13"; //11-销售出库单、12-调拨出库单、13-其他出库单
                    newModel.EditStatus   = 0;    //无人编辑
                    newModel.SOType       = CommonConvert.GetSIOTypeCode("其他出库单");
                    newModel.FromType     = CommonConvert.GetFromTypeCode("源于Excel导入的出库单");

                    List <StockOut> existStockOut = (from r in list where r.FromBillNo == newModel.FromBillNo select r).ToList <StockOut>();
                    if (existStockOut == null || existStockOut.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <StockOut>());;
            }
        }
예제 #14
0
        /// <summary>
        /// 从DataTable中获取实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.ShiftOrder> GetModelFromDataTable(DataTable dt, out string msg)
        {
            try
            {
                List <DAL.ShiftOrder> list = new List <DAL.ShiftOrder>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();

                dataFieldNameDic.Add("NCOrderCode", "转库单编号");
                dataFieldNameDic.Add("Comment", "转库单摘要");
                dataFieldNameDic.Add("OrderDate", "转库单日期");
                dataFieldNameDic.Add("OutWHName", "调出仓库名称");
                dataFieldNameDic.Add("InWHName", "调入仓库名称");
                dataFieldNameDic.Add("TotalNumber", "合计数量");
                dataFieldNameDic.Add("LeaderName", "领导");
                dataFieldNameDic.Add("SenderName", "发货人");
                dataFieldNameDic.Add("ReceiverName", "收货人");
                dataFieldNameDic.Add("BusinessManager", "业务经理");


                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <ShiftOrder>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <ShiftOrder>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    ShiftOrder newModel = new ShiftOrder();
                    newModel.NCOrderCode = DataCheckHelper.GetCellString(dr["NCOrderCode"]);
                    newModel.Comment     = DataCheckHelper.GetCellString(dr["Comment"]);

                    //日期
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["OrderDate"])))
                    {
                        DateTime d;
                        if (DateTime.TryParse(DataCheckHelper.GetCellString(dr["OrderDate"]), out d))
                        {
                            newModel.OrderDate = d;
                        }
                    }

                    newModel.OutWHName = DataCheckHelper.GetCellString(dr["OutWHName"]);
                    if (newModel.OutWHName != "")
                    {
                        newModel.OutWHCode = DbCommonMethod.ParsingWarehouse(newModel.OutWHName);
                        if (string.IsNullOrEmpty(newModel.OutWHCode))
                        {
                            throw new ApplicationException("单号" + newModel.NCOrderCode + ",调出仓库不存在:" + newModel.OutWHName);
                        }
                    }

                    newModel.InWHName = DataCheckHelper.GetCellString(dr["InWHName"]);
                    if (newModel.InWHName != "")
                    {
                        newModel.InWHCode = DbCommonMethod.ParsingWarehouse(newModel.InWHName);
                        if (string.IsNullOrEmpty(newModel.InWHCode))
                        {
                            throw new ApplicationException("单号" + newModel.NCOrderCode + ",调入仓库不存在:" + newModel.InWHName);
                        }
                    }

                    //数量
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["TotalNumber"])))
                    {
                        double d;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["TotalNumber"]), out d))
                        {
                            newModel.TotalNumber = d;
                        }
                    }

                    newModel.LeaderName      = DataCheckHelper.GetCellString(dr["LeaderName"]);
                    newModel.SenderName      = DataCheckHelper.GetCellString(dr["SenderName"]);
                    newModel.ReceiverName    = DataCheckHelper.GetCellString(dr["ReceiverName"]);
                    newModel.BusinessManager = DataCheckHelper.GetCellString(dr["BusinessManager"]);


                    newModel.OrderStatus = 2; //初始态
                    newModel.EditStatus  = 0; //无人编辑
                    newModel.OrderCode   = newModel.NCOrderCode;

                    List <ShiftOrder> existShiftOrder = (from r in list where r.NCOrderCode == newModel.NCOrderCode select r).ToList <ShiftOrder>();
                    if (existShiftOrder == null || existShiftOrder.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <ShiftOrder>());;
            }
        }
예제 #15
0
        protected override void BindingOrderItem(object[] array)
        {
            if (_order.ShiftOrderDetail == null)
            {
                _order.ShiftOrderDetail = new EntityCollection <ShiftOrderDetail>();
            }

            if (_itemDefine == null)
            {
                throw new ApplicationException("未发现行项目字段定义!");
            }

            if (_itemDefine.Count() == array.Count())
            {
                ShiftOrderDetail orderItem = new ShiftOrderDetail();
                for (int i = 0; i < array.Count(); i++)
                {
                    string fieldName  = Regex.Replace(_itemDefine[i].ToString(), @"\s", "");
                    string fieldValue = Regex.Replace(array[i].ToString(), @"\s", "");

                    switch (fieldName)
                    {
                    case "商品编码":
                        orderItem.CargoCode = fieldValue;
                        string cargoCode = DbCommonMethod.ParsingCargoCode(fieldValue);
                        if (string.IsNullOrEmpty(cargoCode))
                        {
                            throw new ApplicationException("商品不存在:" + fieldValue);
                        }
                        break;

                    case "商品名称":
                        orderItem.CargoName = fieldValue;
                        break;

                    case "规格":
                        orderItem.CargoSpec = fieldValue;
                        break;

                    case "型号":
                        //过滤型号值,如果型号是90.000,则去90,去掉小数点后面的0
                        double dou;
                        string strModel = fieldValue;
                        double douModel = 0;
                        if (double.TryParse(fieldValue, out dou))
                        {
                            douModel = dou;
                        }

                        if (douModel != 0 && strModel.Contains("."))
                        {
                            string sdecimal = strModel.Substring(strModel.IndexOf(".") + 1, strModel.Length - strModel.IndexOf(".") - 1);
                            int    istring  = Convert.ToInt32(sdecimal);
                            if (istring == 0)
                            {
                                strModel = fieldValue.Substring(0, fieldValue.IndexOf("."));
                            }
                        }
                        orderItem.CargoModel = strModel;
                        break;

                    case "单位":
                        orderItem.CargoUnits = fieldValue;
                        break;

                    case "数量":
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            double d;
                            if (double.TryParse(fieldValue, out d))
                            {
                                orderItem.NumOriginalPlan = d;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                if (string.IsNullOrEmpty(orderItem.DetailRowNumber))
                {
                    orderItem.DetailRowNumber = _rowNum.ToString();
                }

                orderItem.DetailRowStatus = 2;//初始态
                orderItem.OrderCode       = _order.OrderCode;
                orderItem.NCOrderCode     = _order.NCOrderCode;
                orderItem.ShiftOrder      = _order;
                IEnumerable <KeyValuePair <string, object> > entityKeyValues =
                    new KeyValuePair <string, object>[] {
                    new KeyValuePair <string, object>("OrderCode", orderItem.OrderCode),
                    new KeyValuePair <string, object>("DetailRowNumber", orderItem.DetailRowNumber)
                };
                orderItem.EntityKey = new EntityKey("GoldEntities.ShiftOrderDetail", entityKeyValues);
                _order.ShiftOrderDetail.Add(orderItem);
            }
        }
예제 #16
0
        /// <summary>
        /// 从DataTable中获取销售订单明细实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.SalesOrderDetail> GetModelDetailFromDataTable(DataTable dt, out string msg)
        {
            try
            {
                List <DAL.SalesOrderDetail> list = new List <DAL.SalesOrderDetail>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();
                dataFieldNameDic.Add("NCOrderCode", "订单编号 ");
                dataFieldNameDic.Add("DetailRowNumber", "行号");
                dataFieldNameDic.Add("CargoCode", "商品编码");
                dataFieldNameDic.Add("CargoName", "商品名称");
                dataFieldNameDic.Add("CargoModel", "规格 ");
                dataFieldNameDic.Add("CargoSpec", "型号");
                dataFieldNameDic.Add("CargoUnits", "单位");
                dataFieldNameDic.Add("NumOriginalPlan", "数量");
                dataFieldNameDic.Add("Price", "单价");
                dataFieldNameDic.Add("Money", "金额");
                dataFieldNameDic.Add("DiscountMoney", "折扣金额");
                dataFieldNameDic.Add("WHName", "发出仓库 ");

                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <SalesOrderDetail>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <SalesOrderDetail>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    SalesOrderDetail newModel = new SalesOrderDetail();

                    newModel.NCOrderCode     = DataCheckHelper.GetCellString(dr["NCOrderCode"]);
                    newModel.DetailRowNumber = DataCheckHelper.GetCellString(dr["DetailRowNumber"]);

                    newModel.CargoCode = DataCheckHelper.GetCellString(dr["CargoCode"]);
                    string cargoCode = DbCommonMethod.ParsingCargoCode(newModel.CargoCode);
                    if (string.IsNullOrEmpty(cargoCode))
                    {
                        throw new ApplicationException("单号" + newModel.NCOrderCode + ",商品不存在:" + newModel.CargoCode);
                    }

                    newModel.CargoName  = DataCheckHelper.GetCellString(dr["CargoName"]);
                    newModel.CargoModel = DataCheckHelper.GetCellString(dr["CargoModel"]);
                    newModel.CargoSpec  = DataCheckHelper.GetCellString(dr["CargoSpec"]);
                    newModel.CargoUnits = DataCheckHelper.GetCellString(dr["CargoUnits"]);

                    //数量
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["NumOriginalPlan"])))
                    {
                        double d;
                        if (double.TryParse(DataCheckHelper.GetCellString(dr["NumOriginalPlan"]), out d))
                        {
                            newModel.NumOriginalPlan = d;
                        }
                    }

                    //单价
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["Price"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["Price"]), out d))
                        {
                            newModel.Price = d;
                        }
                    }

                    //金额
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["Money"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["Money"]), out d))
                        {
                            newModel.TotalMoney = d;
                        }
                    }

                    //折后金额
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["DiscountMoney"])))
                    {
                        decimal d;
                        if (decimal.TryParse(DataCheckHelper.GetCellString(dr["DiscountMoney"]), out d))
                        {
                            newModel.DiscountMoney = d;
                        }
                    }

                    newModel.WHName = DataCheckHelper.GetCellString(dr["WHName"]);
                    if (newModel.WHName != "")
                    {
                        newModel.WHCode = DbCommonMethod.ParsingWarehouse(newModel.WHName);
                        if (newModel.WHCode == "")
                        {
                            throw new ApplicationException("单号" + newModel.NCOrderCode + ",仓库不存在:" + newModel.WHName);
                        }
                    }

                    newModel.DetailRowStatus = 2;//初始态
                    newModel.OrderCode       = newModel.OrderCode;
                    newModel.NCOrderCode     = newModel.NCOrderCode;

                    List <SalesOrderDetail> existSalesOrderDetail = (from r in list where r.NCOrderCode == newModel.NCOrderCode && r.DetailRowNumber == newModel.DetailRowNumber select r).ToList <SalesOrderDetail>();
                    if (existSalesOrderDetail == null || existSalesOrderDetail.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <SalesOrderDetail>());;
            }
        }
예제 #17
0
        /// <summary>
        /// 从DataTable中获取实体列表
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private List <DAL.TransferOrder> GetModelFromDataTable(DataTable dt, out string msg)
        {
            try
            {
                List <DAL.TransferOrder> list = new List <DAL.TransferOrder>();
                msg = "";

                //接口协议文档中定义的字段
                Dictionary <string, string> dataFieldNameDic = new Dictionary <string, string>();
                dataFieldNameDic.Add("NCOrderCode", "订单编号");
                dataFieldNameDic.Add("OrderDate", "单据日期");
                dataFieldNameDic.Add("OutWHName", "调出仓库");
                dataFieldNameDic.Add("OutOrganization", "调出组织");
                dataFieldNameDic.Add("OutCompany", "调出公司");
                dataFieldNameDic.Add("InWHName", "调入仓库");
                dataFieldNameDic.Add("InOrganization", "调入组织");
                dataFieldNameDic.Add("InCompany", "调入公司");
                dataFieldNameDic.Add("BillType", "调拨类型");
                dataFieldNameDic.Add("Comment", "备注");
                dataFieldNameDic.Add("Preparer", "制单人");
                dataFieldNameDic.Add("PreparerTime", "制单时间");
                dataFieldNameDic.Add("Approver", "审批人");
                dataFieldNameDic.Add("ApproverDate", "审批日期");
                dataFieldNameDic.Add("CheckTime", "审核时间");
                dataFieldNameDic.Add("LastEditor", "最后修改人");
                dataFieldNameDic.Add("LastEditTime", "最后修改时间");

                if (dt == null || dt.Rows.Count == 0)
                {
                    msg = "用友系统返回数据集中无数据!";
                    return(new List <TransferOrder>());
                }

                StringBuilder errorColName = new StringBuilder();
                //检查数据集中是否存在指定字段
                foreach (KeyValuePair <string, string> kvp in dataFieldNameDic)
                {
                    if (dt.Columns.Contains(kvp.Key) == false)
                    {
                        errorColName.Append(Environment.NewLine);
                        errorColName.Append(kvp.Value);
                        errorColName.Append("-");
                        errorColName.Append(kvp.Key);
                    }
                }
                if (errorColName.Length > 0)
                {
                    errorColName.Insert(0, "用友系统返回的数据集中未包含如下字段,不能进行有效解析!");
                    msg = errorColName.ToString();
                    return(new List <TransferOrder>());;
                }

                //遍历数据集创建实体
                foreach (DataRow dr in dt.Rows)
                {
                    TransferOrder newModel = new TransferOrder();

                    newModel.NCOrderCode = DataCheckHelper.GetCellString(dr["NCOrderCode"]);

                    //订单日期
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["OrderDate"])))
                    {
                        DateTime d;
                        if (DateTime.TryParse(DataCheckHelper.GetCellString(dr["OrderDate"]), out d))
                        {
                            newModel.OrderDate = d;
                        }
                    }

                    newModel.OutWHName = DataCheckHelper.GetCellString(dr["OutWHName"]);
                    if (newModel.OutWHName != "")
                    {
                        newModel.OutWHCode = DbCommonMethod.ParsingWarehouse(newModel.OutWHName);
                        if (string.IsNullOrEmpty(newModel.OutWHCode))
                        {
                            throw new ApplicationException("单号" + newModel.NCOrderCode + ",仓库不存在:" + newModel.OutWHName);
                        }
                    }

                    newModel.OutOrganization = DataCheckHelper.GetCellString(dr["OutOrganization"]);
                    newModel.OutCompany      = DataCheckHelper.GetCellString(dr["OutCompany"]);

                    newModel.InWHName = DataCheckHelper.GetCellString(dr["InWHName"]);
                    if (newModel.InWHName != "")
                    {
                        newModel.InWHCode = DbCommonMethod.ParsingWarehouse(newModel.InWHName);
                        if (string.IsNullOrEmpty(newModel.InWHCode))
                        {
                            throw new ApplicationException("单号" + newModel.NCOrderCode + ",仓库不存在:" + newModel.InWHName);
                        }
                    }

                    newModel.InOrganization = DataCheckHelper.GetCellString(dr["InOrganization"]);
                    newModel.InCompany      = DataCheckHelper.GetCellString(dr["InCompany"]);
                    //newModel = DataCheckHelper.GetCellString(dr["BillType"]);
                    //newModel = DataCheckHelper.GetCellString(dr["Comment"]);
                    //newModel = DataCheckHelper.GetCellString(dr["Preparer"]);
                    //newModel = DataCheckHelper.GetCellString(dr["PreparerTime"]);
                    //newModel = DataCheckHelper.GetCellString(dr["Approver"]);
                    //newModel = DataCheckHelper.GetCellString(dr["ApproverDate"]);
                    //newModel = DataCheckHelper.GetCellString(dr["CheckTime"]);
                    //newModel = DataCheckHelper.GetCellString(dr["LastEditor"]);

                    //最后修改时间
                    if (!string.IsNullOrEmpty(DataCheckHelper.GetCellString(dr["LastEditTime"])))
                    {
                        DateTime d;
                        if (DateTime.TryParse(DataCheckHelper.GetCellString(dr["LastEditTime"]), out d))
                        {
                            newModel.LastModifyTime = d;
                        }
                    }

                    newModel.OrderStatus = 2; //初始态
                    newModel.EditStatus  = 0; //无人编辑
                    newModel.OrderCode   = newModel.NCOrderCode;

                    List <TransferOrder> existTransferOrder = (from r in list where r.NCOrderCode == newModel.NCOrderCode select r).ToList <TransferOrder>();
                    if (existTransferOrder == null || existTransferOrder.Count == 0)//过滤重复数据
                    {
                        list.Add(newModel);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(new List <TransferOrder>());;
            }
        }