Пример #1
0
        public string GetStockInfoBySerialNo(string strBarCode, string strUserJson)
        {
            StockHead_Model stockHeadModel = new StockHead_Model();

            try
            {
                if (string.IsNullOrEmpty(strBarCode))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "请先扫描条码!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                UserInfo userModel = JSONUtil.JSONHelper.JsonToObject <UserInfo>(strUserJson);
                if (userModel == null || string.IsNullOrEmpty(userModel.UserNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "没有获取用户信息!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }


                string strSerialNo = string.Empty;
                if (MaterialBarcodeDecode.InvalidBarcode(strBarCode) == false)
                {
                    if (strBarCode.ToLower().StartsWith("http"))
                    {
                        strSerialNo = strBarCode.Substring(strBarCode.LastIndexOf("?") + 4);
                    }
                    else
                    {
                        strSerialNo = strBarCode;
                    }
                }
                else
                {
                    strSerialNo = MaterialBarcodeDecode.GetSerialNo(strBarCode);
                }

                stockHeadModel.lstStockInfo = GetStockBySerialNo(strSerialNo);

                if (stockHeadModel.lstStockInfo == null || stockHeadModel.lstStockInfo.Count == 0)
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "您扫描的物料或条码没有库存!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                stockHeadModel.Status = "S";
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
            catch (Exception ex)
            {
                stockHeadModel.Status  = "E";
                stockHeadModel.Message = "Web异常:" + ex.Message;
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
        }
Пример #2
0
        public bool QueryStockSumByArraySerialNo(out List <StockHead_Model> list, string strArraySerialNo, out string strErrMsg)
        {
            string strSerialNo = "";

            string[] ArrayMaterialNo = strArraySerialNo.Split(',');
            foreach (var item in ArrayMaterialNo)
            {
                if (string.IsNullOrEmpty(strSerialNo))
                {
                    strSerialNo = "N'" + item + "'";
                }
                else
                {
                    strSerialNo += (",N'" + item + "'");
                }
            }
            try
            {
                string sql = @"select materialno,batchno,Descr,CHDesc,dMDate,dVDate,shelflife,qty ,num,serialno from T_BARCODE where 1=1 AND serialno IN (" + strSerialNo + ")";
                list = new List <StockHead_Model>();
                using (SqlDataReader dr = OperationSql.ExecuteReader(System.Data.CommandType.Text, sql))
                {
                    while (dr.Read())
                    {
                        Stock_Model model = new Stock_Model();
                        model.MaterialNo     = dr["materialno"].ToDBString();
                        model.MaterialENDesc = dr["materialdesc"].ToDBString();
                        model.MaterialCHDesc = dr["MaterialCHDesc"].ToCHString();
                        model.Qty            = dr["qty"].ToDecimal();
                        model.Num            = dr["num"].ToInt32();
                        model.BatchNo        = dr["batchno"].ToDBString();
                        model.SerialNo       = dr["serialno"].ToDBString();
                        StockHead_Model head = list.Find(s => s.MaterialNo.Equals(model.MaterialNo) && s.BatchNo.Equals(model.BatchNo));
                        if (head == null)
                        {
                            head = new StockHead_Model(model);
                            list.Add(head);
                        }
                        else
                        {
                            head.iQuantity += model.Qty;
                            head.iNum      += model.Num;
                            head.lstStockInfo.Add(model);
                        }
                    }
                }
                strErrMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                list      = null;
                strErrMsg = ex.Message;
                return(false);
            }
        }
Пример #3
0
        public string GetStockInfoByMaterialNo(string strBarcodeOrMaterialNo, string strUserJson)
        {
            StockHead_Model stockHeadModel = new StockHead_Model();

            try
            {
                bool bSucc = false;

                if (string.IsNullOrEmpty(strBarcodeOrMaterialNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "请先扫描条码或输入物料编号!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                UserInfo userModel = JSONUtil.JSONHelper.JsonToObject <UserInfo>(strUserJson);
                if (userModel == null || string.IsNullOrEmpty(userModel.UserNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "没有获取用户信息!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                Barcode_Model Barcode_Model        = new Barcode_Model();
                ReceiveGoods.ReceiveGoods_Func RGF = new ReceiveGoods.ReceiveGoods_Func();
                bSucc = RGF.GetBarCodeInfoForQueryStock(strBarcodeOrMaterialNo, ref Barcode_Model);

                if (bSucc == true)
                {
                    stockHeadModel.lstStockInfo = GetStockByMaterialNo(Barcode_Model.MATERIALNO);
                }
                else
                {
                    stockHeadModel.lstStockInfo = GetStockByMaterialNo(strBarcodeOrMaterialNo);
                }

                if (stockHeadModel.lstStockInfo == null || stockHeadModel.lstStockInfo.Count == 0)
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "您扫描的物料或条码没有库存!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                stockHeadModel.Status = "S";
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
            catch (Exception ex)
            {
                stockHeadModel.Status  = "E";
                stockHeadModel.Message = "Web异常:" + ex.Message;
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
        }
Пример #4
0
        public string GetCapacityByProductLineNo(string strProductLineNo, string strUserJson)
        {
            StockHead_Model stockHeadModel = new StockHead_Model();

            try
            {
                if (string.IsNullOrEmpty(strProductLineNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "请输入产线!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                UserInfo userModel = JSONUtil.JSONHelper.JsonToObject <UserInfo>(strUserJson);
                if (userModel == null || string.IsNullOrEmpty(userModel.UserNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "没有获取用户信息!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                Stock_DB        SD         = new Stock_DB();
                QueryConditions conditions = new QueryConditions();
                conditions.ProductLineNo    = strProductLineNo;
                conditions.StartTime        = DateTime.Today;
                conditions.EndTime          = DateTime.Today;
                stockHeadModel.lstStockInfo = SD.GetCapacity(conditions);

                if (stockHeadModel.lstStockInfo == null || stockHeadModel.lstStockInfo.Count == 0)
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "您输入的产线没有记录!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                stockHeadModel.Status = "S";
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
            catch (Exception ex)
            {
                stockHeadModel.Status  = "E";
                stockHeadModel.Message = "Web异常:" + ex.Message;
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
        }
Пример #5
0
        /// <summary>
        /// 获取物料总库存(按仓库及物料汇总)
        /// </summary>
        /// <param name="list"></param>
        /// <param name="strArrayMaterialNo">物料员,以“,”分隔</param>
        /// <param name="strErrMsg"></param>
        /// <returns></returns>
        public bool QueryStockSumForTransfer(out List <StockHead_Model> list, string strArrayMaterialNo, out string strErrMsg)
        {
            string strMaterialNo = "";

            string[] ArrayMaterialNo = strArrayMaterialNo.Split(',');
            foreach (var item in ArrayMaterialNo)
            {
                if (string.IsNullOrEmpty(strMaterialNo))
                {
                    strMaterialNo = "N'" + item + "'";
                }
                else
                {
                    strMaterialNo += (",N'" + item + "'");
                }
            }
            try
            {
                string sql = @"select materialno,Descr,CHDesc,warehouseno,SUM(iquantity) as sumqty,sum(inum) as sumnum from T_CURRENTSTOCK where 1=1 AND MATERIALNO IN (" + strMaterialNo + ") group by materialno,Descr,CHDesc,warehouseno";
                list = new List <StockHead_Model>();
                using (SqlDataReader dr = OperationSql.ExecuteReader(System.Data.CommandType.Text, sql))
                {
                    while (dr.Read())
                    {
                        StockHead_Model model = new StockHead_Model();
                        model.MaterialNo     = dr["materialno"].ToDBString();
                        model.MaterialENDesc = dr["materialdesc"].ToDBString();
                        model.MaterialCHDesc = dr["MaterialCHDesc"].ToCHString();
                        model.iQuantity      = dr["sumqty"].ToDecimal();
                        model.iNum           = dr["sumnum"].ToInt32();
                        model.WarehouseNo    = dr["WarehouseNo"].ToDBString();
                        list.Add(model);
                    }
                }
                strErrMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                list      = null;
                strErrMsg = ex.Message;
                return(false);
            }
        }
Пример #6
0
        public string GetStockInfoByArrayMaterialNo(string strVoucherNo, string strArrayMaterialNo, string strUserJson)
        {
            StockHead_Model stockHeadModel = new StockHead_Model();

            try
            {
                if (string.IsNullOrEmpty(strArrayMaterialNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "请先扫描条码或输入物料编号!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                UserInfo userModel = JSONUtil.JSONHelper.JsonToObject <UserInfo>(strUserJson);
                if (userModel == null || string.IsNullOrEmpty(userModel.UserNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "没有获取用户信息!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                stockHeadModel.lstStockInfo = GetStockByArrayMaterialNo(strVoucherNo, strArrayMaterialNo);

                if (stockHeadModel.lstStockInfo == null || stockHeadModel.lstStockInfo.Count == 0)
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "您扫描的物料或条码没有库存!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                stockHeadModel.Status = "S";
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
            catch (Exception ex)
            {
                stockHeadModel.Status  = "E";
                stockHeadModel.Message = "Web异常:" + ex.Message;
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
        }
Пример #7
0
        public string GetStockByAreaNo(string strAreaNo, string strUserJson)
        {
            StockHead_Model stockHeadModel = new StockHead_Model();

            try
            {
                if (string.IsNullOrEmpty(strAreaNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "请扫描或输入货位编号!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                UserInfo userModel = JSONUtil.JSONHelper.JsonToObject <UserInfo>(strUserJson);
                if (userModel == null || string.IsNullOrEmpty(userModel.UserNo))
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "没有获取用户信息!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }

                Stock_DB SD = new Stock_DB();
                stockHeadModel.lstStockInfo = SD.GetStockByAreaNo(strAreaNo);
                if (stockHeadModel.lstStockInfo == null || stockHeadModel.lstStockInfo.Count == 0)
                {
                    stockHeadModel.Status  = "E";
                    stockHeadModel.Message = "该货位没有物料库存信息!";
                    return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
                }
                stockHeadModel.Status = "S";
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
            catch (Exception ex)
            {
                stockHeadModel.Status  = "E";
                stockHeadModel.Message = "Web异常:" + ex.Message;
                return(JSONUtil.JSONHelper.ObjectToJson <StockHead_Model>(stockHeadModel));
            }
        }