示例#1
0
        public Barcode_Model GetBarCodeInfoForReturn(string strSerialNo, string labeltype)
        {
            try
            {
                string        strSql     = string.Format("select ID,VOUCHERTYPE,DELIVERYNO,VOUCHERNO,ROWNO,QTY, OUTPACKQTY,BARCODE,BARCODETYPE,SERIALNO,MATERIALNO,MATERIALDESC,MATERIALSTD,BATCHNO,ROWNO,TrayID,ISNULL(iFlag,0) iFlag,[ProductLineNo] cProductLineCode,SoCode from t_outbarcode where serialno = '{0}'", strSerialNo);
                Barcode_Model barcodeMdl = new Barcode_Model();
                using (SqlDataReader dr = OperationSql.ExecuteReader(System.Data.CommandType.Text, strSql))
                {
                    if (dr.Read())
                    {
                        barcodeMdl.ID               = dr["id"].ToDecimal();
                        barcodeMdl.DELIVERYNO       = dr["DELIVERYNO"].ToDBString();
                        barcodeMdl.VOUCHERNO        = dr["VOUCHERNO"].ToDBString();
                        barcodeMdl.ROWNO            = dr["ROWNO"].ToDBString();
                        barcodeMdl.OUTPACKQTY       = dr["OUTPACKQTY"].ToDecimal();
                        barcodeMdl.labeltype        = dr["BARCODETYPE"].ToDBString();
                        barcodeMdl.QTY              = dr["QTY"].ToDecimal();
                        barcodeMdl.BARCODE          = dr["barcode"].ToDBString();
                        barcodeMdl.SERIALNO         = dr["serialno"].ToDBString();
                        barcodeMdl.MATERIALNO       = dr["materialno"].ToDBString();
                        barcodeMdl.MATERIALDESC     = dr["materialdesc"].ToDBString();
                        barcodeMdl.MATERIALSTD      = dr["materialstd"].ToDBString();//规格型号
                        barcodeMdl.BATCHNO          = dr["batchno"].ToDBString();
                        barcodeMdl.ROWNO            = dr["rowno"].ToDBString();
                        barcodeMdl.VOUCHERTYPE      = dr["VOUCHERTYPE"].ToDBString();
                        barcodeMdl.TrayID           = dr["TrayID"].ToInt32();
                        barcodeMdl.iFlag            = dr["iFlag"].ToInt32();
                        barcodeMdl.cProductLineCode = dr["cProductLineCode"].ToDBString();//产线
                        barcodeMdl.SoCode           = dr["SoCode"].ToDBString();
                    }
                }

                if (string.IsNullOrEmpty(barcodeMdl.SERIALNO))
                {
                    strSql = string.Format("  select a.ID,b.VOUCHERTYPE,b.DELIVERYNO,a.VOUCHERNO,a.QTY, a.OUTPACKQTY,a.BARCODE,a.BARCODETYPE,a.SERIALNO,a.MATERIALNO,a.MATERIALDESC,a.MATERIALSTD,a.BATCHNO,b.ROWNO,0 TrayID,ISNULL(iFlag,0) iFlag,[ProductLineNo] cProductLineCode,a.SoCode from T_INNERBARCODE a join T_OUTBARCODE b on a.outbox_id=b.id where a.serialno = '{0}'", strSerialNo);
                    using (SqlDataReader dr = OperationSql.ExecuteReader(System.Data.CommandType.Text, strSql))
                    {
                        if (dr.Read())
                        {
                            barcodeMdl.ID               = dr["id"].ToDecimal();
                            barcodeMdl.DELIVERYNO       = dr["DELIVERYNO"].ToDBString();
                            barcodeMdl.VOUCHERNO        = dr["VOUCHERNO"].ToDBString();
                            barcodeMdl.ROWNO            = dr["ROWNO"].ToDBString();
                            barcodeMdl.OUTPACKQTY       = dr["OUTPACKQTY"].ToDecimal();
                            barcodeMdl.labeltype        = dr["BARCODETYPE"].ToDBString();
                            barcodeMdl.QTY              = dr["QTY"].ToDecimal();
                            barcodeMdl.BARCODE          = dr["barcode"].ToDBString();
                            barcodeMdl.SERIALNO         = dr["serialno"].ToDBString();
                            barcodeMdl.MATERIALNO       = dr["materialno"].ToDBString();
                            barcodeMdl.MATERIALDESC     = dr["materialdesc"].ToDBString();
                            barcodeMdl.MATERIALSTD      = dr["materialstd"].ToDBString();//规格型号
                            barcodeMdl.BATCHNO          = dr["batchno"].ToDBString();
                            barcodeMdl.ROWNO            = dr["rowno"].ToDBString();
                            barcodeMdl.VOUCHERTYPE      = dr["VOUCHERTYPE"].ToDBString();
                            barcodeMdl.TrayID           = dr["TrayID"].ToInt32();
                            barcodeMdl.iFlag            = dr["iFlag"].ToInt32();
                            barcodeMdl.cProductLineCode = dr["cProductLineCode"].ToDBString();//产线
                            barcodeMdl.SoCode           = dr["SoCode"].ToDBString();
                        }
                    }
                    if (string.IsNullOrEmpty(barcodeMdl.SERIALNO))
                    {
                        return(null);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(labeltype) && !labeltype.Equals("10") && !labeltype.Equals("14"))
                        {
                            throw new Exception("本次扫描必须都为外箱条码!");
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(labeltype) && !labeltype.Equals("11") && !labeltype.Equals("15"))
                    {
                        throw new Exception("本次扫描必须都为内盒条码!");
                    }
                }
                //strSql = string.Format("select ISNULL(orderseq,'') sorowno,ISNULL(ordercode,'') socode from v_st_mom_orderdetail where mocode = '{0}' and MoSeq={1}", barcodeMdl.VOUCHERNO, barcodeMdl.ROWNO);
                //using (SqlDataReader dr = OperationSql.ExecuteReaderForU8(System.Data.CommandType.Text, strSql))
                //{
                //    if (dr.Read())
                //    {
                //        if (!string.IsNullOrEmpty(dr["socode"].ToDBString()))
                //            barcodeMdl.SoCode = dr["socode"].ToDBString();
                //        barcodeMdl.sorowno = dr["sorowno"].ToDBString();
                //    }
                //}
                strSql = string.Format("select 1 from t_stockoutdetails where serialno='{0}'", barcodeMdl.SERIALNO);
                object oResult = OperationSql.ExecuteScalar(CommandType.Text, strSql);
                if (oResult == null || oResult == DBNull.Value)
                {
                    strSql  = string.Format("select a.serialno from t_stockoutdetails a join T_INNERBARCODE b on a.serialno=b.serialno  where b.serialno='{0}'", barcodeMdl.SERIALNO);
                    oResult = OperationSql.ExecuteScalar(CommandType.Text, strSql);
                    if (barcodeMdl.iFlag != 4 || oResult == null || oResult == DBNull.Value)
                    {
                        barcodeMdl = null;
                        throw new Exception("该条码并未出库!");
                    }
                    else if (!char.IsLetter(oResult.ToString().Last()))
                    {
                        barcodeMdl = null;
                        throw new Exception("违规操作,该条码是按外箱出库的,不能还回内箱!");
                    }
                    else
                    {
                        strSql              = string.Format(@"select a.areano from T_STOCK a join T_OUTBARCODE b on a.serialno=b.serialno
join T_SplitRecord c on c.old_outboxid = b.id
join T_SplitDetails d on c.id = d.id
where d.serialno = '{0}' order by c.createrdate desc", barcodeMdl.SERIALNO);
                        oResult             = OperationSql.ExecuteScalar(CommandType.Text, strSql);
                        barcodeMdl.AndalaNo = oResult.ToString();
                    }
                }
                else
                {
                    if (barcodeMdl.iFlag != 4)
                    {
                        barcodeMdl = null;
                        throw new Exception("该条码并未出库!");
                    }
                }


                if (barcodeMdl.TrayID != 0)
                {
                    Tray_Func  tf   = new Tray_Func();
                    Tray_Model tray = new Tray_Model();
                    if (tf.GetTrayInfoByTrayIDForOutStock(barcodeMdl, ref tray))
                    {
                        barcodeMdl.tray_Model = tray;
                    }
                }

                return(barcodeMdl);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public Barcode_Model GetBarCodeInfo(string strSerialNo, string labeltype)
        {
            try
            {
                string        strSql     = string.Format("select a.supcode,a.supname,a.ID,VOUCHERTYPE,DELIVERYNO,VOUCHERNO,ROWNO,a.QTY, OUTPACKQTY,a.BARCODE,BARCODETYPE,a.SERIALNO,a.MATERIALNO,a.MATERIALDESC,a.MATERIALSTD,a.BATCHNO,ROWNO,TrayID,ISNULL(iFlag,0) iFlag,[ProductLineNo] cProductLineCode,SoCode,areano,ArrivalCode from t_outbarcode a left join T_STOCK b on a.serialno=b.serialno where a.serialno = '{0}'", strSerialNo);
                Barcode_Model barcodeMdl = new Barcode_Model();
                using (SqlDataReader dr = OperationSql.ExecuteReader(System.Data.CommandType.Text, strSql))
                {
                    if (dr.Read())
                    {
                        barcodeMdl.ID           = dr["id"].ToDecimal();
                        barcodeMdl.DELIVERYNO   = dr["DELIVERYNO"].ToDBString();
                        barcodeMdl.VOUCHERNO    = dr["VOUCHERNO"].ToDBString();
                        barcodeMdl.ROWNO        = dr["ROWNO"].ToDBString();
                        barcodeMdl.OUTPACKQTY   = dr["OUTPACKQTY"].ToDecimal();
                        barcodeMdl.labeltype    = dr["BARCODETYPE"].ToDBString();
                        barcodeMdl.QTY          = dr["QTY"].ToDecimal();
                        barcodeMdl.BARCODE      = dr["barcode"].ToDBString();
                        barcodeMdl.SERIALNO     = dr["serialno"].ToDBString();
                        barcodeMdl.MATERIALNO   = dr["materialno"].ToDBString();
                        barcodeMdl.MATERIALDESC = dr["materialdesc"].ToDBString();
                        barcodeMdl.MATERIALSTD  = dr["materialstd"].ToDBString();//规格型号
                        barcodeMdl.BATCHNO      = dr["batchno"].ToDBString();
                        //barcodeMdl.ROWNO = dr["rowno"].ToDBString();
                        barcodeMdl.VOUCHERTYPE      = dr["VOUCHERTYPE"].ToDBString();
                        barcodeMdl.TrayID           = dr["TrayID"].ToInt32();
                        barcodeMdl.iFlag            = dr["iFlag"].ToInt32();
                        barcodeMdl.cProductLineCode = dr["cProductLineCode"].ToDBString();//产线
                        barcodeMdl.SoCode           = dr["SoCode"].ToDBString();
                        barcodeMdl.AreaNo           = dr["AreaNo"].ToDBString();
                        barcodeMdl.ArrivalCode      = dr["ArrivalCode"].ToDBString();
                        barcodeMdl.SUPCODE          = dr["SUPCODE"].ToDBString();
                        barcodeMdl.SUPNAME          = dr["SUPNAME"].ToDBString();
                    }
                }

                if (string.IsNullOrEmpty(barcodeMdl.SERIALNO))
                {
                    strSql = string.Format("select top 1 b.serialno OUTBARCODENO,a.ID,b.VOUCHERTYPE,b.DELIVERYNO,a.VOUCHERNO,a.QTY, a.OUTPACKQTY,a.BARCODE,a.BARCODETYPE,a.SERIALNO,a.MATERIALNO,a.MATERIALDESC,a.MATERIALSTD,a.BATCHNO,b.ROWNO,0 TrayID,ISNULL(iFlag,0) iFlag,[ProductLineNo] cProductLineCode,a.SoCode,c.AreaNo from T_INNERBARCODE a join T_OUTBARCODE b on a.outbox_id=b.id left join T_STOCK c on b.serialno=c.serialno where a.serialno = '{0}'", strSerialNo);
                    using (SqlDataReader dr = OperationSql.ExecuteReader(System.Data.CommandType.Text, strSql))
                    {
                        if (dr.Read())
                        {
                            barcodeMdl.ID           = dr["id"].ToDecimal();
                            barcodeMdl.DELIVERYNO   = dr["DELIVERYNO"].ToDBString();
                            barcodeMdl.VOUCHERNO    = dr["VOUCHERNO"].ToDBString();
                            barcodeMdl.ROWNO        = dr["ROWNO"].ToDBString();
                            barcodeMdl.OUTPACKQTY   = dr["OUTPACKQTY"].ToDecimal();
                            barcodeMdl.labeltype    = dr["BARCODETYPE"].ToDBString();
                            barcodeMdl.QTY          = dr["QTY"].ToDecimal();
                            barcodeMdl.BARCODE      = dr["barcode"].ToDBString();
                            barcodeMdl.SERIALNO     = dr["serialno"].ToDBString();
                            barcodeMdl.MATERIALNO   = dr["materialno"].ToDBString();
                            barcodeMdl.MATERIALDESC = dr["materialdesc"].ToDBString();
                            barcodeMdl.MATERIALSTD  = dr["materialstd"].ToDBString();//规格型号
                            barcodeMdl.BATCHNO      = dr["batchno"].ToDBString();
                            //barcodeMdl.ROWNO = dr["rowno"].ToDBString();
                            barcodeMdl.VOUCHERTYPE      = dr["VOUCHERTYPE"].ToDBString();
                            barcodeMdl.TrayID           = dr["TrayID"].ToInt32();
                            barcodeMdl.iFlag            = dr["iFlag"].ToInt32();
                            barcodeMdl.cProductLineCode = dr["cProductLineCode"].ToDBString();//产线
                            barcodeMdl.SoCode           = dr["SoCode"].ToDBString();
                            barcodeMdl.OUTBARCODENO     = dr["OUTBARCODENO"].ToDBString();
                            barcodeMdl.AreaNo           = dr["AreaNo"].ToDBString();
                        }
                    }
                    if (string.IsNullOrEmpty(barcodeMdl.SERIALNO))
                    {
                        return(null);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(labeltype) && !labeltype.Equals("10") && !labeltype.Equals("14"))
                        {
                            throw new Exception("本次扫描必须都为外箱条码!");
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(labeltype) && !labeltype.Equals("11") && !labeltype.Equals("15"))
                    {
                        throw new Exception("本次扫描必须都为内盒条码!");
                    }
                }
                //strSql = string.Format("select ISNULL(ordercode,'') socode,ISNULL(orderseq,'') sorowno from v_st_mom_orderdetail where mocode = '{0}' and MoSeq='{1}'", barcodeMdl.VOUCHERNO, barcodeMdl.ROWNO);
                //using (SqlDataReader dr = OperationSql.ExecuteReaderForU8(System.Data.CommandType.Text, strSql))
                //{
                //    if (dr.Read())
                //    {
                //        barcodeMdl.SoCode = dr["socode"].ToDBString();
                //        barcodeMdl.sorowno = dr["sorowno"].ToDBString();
                //    }
                //}
                //barcodeMdl.SoCode = "";
                barcodeMdl.sorowno = "";
                if (barcodeMdl.TrayID != 0)
                {
                    Tray_Func  tf   = new Tray_Func();
                    Tray_Model tray = new Tray_Model();
                    if (tf.GetTrayInfoByTrayIDForOutStock(barcodeMdl, ref tray))
                    {
                        barcodeMdl.tray_Model = tray;
                    }
                }
                return(barcodeMdl);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }