Ejemplo n.º 1
0
        /// <summary>
        /// 打印销售发货单
        /// </summary>
        public void PrintSO()
        {
            if (this.List == null || this.List.Count == 0)
            {
                MsgBox.Warn("请查询要打印的车辆信息。");
                return;
            }

            LoadingHeaderEntity loadingHeader = this.searchLookUpEdit2.EditValue as LoadingHeaderEntity;

            if (GlobeSettings.LoginedUser.WarehouseType == EWarehouseType.整货仓)
            {
                if (!GetSyncCodeCanT(ConvertUtil.ToInt(row["ID"]), loadingHeader.LoadingNO))
                    return;
            }

            DataTable ctCanTDT = GetCtCodeCanT(ConvertUtil.ToInt(row["ID"]), loadingHeader.LoadingNO);
            if (ctCanTDT.Rows.Count > 0)
            {
                FrmSoWeightCanT frmsoWeigheCant = new FrmSoWeightCanT(ctCanTDT);
                frmsoWeigheCant.StartPosition = FormStartPosition.CenterScreen;
                frmsoWeigheCant.Show();
                return;
            }

            if (loadingHeader == null)
            {
                MsgBox.Warn("未找到装车信息,请联系技术人员!");
                return;
            }
            // 验证当前选择的装车信息是否有选择人员
            List<LoadingUserEntity> loadingUsers = GetLoadingInfoByNonChooseUser(loadingHeader.LoadingNO);
            if (loadingUsers == null || loadingUsers.Count == 0)
            {
                MsgBox.Warn(string.Format("装车编号:{0} 未选择装车人员,请选择装车人员后再打印销售发货单;", loadingHeader.LoadingNO));
                return;
            }
            if (MsgBox.AskOK(string.Format("确定打印该车辆的销售发货单?")) != DialogResult.OK)
                return;
            // 选择司机和助理信息
            //FrmChoosePersonnel frm = new FrmChoosePersonnel(true);
            FrmPersonChoosen frm = new FrmPersonChoosen();
            if (frm.ShowDialog() != DialogResult.OK)
                return;

            bool ret = CreateTrain(
                GlobeSettings.LoginedUser.WarehouseCode,
                GlobeSettings.LoginedUser.UserName,
                row["VH_NO"].ToString(),
                frm.SelectedPersonnel.UserName,
                frm.SelectedPersonnel.MobilePhone,
                this.List,
                frm.SelectedPersonnelList,
                GlobeSettings.LoginedUser.WarehouseType,
                loadingHeader.LoadingNO);
            if(!ret)
            {
                MsgBox.Warn("生成车次信息失败,请重新生成!!!");
                return;
            }

            List<int> tempBillIDs = new List<int>();
            try
            {
                using (WaitDialogForm wait = new WaitDialogForm("正在打印,请稍侯..."))
                {

                    int pick_suit_type = ConvertUtil.ToInt(GlobeSettings.SystemSettings["套餐分拣方式"]);
                    string module = "打印销售发货单";
                    //sb = new StringBuilder();
                    NewPrint.sellorder sellOrder = new NewPrint.sellorder();
                    foreach (SOHeaderEntity header in this.List)
                    {
                        int printInt = 2;
                        try
                        {
                            for (int i = 0; i < printInt; i++)
                            {
                                sellOrder.printorder(string.Format("{0}#{1}",
                                    GlobeSettings.LoginedUser.WarehouseName, header.BillNO));
                                Thread.Sleep(200);
                            }
                        }
                        catch
                        {
                            // 屏蔽打印时的错误
                        }
                        Insert(ELogType.打印, GlobeSettings.LoginedUser.UserName, header.BillNO, header.BillTypeName, this.Text, row["VH_NO"].ToString());
                        InsertSOLog(header.BillID, ESOOperationType.已打印销售发货单.ToString(), GlobeSettings.LoginedUser.UserName);
                        //List<ReturnHeaderEntity> listReturn = this.returnDal.GetReturnBill(header.CustomerCode);
                        //foreach (ReturnHeaderEntity entity in listReturn)
                        //{
                        //    RepReturn repReturn = new RepReturn(entity.BillID, 1, module);
                        //    //repReturn.ShowPreviewDialog();
                        //    for (int i = 0; i < 3; i++)
                        //    {
                        //        Thread.Sleep(50);
                        //        repReturn.Print();
                        //    }
                        //    //更新打印标记为已打印、把对应的送货单号写入退货单
                        //    this.returnDal.UpdatePrintedFlag(entity.BillID, header.BillNO, header.ShipNO);
                        //}
                        //更新打印标记为已打印
                        UpdatePrintedFlag(header.BillID, GlobeSettings.LoginedUser.UserName, header.BillNO, printInt);
                        header.Printed = 1;
                        UpdateContainerState(header.BillID);
                    }
                    // 打印完成以后,修改车次的同步状态为1、更新整散数量
                    //LoadingDal.UpdateTrainInfo(trainNo, StringUtil.JoinBySign<int>(tempBillIDs, ""), GlobeSettings.LoginedUser.WarehouseType);
                    //CreateTrainLoading();
                }
                //OnbtnQueryClick(null, null);
            }
            catch (Exception ex)
            {
                MsgBox.Err("打印时遇到错误:" + ex.Message);
            }
            this.searchLookUpEdit1_EditValueChanged(this.searchLookUpEdit1, EventArgs.Empty);
        }
