コード例 #1
0
ファイル: FrmSOLoadingNew.cs プロジェクト: uwitec/wms-1
        /// <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);
        }
コード例 #2
0
        /// <summary>
        /// 打印销售发货单
        /// </summary>
        public void PrintSO()
        {
            if (this.List == null || this.List.Count == 0)
            {
                MsgBox.Warn("请查询要打印的车辆信息。");
                return;
            }
            string billNOs = GetBillNOS(ConvertUtil.ToInt(row["ID"]));

            if (!string.IsNullOrEmpty(billNOs))
            {
                MsgBox.Warn("订单:" + billNOs + " 拣货任务未完成!");
                return;
            }
            DataTable ctCanTDT = GetCtCodeCanT(ConvertUtil.ToInt(row["ID"]));

            if (ctCanTDT.Rows.Count > 0)
            {
                FrmSoWeightCanT frmsoWeigheCant = new FrmSoWeightCanT(ctCanTDT);
                frmsoWeigheCant.StartPosition = FormStartPosition.CenterScreen;
                frmsoWeigheCant.Show();
                return;
            }
            //if (GlobeSettings.LoginedUser.WarehouseType == EWarehouseType.整货仓 &&
            //    this.List.Exists(u => u.SyncState < 5 && u.CaseBoxNum > 0))
            //{
            //    MsgBox.Warn("当前车次还有订单的物流箱未接收!");
            //    return;
            //}
            //if (this.List.Exists(u => u.Status != "66" && u.Status != "691"))
            //{
            //    MsgBox.Warn("当前装车信息中包含未称重的订单,请先称重后再执行此操作!");
            //    return;
            //}
            LoadingHeaderEntity loadingHeader = this.searchLookUpEdit2.EditValue as LoadingHeaderEntity;

            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;
            }
            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);
            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();
                    Print.sellorder sellOrder = new Print.sellorder();

                    foreach (SOHeaderEntity header in this.List)
                    {
                        try
                        {
                            //更新打印标记为已打印
                            UpdatePrintedFlag(header.BillID, GlobeSettings.LoginedUser.UserName, header.BillNO, 2);
                            for (int i = 0; i < 2; i++)
                            {
                                sellOrder.printorder(string.Format("{0}#{1}",
                                                                   GlobeSettings.LoginedUser.WarehouseName, header.BillNO));
                                Thread.Sleep(200);
                            }
                        }
                        catch (Exception exp)
                        {
                            // 屏蔽打印时的错误
                            MsgBox.Err(string.Format(
                                           @"订单:{0} 打印过程中出现错误,请将错误信息提交给供应链相关同事!\r\n异常信息:{1} ",
                                           header.BillNO, string.Format("{0}\r\n{1}", exp.Message, exp.StackTrace)));
                        }
                        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);
                        //}

                        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);
        }