Esempio n. 1
0
        /// <summary>
        /// 销售发货:单据装载
        /// </summary>
        /// <param name="cDLCode"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public DispatchList Load(string cDLCode, out string errMsg)
        {
            //来源主表
            BLL.Service.DispatchList sMain = Common.Instance.Service.SA_Consignment_Load(Common.Instance.User.ConnectionString, cDLCode, out errMsg);
            if (sMain == null)
            {
                return(null);
            }

            //目标主表
            DispatchList  tMain = new DispatchList();
            DispatchLists tChild;

            //转换主表
            EntityConvert.ConvertClass <BLL.Service.DispatchList, DispatchList>(sMain, tMain);
            //循环转换子表
            foreach (BLL.Service.DispatchLists sChild in sMain.List)
            {
                tChild = new DispatchLists();
                EntityConvert.ConvertClass <BLL.Service.DispatchLists, DispatchLists>(sChild, tChild);
                ////存货转换
                //tChild.Inventory = new Inventory();
                //EntityConvert.ConvertClass<BLL.Service.Inventory, Inventory>(sChild.Inventory, tChild.Inventory);
                tMain.List.Add(tChild);
            }
            return(tMain);
        }
Esempio n. 2
0
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SalesLibrary_Load(object sender, EventArgs e)
        {
            txtDelivery.Text = showCode;
            lblcCusName.Text = cCusName;
            Clear();
            string errMsg;

            try
            {
                //显示等待
                Cursor.Current = Cursors.WaitCursor;
                dispatchList   = new BLL.Consignment().Load(cDLCode, out errMsg);
                if (dispatchList != null)
                {
                    //把销售发货对象转换成销售出库对象
                    rdRecord          = EntityConvert.ConvertToRdrecord(dispatchList);
                    btnSource.Enabled = true;

                    txtBarcode.Focus();
                }
                else
                {
                    MessageBox.Show(errMsg);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 通过tcp通知控制系统删除生产登记
        /// </summary>
        /// <param name="dispatch"></param>
        /// <returns></returns>
        ResultInfo DeleteDispatchListTcp(DispatchList dispatch)
        {
            string IP = GetControlSystemIP(dispatch.ProductLineID);

            //未指定该生产线IP,不使用TCP通讯,始终返回true;
            if (string.IsNullOrEmpty(IP))
            {
                logger.WarnFormat("未配置该生产线[{0}]的IP,不使用TCP通讯[DeleteDispatchListTcp],直接返回true。", dispatch.ProductLineID);
                return(new ResultInfo
                {
                    Result = true,
                    Message = "未配置该生产线IP,不使用TCP通讯。"
                });
            }
            DataTable dt = new DataTable();

            dt.Columns.Add("ID");
            DataRow Dr = dt.NewRow();

            Dr["ID"] = dispatch.ID;
            dt.Rows.Add(Dr);
            string CMD = "102";

            string Num = IP + ":" + DateTime.Now.ToString("yyyyMMddHHmmss");
            string XML = TcpIpHelper.CombinSendXML(Num, 1, CMD, "ProductRegist", "", dt);

            return(TcpIpHelper.TcpSend(XML, CMD, IP));
        }
Esempio n. 4
0
 /// <summary>
 /// 新增调度
 /// </summary>
 /// <param name="disp"></param>
 /// <returns></returns>
 public ResultInfo AddDispatch(DispatchList disp)
 {
     if (cs != null)
     {
         return(cs.AddDispatch(disp));
     }
     return(_TrueResult);
 }
Esempio n. 5
0
 /// <summary>
 /// 交换生产登记位置
 /// </summary>
 /// <param name="disp1"></param>
 /// <param name="disp2"></param>
 /// <returns></returns>
 public bool SwapDispatch(DispatchList disp1, DispatchList disp2)
 {
     if (cs != null)
     {
         return(cs.SwapDispatchOrder(disp1, disp2));
     }
     return(true);
 }
Esempio n. 6
0
 public DispatchListNumber GetDispatches(int offset = 0, int limit = int.MaxValue, string needle = "")
 {
     if (UserHelper.IsAuthorize(new List <int> {
         (int)UserType.SuperAdmin, (int)UserType.Admin
     }))
     {
         try
         {
             dynamic             listOfDispatchFromDB = null;
             DispatchListNumber  result           = new DispatchListNumber();
             List <DispatchList> listOfDispatches = new List <DispatchList>();
             listOfDispatchFromDB = (from dispatches in _context.Dispatches
                                     join dispatchPositions in _context.Dispatches_Positions on dispatches.Id equals dispatchPositions.Dispatch_Id into q
                                     from dispatchPositions in q.DefaultIfEmpty()
                                     join orderPositions in _context.Orders_Positions on dispatchPositions.Order_Position_Id equals orderPositions.Id into x
                                     from orderPositions in x.DefaultIfEmpty()
                                     join orders in _context.Orders on orderPositions.Order_id equals orders.Id into z
                                     from orders in z.DefaultIfEmpty()
                                     where (dispatches.Deleted_At == null && dispatchPositions.Deleted_At == null && orderPositions.Deleted_At == null && orders.Deleted_At == null && (orders.ATB.Contains(needle) || orders.Container_Id.Contains(needle)))
                                     select new { Dispatches = dispatches }).Distinct().OrderByDescending(d => d.Dispatches.Created_At).Skip(offset).Take(limit);
             //List<Dispatch> listOfDispatchFromDB = _context.Dispatches.Where(d=>d.Deleted_At == null && (d.Car_Id.Contains(needle) || d.Receiver_Name.Contains(needle) || d.Carrier_Name.Contains(needle))).OrderByDescending(o => o.Creation_Date).Skip(offset).Take(limit).ToList();
             foreach (var dispatch in listOfDispatchFromDB)
             {
                 DispatchList dispatchToResult = new DispatchList();
                 dispatchToResult.Carrier_Name    = dispatch.Dispatches.Carrier_Name;
                 dispatchToResult.Car_Id          = dispatch.Dispatches.Car_Id;
                 dispatchToResult.Creation_Date   = dispatch.Dispatches.Creation_Date == null ? string.Empty : ((DateTime)dispatch.Dispatches.Creation_Date).ToString("dd-MM-yyyy");
                 dispatchToResult.Id              = dispatch.Dispatches.Id;
                 dispatchToResult.Receiver_Name   = dispatch.Dispatches.Receiver_Name;
                 dispatchToResult.IsCMR           = dispatch.Dispatches.If_CMR == null ? false : dispatch.Dispatches.If_CMR;
                 dispatchToResult.Dispatch_Number = dispatch.Dispatches.Dispatch_Number;
                 listOfDispatches.Add(dispatchToResult);
             }
             result.ListOfDispatches   = listOfDispatches;
             result.NumberOfDispatches = _dispatchManager.CountOfDispatches(needle);
             return(result);
         }
         catch (Exception ex)
         {
             throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
         }
     }
     else
     {
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "User don't have acces to this method"));
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 把数据行转换为DispatchList对象
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        public static DispatchList ConvertToDispatchList(DataRow row)
        {
            DispatchList dispatchList = new DispatchList();

            dispatchList.cVouchType   = Cast.ToString(row["cVouchType"]);
            dispatchList.cVouchName   = Cast.ToString(row["cVouchName"]);
            dispatchList.cDLCode      = Cast.ToString(row["cDLCode"]);
            dispatchList.dDate        = Cast.ToDateTime(row["dDate"]);
            dispatchList.SBVID        = Cast.ToInteger(row["SBVID"]);   //发票主表标识
            dispatchList.cSBVCode     = Cast.ToString(row["cSBVCode"]); //发票号
            dispatchList.cBusType     = Cast.ToString(row["cBusType"]);
            dispatchList.DLID         = Cast.ToInteger(row["DLID"]);
            dispatchList.cSTCode      = Cast.ToString(row["cSTCode"]);
            dispatchList.cSTName      = Cast.ToString(row["cSTName"]);
            dispatchList.cCusCode     = Cast.ToString(row["cCusCode"]);
            dispatchList.cCusAbbName  = Cast.ToString(row["cCusAbbName"]);
            dispatchList.cCusName     = Cast.ToString(row["cCusName"]);
            dispatchList.cDepCode     = Cast.ToString(row["cDepCode"]);
            dispatchList.cDepName     = Cast.ToString(row["cDepName"]);
            dispatchList.cPersonCode  = Cast.ToString(row["cPersonCode"]);
            dispatchList.cPersonName  = Cast.ToString(row["cPersonName"]);
            dispatchList.cMaker       = Cast.ToString(row["cMaker"]);
            dispatchList.cVerifier    = Cast.ToString(row["cVerifier"]);
            dispatchList.cShipAddress = Cast.ToString(row["cShipAddress"]);
            dispatchList.ufts         = Cast.ToString(row["ufts"]);
            dispatchList.cDefine1     = Cast.ToString(row["cDefine1"]);
            dispatchList.cDefine2     = Cast.ToString(row["cDefine2"]);
            dispatchList.cDefine3     = Cast.ToString(row["cDefine3"]);
            dispatchList.cDefine4     = Cast.ToDateTime(row["cDefine4"]);
            dispatchList.cDefine5     = Cast.ToInteger(row["cDefine5"]);
            dispatchList.cDefine6     = Cast.ToDateTime(row["cDefine6"]);
            dispatchList.cDefine7     = Cast.ToDouble(row["cDefine7"]);
            dispatchList.cDefine8     = Cast.ToString(row["cDefine8"]);
            dispatchList.cDefine9     = Cast.ToString(row["cDefine9"]);
            dispatchList.cDefine10    = Cast.ToString(row["cDefine10"]);
            dispatchList.cDefine11    = Cast.ToString(row["cDefine11"]);
            dispatchList.cDefine12    = Cast.ToString(row["cDefine12"]);
            dispatchList.cDefine13    = Cast.ToString(row["cDefine13"]);
            dispatchList.cDefine14    = Cast.ToString(row["cDefine14"]);
            dispatchList.cDefine15    = Cast.ToInteger(row["cDefine15"]);
            dispatchList.cDefine16    = Cast.ToDouble(row["cDefine16"]);
            dispatchList.cMemo        = Cast.ToString(row["cMemo"]);
            dispatchList.bReturnFlag  = Cast.ToBoolean(row["bReturnFlag"]);

            return(dispatchList);
        }
Esempio n. 8
0
        public object getDispatchInfoByID(string id)
        {
            string       shipDocID = string.Empty;
            int?         nullable  = 0;
            DispatchList list      = base.m_UnitOfWork.GetRepositoryBase <DispatchList>().Get(id);

            if (list != null)
            {
                shipDocID = list.ShipDocID;
                nullable  = list.BTotalPot + list.STotalPot;
            }
            else
            {
                DispatchListHistory history = base.m_UnitOfWork.GetRepositoryBase <DispatchListHistory>().Find("DispatchID = '" + id + "'", 1, 10, "ASC", "AutoID").FirstOrDefault <DispatchListHistory>();
                if (history != null)
                {
                    shipDocID = history.ShipDocID;
                    nullable  = history.BTotalPot + history.STotalPot;
                }
            }
            ShippingDocument document = base.m_UnitOfWork.GetRepositoryBase <ShippingDocument>().Get(shipDocID);

            return(new { Result = true, Message = string.Empty, TaskID = (document == null) ? string.Empty : document.TaskID, ShipDocID = (document == null) ? string.Empty : document.ID, ProjectName = (document == null) ? string.Empty : document.ProjectName, ConStrength = (document == null) ? string.Empty : document.ConStrength, ProductLineID = (document == null) ? string.Empty : document.ProductLineID, CarID = (document == null) ? string.Empty : document.CarID, SendCube = (document == null) ? 0M : document.SendCube, SendPot = nullable, Operator = (document == null) ? string.Empty : document.Operator });
        }
Esempio n. 9
0
 public int SaveDispatchList(DispatchList dl, string connectionString, string accid, string year, out string errMsg)
 {
     return(DispatchListProcess.SaveDispatchList(dl, connectionString, accid, year, out errMsg));
 }
Esempio n. 10
0
        ResultInfo UpdateDispatchListTcp(DispatchList dispatch)
        {
            string IP = GetControlSystemIP(dispatch.ProductLineID);

            //未指定该生产线IP,不使用TCP通讯,始终返回true;
            if (string.IsNullOrEmpty(IP))
            {
                logger.WarnFormat("未配置该生产线[{0}]的IP,不使用TCP通讯[UpdateDispatchListTcp],直接返回true。", dispatch.ProductLineID);
                return(new ResultInfo
                {
                    Result = true,
                    Message = "未配置该生产线IP,不使用TCP通讯。"
                });
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("ID");
            dt.Columns.Add("PRegOrder");
            dt.Columns.Add("TaskID");
            dt.Columns.Add("CarID");
            dt.Columns.Add("Driver");

            dt.Columns.Add("CurCarProductNum");
            dt.Columns.Add("CurCarNum");
            dt.Columns.Add("FirNum");
            dt.Columns.Add("FirTrayNum");
            dt.Columns.Add("SecNum");
            dt.Columns.Add("SecTrayNum");
            dt.Columns.Add("IsContRun");
            dt.Columns.Add("RunproductCarNum");
            dt.Columns.Add("CompletetCarNum");
            dt.Columns.Add("ConcreteTrayNum");
            dt.Columns.Add("TraySumNum");
            dt.Columns.Add("FirMortarNum");
            dt.Columns.Add("FirMortarTrayNum");
            dt.Columns.Add("SecMortarTrayNum");
            dt.Columns.Add("SecMortarNum");
            dt.Columns.Add("MortarTrayNum");
            dt.Columns.Add("MortarTraySumNum");
            dt.Columns.Add("ConcreteSumNum");
            dt.Columns.Add("MortarNum");
            dt.Columns.Add("StartTime");
            dt.Columns.Add("EndTime");
            dt.Columns.Add("IsDivideAvg");
            dt.Columns.Add("TrayRate");
            dt.Columns.Add("ProductLineID");
            dt.Columns.Add("PrintStatus");
            dt.Columns.Add("RestStuffNum");
            dt.Columns.Add("TicketNum");
            dt.Columns.Add("FormulaCont");
            dt.Columns.Add("FormulaMor");
            dt.Columns.Add("FinishedAutoDel");
            dt.Columns.Add("Version");
            dt.Columns.Add("CreateTime");
            dt.Columns.Add("UpdateTime");
            dt.Columns.Add("CreaterID");
            dt.Columns.Add("UpdaterID");
            dt.Columns.Add("Status");
            dt.Columns.Add("PrintNum");
            dt.Columns.Add("PrintCarNum");
            dt.Columns.Add("BYField1");
            dt.Columns.Add("BYField2");
            dt.Columns.Add("BYField3");
            dt.Columns.Add("BYField4");
            dt.Columns.Add("BYField5");
            dt.Columns.Add("ShipDocID");

            DataRow Dr = dt.NewRow();

            Dr["ID"]               = dispatch.ID;
            Dr["PRegOrder"]        = dispatch.DispatchOrder;
            Dr["TaskID"]           = dispatch.TaskID;
            Dr["CarID"]            = dispatch.CarID;
            Dr["Driver"]           = dispatch.Driver;
            Dr["CompletetCarNum"]  = dispatch.ProvidedTimes;
            Dr["CurCarProductNum"] = dispatch.ProvidedCube;
            Dr["CurCarNum"]        = dispatch.ProduceCube;
            Dr["FirNum"]           = dispatch.OneCube;
            Dr["FirTrayNum"]       = dispatch.BNextPot;
            Dr["SecNum"]           = dispatch.TwoCube;
            Dr["SecTrayNum"]       = dispatch.BTotalPot - dispatch.BNextPot;
            Dr["IsContRun"]        = 0;
            Dr["RunproductCarNum"] = 0;
            Dr["ConcreteTrayNum"]  = dispatch.BTotalPot;
            Dr["TraySumNum"]       = dispatch.BTotalPot + dispatch.STotalPot;
            Dr["FirMortarNum"]     = dispatch.OneSlurryCube;
            Dr["FirMortarTrayNum"] = dispatch.SNextPot;
            Dr["SecMortarNum"]     = dispatch.TwoSlurryCube;
            Dr["SecMortarTrayNum"] = dispatch.STotalPot - dispatch.SNextPot;
            Dr["MortarTrayNum"]    = dispatch.STotalPot;
            Dr["MortarTraySumNum"] = dispatch.STotalPot;
            Dr["ConcreteSumNum"]   = dispatch.BetonCount;
            Dr["MortarNum"]        = dispatch.SlurryCount;
            Dr["StartTime"]        = null;
            Dr["EndTime"]          = null;
            Dr["IsDivideAvg"]      = dispatch.IsAverage;
            Dr["TrayRate"]         = dispatch.PCRate;
            Dr["ProductLineID"]    = "00000" + dispatch.ProductLineID;// 系统中数据库已经将机组线号改成8位
            //Dr["ProductLineID"] = dispatch.ProductLineID;
            Dr["PrintStatus"]     = 0;
            Dr["RestStuffNum"]    = 0;
            Dr["TicketNum"]       = dispatch.ParCube;
            Dr["FormulaCont"]     = dispatch.BetonFormula;
            Dr["FormulaMor"]      = dispatch.SlurryFormula;
            Dr["FinishedAutoDel"] = 0;
            Dr["Version"]         = 1;

            Dr["CreateTime"] = dispatch.BuildTime;
            Dr["UpdateTime"] = dispatch.ModifyTime;
            Dr["CreaterID"]  = dispatch.Builder;
            Dr["UpdaterID"]  = dispatch.Modifier;

            //Dr["Status"] = 0;//ERP修改调度不修改控制系统的生产状态
            Dr["PrintNum"]    = dispatch.ProvidedCube;
            Dr["PrintCarNum"] = dispatch.ProvidedTimes;
            Dr["BYField1"]    = dispatch.ParCube;                                                                //备用1:出票方量
            Dr["BYField2"]    = dispatch.ProvidedTimes;                                                          //备用2:累计车次
            Dr["BYField3"]    = dispatch.ProvidedCube;                                                           //备用3:已供方量
            Dr["BYField4"]    = dispatch.ConStrength;                                                            //备用4:砼强度
            Dr["BYField5"]    = string.IsNullOrEmpty(dispatch.PumpName) ? dispatch.CastMode : dispatch.PumpName; //备用5:浇筑方式或泵名称
            Dr["ShipDocID"]   = dispatch.ShipDocID;

            dt.Rows.Add(Dr);
            string CMD = "103";

            string Num = IP + ":" + DateTime.Now.ToString("yyyyMMddHHmmss");
            string XML = TcpIpHelper.CombinSendXML(Num, 1, CMD, "ProductRegist", "", dt);

            return(TcpIpHelper.TcpSend(XML, CMD, IP));
        }
Esempio n. 11
0
 /// <summary>
 /// 新增调度
 /// </summary>
 /// <param name="disp"></param>
 /// <returns></returns>
 public ResultInfo AddDispatch(DispatchList disp)
 {
     return(AddDispatchListTcp(disp));
 }
Esempio n. 12
0
        /// <summary>
        /// 把销售发货主表对象转换成销售出库主表对象
        /// </summary>
        /// <param name="dispatchList"></param>
        /// <returns></returns>
        public static RdRecord ConvertToRdrecord(DispatchList dispatchList)
        {
            RdRecord rdRecord = new RdRecord();

            //rdRecord.cVouchName = "销售出库单";//VouchType字典表
            //rdRecord.cVouchType = "32";
            rdRecord.cRdCode = "201";//数据表rd_style
            //rdRecord.cRdName = "销售出库";

            rdRecord.cWhCode = dispatchList.cWhCode;
            rdRecord.cWhName = dispatchList.cWhName;
            //rdRecord.bIsSTQc = dispatchList.bIsSTQc;
            //rdRecord.bRdFlag = dispatchList.bRdFlag;
            rdRecord.cAccounter  = dispatchList.cAccounter;
            rdRecord.cAddCode    = dispatchList.caddcode;
            rdRecord.cBillCode   = dispatchList.SBVID;    //发票主表标识
            rdRecord.isalebillid = dispatchList.cSBVCode; //发票号
            //来源单据:判断发票号是否空,如果为空则为发货单号,否则为发票号(即零售日报号)
            rdRecord.cBusCode = string.IsNullOrEmpty(dispatchList.cSBVCode) ? dispatchList.cDLCode : dispatchList.cSBVCode;
            rdRecord.cBusType = dispatchList.cBusType;
            //rdRecord.cChkCode = dispatchList.cchkcode;
            //rdRecord.cChkPerson = dispatchList.cchkperson;
            //rdRecord.cCode = dispatchList;
            rdRecord.cContactName = dispatchList.cContactName;
            rdRecord.cCusAbbName  = dispatchList.cCusAbbName;
            //rdRecord.ccusaddress = dispatchList.ccusaddress;
            rdRecord.cCusCode = dispatchList.cCusCode;
            //rdRecord.ccushand = dispatchList.ccushand;
            rdRecord.ccusperson = dispatchList.ccusperson;
            //rdRecord.ccusphone = dispatchList.ccusphone;
            rdRecord.cDefine1     = dispatchList.cDefine1;
            rdRecord.cDefine2     = dispatchList.cDefine2;
            rdRecord.cDefine3     = dispatchList.cDefine3;
            rdRecord.cDefine4     = dispatchList.cDefine4;
            rdRecord.cDefine5     = dispatchList.cDefine5;
            rdRecord.cDefine6     = dispatchList.cDefine6;
            rdRecord.cDefine7     = dispatchList.cDefine7;
            rdRecord.cDefine8     = dispatchList.cDefine8;
            rdRecord.cDefine9     = dispatchList.cDefine9;
            rdRecord.cDefine10    = dispatchList.cDefine10;
            rdRecord.cDefine11    = dispatchList.cDefine11;
            rdRecord.cDefine12    = dispatchList.cDefine12;
            rdRecord.cDefine13    = dispatchList.cDefine13;
            rdRecord.cDefine14    = dispatchList.cDefine14;
            rdRecord.cDefine15    = dispatchList.cDefine15;
            rdRecord.cDefine16    = dispatchList.cDefine16;
            rdRecord.cdeliverunit = dispatchList.cdeliverunit;
            rdRecord.cDepCode     = dispatchList.cDepCode;
            rdRecord.cDepName     = dispatchList.cDepName;
            rdRecord.DLID         = dispatchList.DLID;
            rdRecord.cDLCode      = dispatchList.cDLCode;
            //rdRecord.cHandler = dispatchList.chandler;
            //rdRecord.cMaker = dispatchList.cMaker;
            rdRecord.cMemo        = dispatchList.cMemo;
            rdRecord.cmobilephone = dispatchList.cmobilephone;
            //rdRecord.cModifyPerson = dispatchList.cmodifier;
            rdRecord.cofficephone = dispatchList.cofficephone;
            //rdRecord.contactmobile = dispatchList.contactmobile;
            //rdRecord.contactphone = dispatchList.contactphone;
            rdRecord.cPersonCode = dispatchList.cPersonCode;
            rdRecord.cPersonName = dispatchList.cPersonName;
            //rdRecord.cRdCode = dispatchList.cRdCode;
            //rdRecord.cRdName = dispatchList.cRdName;
            rdRecord.cShipAddress = dispatchList.cShipAddress;
            rdRecord.cSource      = dispatchList.cVouchName;
            rdRecord.cSTCode      = dispatchList.cSTCode;
            rdRecord.cSTName      = dispatchList.cSTName;
            //rdRecord.cVenAbbName = dispatchList.;
            //rdRecord.cVenCode = dispatchList.cvencode;
            //rdRecord.cWhName = dispatchList.cwhname;
            //rdRecord.dChkDate = dispatchList.dchkdate;
            //rdRecord.dDate = MainForm.OperateTime; //单据日期
            //rdRecord.dModifyDate = dispatchList.dmoddate;
            //rdRecord.dnmaketime =DateTime.Now;// dispatchList;
            //rdRecord.dnmodifytime = dispatchList.dmodifysystime;
            //rdRecord.dnverifytime = dispatchList.dverifysystime;
            //rdRecord.dVeriDate = dispatchList.dverifydate;
            //rdRecord.gspcheck = dispatchList.;
            rdRecord.iarriveid = dispatchList.cDLCode;//发货退货单号
            //rdRecord.iAvaNum = dispatchList.iav;
            //rdRecord.iAvaQuantity = dispatchList.iav;
            //rdRecord.ID=;
            //rdRecord.iLowSum = dispatchList.;
            //rdRecord.ipresent = dispatchList.ipr;
            //rdRecord.iPresentNum = dispatchList.ipr;
            //rdRecord.ireturncount = dispatchList.ireturncount;
            //rdRecord.iSafeSum =;
            rdRecord.iswfcontrolled = dispatchList.iswfcontrolled;
            //rdRecord.iTopSum=;
            //rdRecord.iverifystate = dispatchList.iverifystate;
            //rdRecord.iVTid = ;
            rdRecord.ufts = dispatchList.ufts;

            return(rdRecord);
        }
Esempio n. 13
0
        public frmSaleOutList(DispatchList dl)
        {
            InitializeComponent();
            if (dl.OperateDetails == null || dl.OperateDetails.Count < 1)
            {
                return;
            }
            this.dl = dl;
            DataGridTableStyle dts = new DataGridTableStyle();

            DataGridTextBoxColumn dtbc = new DataGridTextBoxColumn();

            dtbc.HeaderText  = "存货编码";
            dtbc.MappingName = "cinvcode";
            dtbc.Width       = 80;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "存货名称";
            dtbc.MappingName = "cinvname";
            dtbc.Width       = 90;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "数量";
            dtbc.MappingName = "iquantity";
            dtbc.Width       = 70;
            dtbc.Format      = "F2";
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "累计发货数量";
            dtbc.MappingName = "IFHQuantity";
            dtbc.Width       = 70;
            dtbc.Format      = "F2";
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "扫描数量";
            dtbc.MappingName = "inewquantity";
            dtbc.Width       = 70;
            dtbc.Format      = "F2";
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "规格";
            dtbc.MappingName = "cinvstd";
            dtbc.Width       = 90;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "产地";
            dtbc.MappingName = "cdefine22";
            dtbc.Width       = 100;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "主计量单位";
            dtbc.MappingName = "comunit";
            dtbc.Width       = 70;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "含税单价";
            dtbc.MappingName = "itaxunitprice";
            dtbc.Width       = 70;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "批号";
            dtbc.MappingName = "invbatch";
            dtbc.Width       = 100;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "货位";
            dtbc.MappingName = "cposition";
            dtbc.Width       = 70;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "生产日期";
            dtbc.MappingName = "dmdate";
            dtbc.Width       = 100;
            dtbc.Format      = "yyyy-MM-dd";
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "有效期至";
            dtbc.MappingName = "cexpirationdate";
            dtbc.Width       = 100;
            dtbc.Format      = "yyyy-MM-dd";
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "失效日期";
            dtbc.MappingName = "dvdate";
            dtbc.Width       = 100;
            dtbc.Format      = "yyyy-MM-dd";
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "客户名称";
            dtbc.MappingName = "ccusname";
            dtbc.Width       = 120;
            dts.GridColumnStyles.Add(dtbc);

            dtbc             = new DataGridTextBoxColumn();
            dtbc.HeaderText  = "客户简称";
            dtbc.MappingName = "ccusabbname";
            dtbc.Width       = 120;
            dts.GridColumnStyles.Add(dtbc);

            dataGrid1.TableStyles.Add(dts);
            dataGrid1.RowHeadersVisible = true;
            dts.MappingName             = dl.OperateDetails.GetType().Name;
            this.dataGrid1.DataSource   = dl.OperateDetails;
        }
Esempio n. 14
0
        /// <summary>
        /// 生成销售发货单
        /// </summary>
        /// <param name="dl"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static int SaveDispatchList(DispatchList dl, out string errMsg)
        {
            Common co = Common.GetInstance();

            errMsg = "";
            try
            {
                U8Business.Service.DispatchList dispatchlist = new U8Business.Service.DispatchList();

                #region webserver 实体类转换

                //表头
                dispatchlist.cpersoncode  = dl.cpersoncode;
                dispatchlist.cbustype     = dl.cbustype;
                dispatchlist.cDLCode      = dl.cDLCode;
                dispatchlist.cdepcode     = dl.cdepcode;
                dispatchlist.csocode      = dl.csocode;
                dispatchlist.ccuscode     = dl.ccuscode;
                dispatchlist.cexch_name   = dl.cexch_name;
                dispatchlist.iExchRate    = dl.iExchRate;
                dispatchlist.itaxrate     = dl.itaxrate;
                dispatchlist.cmemo        = dl.cmemo;
                dispatchlist.cdefine2     = dl.cdefine2;
                dispatchlist.cdefine3     = dl.cdefine3;
                dispatchlist.cdefine10    = dl.cdefine10;//监管码
                dispatchlist.cdefine11    = dl.cdefine11;
                dispatchlist.cmaker       = dl.cmaker;
                dispatchlist.ccusname     = dl.ccusname;
                dispatchlist.ccusperson   = dl.ccusperson;
                dispatchlist.ccusoaddress = dl.ccusoaddress;
                dispatchlist.cSCCode      = dl.cSCCode;
                dispatchlist.caddcode     = dl.caddcode;

                //2013-11-11
                dispatchlist.cinvoicecompany = dl.cinvoicecompany; //开票单位编码 
                dispatchlist.ccuspersoncode  = dl.ccuspersoncode;  //联系人编码 

                dispatchlist.cstcode = dl.cstcode;                 //销售类型

                //表体
                dispatchlist.OperateDetails = new U8Business.Service.DispatchDetail[dl.OperateDetails.Count];
                int i = 0;
                foreach (DispatchDetail dd in dl.OperateDetails)
                {
                    U8Business.Service.DispatchDetail detail = new U8Business.Service.DispatchDetail();
                    detail.cposition         = dd.cposition;//货位
                    detail.cwhcode           = dd.cwhcode;
                    detail.cinvcode          = dd.cinvcode;
                    detail.iquantity         = dd.iquantity;
                    detail.inewquantity      = dd.inewquantity;
                    detail.iquotedprice      = dd.iquotedprice;
                    detail.iunitprice        = dd.iunitprice;
                    detail.itaxunitprice     = dd.itaxunitprice;
                    detail.imoney            = dd.imoney * dd.inewquantity / dd.iquantity;
                    detail.itax              = dd.itax * dd.inewquantity / dd.iquantity;
                    detail.isum              = dd.isum * dd.inewquantity / dd.iquantity;
                    detail.idiscount         = dd.idiscount * dd.inewquantity / dd.iquantity;
                    detail.inatunitprice     = dd.inatunitprice;
                    detail.inatmoney         = dd.inatmoney * dd.inewquantity / dd.iquantity;
                    detail.inattax           = dd.inattax * dd.inewquantity / dd.iquantity;
                    detail.inatsum           = dd.inatsum * dd.inewquantity / dd.iquantity;
                    detail.inatdiscount      = dd.inatdiscount * dd.inewquantity / dd.iquantity;
                    detail.invbatch          = dd.invbatch;
                    detail.dvdate            = dd.dvdate;
                    detail.isosid            = dd.isosid;
                    detail.kl                = dd.kl;
                    detail.kl2               = dd.kl2;
                    detail.cinvname          = dd.cinvname;
                    detail.itaxrate          = dd.itaxrate;
                    detail.cdefine22         = dd.cdefine22;
                    detail.fsalecost         = dd.fsalecost;
                    detail.fsaleprice        = dd.fsaleprice * dd.inewquantity / dd.iquantity;
                    detail.cvenabbname       = dd.cvenabbname;
                    detail.dmdate            = dd.dmdate;
                    detail.csocode           = dd.csocode;
                    detail.cmassunit         = dd.cmassunit;
                    detail.imassdate         = dd.imassdate;
                    detail.cordercode        = dd.cordercode;
                    detail.iexpiratdatecalcu = dd.iexpiratdatecalcu;
                    detail.dexpirationdate   = dd.dexpirationdate;
                    detail.cexpirationdate   = dd.cexpirationdate;
                    detail.cvencode          = dd.cvencode;
                    detail.cdefine25         = dd.cdefine25;//请货单号

                    //2013-11-11
                    detail.bsaleprice = dd.bsaleprice;   //报价含税标识
                    detail.bgift      = dd.bgift;        //是否赠品

                    detail.iorderrowno = dd.iorderrowno; //订单行号

                    dispatchlist.OperateDetails[i] = detail;
                    i++;
                }
                #endregion

                int rt = co.Service.SaveDispatchList(dispatchlist, Common.CurrentUser.ConnectionString, Common.CurrentUser.Accid, Common.CurrentUser.Year, out errMsg);
                if (rt != -1 && errMsg.Equals(""))
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(-1);
            }
        }
        /// <summary>
        /// 销售发货:单据装载
        /// </summary>
        /// <param name="connectionString"></param>
        /// <param name="cDLCode"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        /// <remarks>tianzhenyun 2013-06-20</remarks>
        public DispatchList Load(string connectionString, string cDLCode, out string errMsg)
        {
            errMsg = string.Empty;
            DispatchList dispatchList = null;
            //查询主表
            string strSql = string.Format(@" SELECT DISTINCT DispatchList.caddcode, (CASE WHEN isnull(DispatchList.cSBVCode, '') <> '' THEN salebillvouch.cVouchType  ELSE Dispatchlist.cVouchType END) AS cVouchType,  VouchType.cVouchName,
DispatchList.cDLCode,DispatchList.sbvid ,DispatchList.cSBVCode,DispatchList.ddate,DispatchList.cBusType, DispatchList.DLID as DLID,  DispatchList.cSTCode, 
SaleType.cSTName, DispatchList.cCusCode, Customer.cCusAbbName,Customer.cCusName, DispatchList.cDepCode, Department.cDepName,DispatchList.cPersonCode ,
 Person.cPersonName, DispatchList.cMaker,DispatchList.cVerifier,
DispatchList.cShipAddress,convert(char,convert(money,DispatchList.ufts),2) as ufts   ,
DispatchList.cDefine1 , DispatchList.cDefine2, DispatchList.cDefine3, DispatchList.cDefine4, 
 DispatchList.cDefine5, DispatchList.cDefine6, DispatchList.cDefine7, DispatchList.cDefine8, DispatchList.cDefine9, 
 DispatchList.cDefine10, DispatchList.cDefine11, DispatchList.cDefine12, DispatchList.cDefine13, DispatchList.cDefine14,
 DispatchList.cDefine15, DispatchList.cDefine16,DispatchList.cMemo,DispatchList.bReturnFlag 
 from DispatchList inner join   DispatchLists ON DispatchList.DLID = DispatchLists.DLID  
  INNER JOIN  Inventory ON DispatchLists.cInvCode = Inventory.cInvCode left join ComputationUnit on Inventory.ccomunitcode=ComputationUnit.ccomunitcode 
 inner join Warehouse on DispatchLists.cwhcode=warehouse.cwhcode
 LEFT OUTER JOIN SaleType ON DispatchList.cSTCode = SaleType.cSTCode 
 LEFT OUTER JOIN (select cpersoncode as cpersoncode2,cpersonname from Person) person ON DispatchList.cPersonCode = Person.cPersonCode2 
 LEFT OUTER JOIN  Customer ON DispatchList.cCusCode = Customer.cCusCode 
 LEFT OUTER JOIN Department ON DispatchList.cDepCode = Department.cDepCode
 left join SaleBillVouch on SaleBillVouch.SBVID = dbo.DispatchList.SBVID  
 left join VouchType on VouchType.cVouchType = case when  salebillvouch.SBVID is null then dispatchlist.cVouchType else salebillvouch.cVouchType end  
 WHERE  (DispatchList.cVouchType='05' OR DispatchList.cVouchType='06') 
AND  ((ISNULL(DispatchList.cSaleOut,'') = '' OR isnull(bqaneedcheck,0)=1) OR DispatchList.cSaleOut ='ST')    
AND NOT (isnull(DispatchList.bFirst,0) =1 And isnull(DispatchLists.bIsStQC,0) =0) 
AND (
	(ABS(ISNULL((case when (isnull(DispatchLists.bQANeedCheck,0)=1 and DispatchLists.iquantity>0) then DispatchLists.iqaquantity else DispatchLists.iquantity end ),0))-ABS(ISNULL(DispatchLists.fOutQuantity,0))    ) >=0.01 
	or ( igrouptype=2 and  (  ABS(ISNULL((case when (isnull(DispatchLists.bQANeedCheck,0)=1 and DispatchLists.iquantity>0) then DispatchLists.iqanum else DispatchLists.inum end ),0))-ABS(ISNULL(DispatchLists.fOutnum,0)) ) >=0.01)
	)
AND (ISNULL(DispatchLists.cWhCode,'')<>'') 
AND bInvType=0 
AND bService=0  
AND	((ISNULL(DispatchLists.bSettleAll,0)=0 and DispatchList.cvouchtype='05') or DispatchList.cvouchtype='06')  
AND ISNULL(DispatchList.cVerifier,'')<>''  
AND DISPATCHLIST.CDLCODE = N'{0}'
AND (
	(case when isnull(DispatchLists.bQANeedCheck,0)=1 and isnull(DispatchLists.iquantity,0)>0 then DispatchLists.iqaquantity else DispatchLists.iquantity end) <>0 
	 OR (case when isnull(DispatchLists.bQANeedCheck,0)=1  and isnull(DispatchLists.inum,0)>0 then DispatchLists.iqanum else DispatchLists.inum end) <>0)"    , cDLCode);

            DataTable dt = null;

            try
            {
                dt = DBHelperSQL.QueryTable(connectionString, strSql);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(dispatchList);
            }
            if (dt.Rows.Count == 0)
            {
                errMsg = "单据错误或单据不存在、未审核、已关闭";
                return(dispatchList);
            }
            //转换主表
            dispatchList = EntityConvert.ConvertToDispatchList(dt.Rows[0]);
            //查询子表
            strSql = string.Format(@"Select WareHouse.cWhName
,DispatchList.cDLCode
,DispatchLists.AutoID,DispatchLists.cWhCode, DispatchLists.DLID, DispatchLists.iCorID,DispatchLists.cInvCode,DispatchLists.iQuotedPrice,DispatchLists.ccusinvcode,DispatchLists.ccusinvname,DispatchLists.iExpiratDateCalcu,DispatchLists.cExpirationdate,DispatchLists.dExpirationdate,DispatchLists.iUnitPrice, DispatchLists.iTaxUnitPrice,DispatchLists.iMoney, DispatchLists.iTax, DispatchLists.iDisCount,DispatchLists.iSum, DispatchLists.iNatUnitPrice,DispatchLists.iNatMoney, DispatchLists.iNatTax, DispatchLists.iNatSum,DispatchLists.iNatDisCount, DispatchLists.iSettleNum,DispatchLists.iSettleQuantity, DispatchLists.iBatch,DispatchLists.iInvExchRate,DispatchLists.cBatch, DispatchLists.bSettleAll, DispatchLists.cvmivencode,DispatchLists.cFree1, DispatchLists.cFree2, DispatchLists.iTB,DispatchLists.dMDate , DispatchLists.dvDate,DispatchLists.cMassUnit,DispatchLists.iMassDate, DispatchLists.TBQuantity, DispatchLists.TBNum,DispatchLists.iSOsID, DispatchLists.iDLsID, DispatchLists.KL,DispatchLists.iTaxRate, DispatchLists.KL2,DispatchLists.cDefine22, DispatchLists.cDefine23,DispatchLists.cDefine24, DispatchLists.cDefine25,DispatchLists.cDefine26, DispatchLists.cDefine27,convert(int,1) as isotype, DispatchLists.isosid as isodid,DispatchLists.idemandtype,DispatchLists.cdemandcode,DispatchLists.cdemandid,DispatchLists.idemandseq,DispatchLists.cItemCode, DispatchLists.cItem_class,DispatchLists.fSaleCost, DispatchLists.fSalePrice,DispatchLists.cVenAbbName, DispatchLists.cItemName,DispatchLists.cContractid,DispatchLists.ccontractTagCode,DispatchLists.ccontractrowguid,DispatchLists.cItem_CName, DispatchLists.cFree3,DispatchLists.cFree4, DispatchLists.cFree5, DispatchLists.cFree6,DispatchLists.cFree7, DispatchLists.cFree8, DispatchLists.cFree9,DispatchLists.cFree10,DispatchLists.cBatchProperty1,DispatchLists.cBatchProperty2,DispatchLists.cBatchProperty3, DispatchLists.bIsSTQc,DispatchLists.cBatchProperty4,DispatchLists.cBatchProperty5,DispatchLists.cBatchProperty6,DispatchLists.cBatchProperty7,DispatchLists.cBatchProperty8,DispatchLists.cBatchProperty9,DispatchLists.cBatchProperty10,DispatchLists.cUnitID, DispatchLists.cCode,DispatchLists.iRetQuantity, DispatchLists.fEnSettleQuan,DispatchLists.fEnSettleSum, DispatchLists.iSettlePrice,DispatchLists.cDefine28, DispatchLists.cDefine29,DispatchLists.cDefine30, DispatchLists.cDefine31,DispatchLists.cDefine32, DispatchLists.cDefine33,DispatchLists.cDefine34, DispatchLists.cDefine35,DispatchLists.cDefine36, DispatchLists.cDefine37,DispatchLists.bGsp, DispatchLists.cGspState,DispatchLists.bQANeedCheck,DispatchLists.cSoCode,DispatchLists.bCosting,DispatchLists.iorderrowno
,v1.cvenabbname as cvmivenname
,ComputationUnit.cComUnitName AS cinvm_unit,ComputationUnit_1.cComUnitName AS cinva_unit 
,SaleType.cstcode,saletype.cstname, SA_SORowNo.iRowNo
,inventory.cinvaddcode,Inventory.cInvName,Inventory.cInvStd, Inventory.cInvCCode, Inventory.cVenCode, Inventory.cReplaceItem, Inventory.cPosition, Inventory.bSale,Inventory.bPurchase, Inventory.bSelf, Inventory.bComsume,Inventory.bProducing, Inventory.bService, Inventory.bAccessary,Inventory.iInvWeight, Inventory.iVolume,Inventory.iInvRCost, Inventory.iInvSPrice, Inventory.iInvSCost,Inventory.iInvLSCost, Inventory.iInvNCost, Inventory.iInvAdvance,Inventory.iInvBatch, Inventory.iSafeNum, Inventory.iTopSum,Inventory.iLowSum, Inventory.iOverStock, Inventory.cInvABC,Inventory.bInvQuality, Inventory.bInvBatch, Inventory.bInvEntrust,Inventory.bInvOverStock, Inventory.dSDate, Inventory.dEDate,Inventory.bFree1, Inventory.bFree2, Inventory.cInvDefine1,Inventory.cInvDefine2, Inventory.cInvDefine3, Inventory.I_id,Inventory.bInvType, Inventory.iInvMPCost, Inventory.cQuality,Inventory.iInvSaleCost, Inventory.iInvSCost1, Inventory.iInvSCost2,Inventory.iInvSCost3, Inventory.bFree3, Inventory.bFree4,Inventory.bFree5, Inventory.bFree6, Inventory.bFree7,Inventory.bFree8, Inventory.bFree9, Inventory.bFree10,Inventory.cCreatePerson, Inventory.cModifyPerson,Inventory.dModifyDate, Inventory.fSubscribePoint,Inventory.fVagQuantity, Inventory.cValueType, Inventory.bFixExch,Inventory.fOutExcess, Inventory.fInExcess,Inventory.iWarnDays, Inventory.fExpensesExch, Inventory.bTrack,Inventory.bSerial, Inventory.bBarCode, Inventory.iId,Inventory.cBarCode, Inventory.cInvDefine4, Inventory.cInvDefine5,Inventory.cInvDefine6, Inventory.cInvDefine7, Inventory.cInvDefine8,Inventory.cInvDefine9, Inventory.cInvDefine10, Inventory.cInvDefine11,Inventory.cInvDefine12, Inventory.cInvDefine13, Inventory.cInvDefine14,Inventory.cInvDefine15, Inventory.cInvDefine16,convert(bit,0) AS bQuanSign, Inventory.iGroupType,Inventory.cGroupCode, Inventory.cAssComUnitCode,Inventory.cSAComUnitCode, Inventory.cPUComUnitCode,Inventory.cSTComUnitCode, Inventory.cComUnitCode,Inventory.cCAComUnitCode, Inventory.cFrequency, Inventory.iFrequency,Inventory.iDays, Inventory.dLastDate, Inventory.iWastage,Inventory.bSolitude, Inventory.cEnterprise, Inventory.cAddress,Inventory.cFile, Inventory.cLabel, Inventory.cCheckOut,Inventory.cLicence, Inventory.bSpecialties, Inventory.cDefWareHouse, Inventory.iHighPrice, Inventory.cPriceGroup,Inventory.iExpSaleRate, Inventory.cOfferGrade, Inventory.iOfferRate,Inventory.cMonth, Inventory.iAdvanceDate, Inventory.cCurrencyName,Inventory.cProduceAddress, Inventory.cProduceNation,Inventory.cRegisterNo, Inventory.cEnterNo, Inventory.cPackingType,Inventory.cEnglishName, Inventory.bPropertyCheck,Inventory.cPreparationType, Inventory.cCommodity,Inventory.iRecipeBatch, Inventory.cNotPatentName,Inventory.pubufts
,(case when (isnull(DispatchLists.bQANeedCheck,0)=1 and DispatchLists.iquantity>0) then isnull(DispatchLists.iqaquantity,0) else isnull(DispatchLists.iquantity,0) end ) as iquantity
, (case when (isnull(DispatchLists.bqaneedcheck,0)=1 and DispatchLists.inum>0) then isnull(DispatchLists.iqanum,0) else isnull(DispatchLists.inum,0) end) as inum,isnull(DispatchLists.fOutQuantity,0) as fOutQuantity
,isnull(case when inventory.igrouptype=1 then DispatchLists.fOutQuantity/DispatchLists.iInvExchRate else DispatchLists.fOutNum end ,0) as fOutNum 
 From dbo.DispatchList  
 INNER JOIN DispatchLists ON DispatchList.DLID = DispatchLists.DLID 
 INNER JOIN Inventory ON DispatchLists.cInvCode = Inventory.cInvCode 
 INNER JOIN Warehouse ON DispatchLists.cWhCode = Warehouse.cWhCode 
 INNER JOIN ComputationUnit ON Inventory.cComUnitCode = ComputationUnit.cComunitCode 
 LEFT OUTER JOIN Department ON DispatchList.cDepCode = Department.cDepCode 
 LEFT OUTER JOIN ComputationUnit ComputationUnit_1 ON DispatchLists.cUnitID = ComputationUnit_1.cComunitCode 
 Left Join SA_SORowNo On Dispatchlists.isosid=SA_SORowNo.isosid 
 Left Join SaleType ON DispatchList.cStCode=SaleType.cstcode 
 left join vendor v1 on v1.cvencode =dispatchlists.cvmivencode 
 left join (select cpersoncode as cpersoncode2,cpersonname from person) person on person.cpersoncode2 =dispatchlist.cpersoncode  
 left join  SaleBillVouch on SaleBillVouch.SBVID = DispatchList.SBVID 
 left join VouchType on VouchType.cVouchType = case when  salebillvouch.SBVID is null then dispatchlist.cVouchType else salebillvouch.cVouchType end  
 WHERE  (DispatchList.cVouchType='05' OR DispatchList.cVouchType='06')  
 AND  ((ISNULL(DispatchList.cSaleOut,'') = '' OR isnull(bqaneedcheck,0)=1) OR DispatchList.cSaleOut ='ST')    
 AND not (isnull(DispatchList.bFirst,0) =1 And isnull(DispatchLists.bIsStQC,0) =0) 
 and (
	(ABS(ISNULL((case when (isnull(DispatchLists.bQANeedCheck,0)=1 and DispatchLists.iquantity>0) then DispatchLists.iqaquantity else DispatchLists.iquantity end ),0))-ABS(ISNULL(DispatchLists.fOutQuantity,0))    ) >=0.01 
	or ( igrouptype=2 and  (  ABS(ISNULL((case when (isnull(DispatchLists.bQANeedCheck,0)=1 and DispatchLists.iquantity>0) then DispatchLists.iqanum else DispatchLists.inum end ),0))-ABS(ISNULL(DispatchLists.fOutnum,0)) ) >=0.01)
	)
 AND (ISNULL(DispatchLists.cWhCode,'')<>'') 
 AND bInvType=0 
 AND bService=0  
 AND ((ISNULL(DispatchLists.bSettleAll,0)=0 and DispatchList.cvouchtype='05') or DispatchList.cvouchtype='06')  
and  ISNULL(DispatchList.cVerifier,'')<>''  
AND	DISPATCHLIST.CDLCODE = N'{0}' 
and	((case when isnull(DispatchLists.bQANeedCheck,0)=1 and isnull(DispatchLists.iquantity,0)>0 then DispatchLists.iqaquantity else DispatchLists.iquantity end) <>0  OR (case when isnull(DispatchLists.bQANeedCheck,0)=1  and isnull(DispatchLists.inum,0)>0 then DispatchLists.iqanum else DispatchLists.inum end) <>0) "    , cDLCode);

            try
            {
                dt = DBHelperSQL.QueryTable(connectionString, strSql);
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(dispatchList);
            }
            //转换子表
            DispatchLists dispatchLists = null;

            foreach (DataRow row in dt.Rows)
            {
                dispatchLists = EntityConvert.ConvertToDispatchLists(row);
                dispatchList.List.Add(dispatchLists);
            }

            return(dispatchList);
        }