Ejemplo n.º 2
0
        public void PrintSO()
        {
            List <SOHeaderEntity> focusedBills = IParent.GetFocusedBills();

            if (focusedBills.Count == 0)
            {
                MsgBox.Warn("请选中要打印的单据。");
                return;
            }
            foreach (SOHeaderEntity entity in focusedBills)
            {
                int status = ConvertUtil.ToInt(entity.Status);
                if (status != 68 && status != 693)
                {
                    MsgBox.Warn(String.Format("只有订单状态为<发货完成>或<已发车>后才能在此打印单据。"));
                    return;
                }
            }

            if (MsgBox.AskOK(string.Format("一共选中了“{0}”个单据“{1}”,确定要开始打印吗?",
                                           focusedBills.Count, GetBillNOs(focusedBills))) != DialogResult.OK)
            {
                return;
            }
            SOBody dataSource = null;
            //CompanyEntity company = new CompanyDal().GetCompanys()[0];        whc 2016-11-14 16:32:43
            bool   printed        = false;
            int    pick_suit_type = ConvertUtil.ToInt(GlobeSettings.SystemSettings["套餐分拣方式"]);
            string module         = "出库单管理";

            NewPrint.sellorder sellOrder = new NewPrint.sellorder();
            //sellOrder.printorder(string.Format("{0}#{1}", GlobeSettings.LoginedUser.WarehouseName, StringUtil.JoinBySign<SOHeaderEntity>(focusedBills, "BillNO", ";")));
            //return;
            foreach (SOHeaderEntity header in focusedBills)
            {
                sellOrder.printorder(string.Format("{0}#{1}",
                                                   GlobeSettings.LoginedUser.WarehouseName, header.BillNO));
                #region 现已不采用
                //dataSource = new SOBody();
                //#region 采购退货注释
                ////if (header.BillType == "124")
                ////{
                ////    if (header.Status == BaseCodeConstant.SO_STATUS_CLOSE)  // 如果状态为“发货完成”,打印单据
                ////    {
                ////        dataSource.Header = header;
                ////        dataSource.CompanyInfo = company;
                ////        dataSource.ReportDetails = soDal.GetDetailsForPrint(header.BillID);

                ////        RepAsnReturn repSO = new RepAsnReturn(dataSource);
                ////        //repSO.ShowPreviewDialog();
                ////        repSO.Print();
                ////        printed = true;
                ////    }
                ////    else
                ////    {
                ////        MsgBox.Warn(string.Format("单据:{0} 发货完成后才能打印。"));
                ////    }
                ////}
                ////else
                ////{
                //#endregion
                //dataSource.Header = header;
                //dataSource.CompanyInfo = company;
                //dataSource.ReportDetails = soDal.GetDetailsForPrint(header.BillID, pick_suit_type);
                //dataSource.ReportDetailAttri = soDal.GeDetailAttri(header.BillID);   // 该订单所有优惠券
                //XtraReport repSO = null;
                //if (header.BillType == "121" || header.BillType == "122" || header.BillType == "123")
                //{
                //    repSO = new RepSOTransfer(dataSource, module);
                //}
                //else if (header.BillType == "125")
                //{
                //    repSO = new RepSOBreakage(dataSource, module);
                //}
                //else if (pick_suit_type == 0)
                //{
                //    repSO = new RepSO_New(dataSource, module);
                //}
                //else if (pick_suit_type == 1)
                //{
                //    repSO = new RepSO_New2(dataSource, module);
                //}
                //repSO.ShowPreviewDialog();
                ////repSO.Print();
                #endregion
                printed = true;
                //}
                if (printed)
                {
                    //更新打印标记为已打印
                    UpdatePrintedFlag(header.BillID, GlobeSettings.LoginedUser.UserName, header.BillNO, 0);
                    header.Printed = 1;
                    //Insert(ELogType.打印, GlobeSettings.LoginedUser.UserName, header.BillNO, header.BillTypeName, "出库单管理");
                }
            }

            IParent.RefreshHeaderGrid();
        }