Beispiel #1
0
        private void deliveryButton_Click(object sender, EventArgs e)
        {
            if (!harvestFlag)
            {
                MessageBox.Show("当前货物已确认收货,无法重复确认收货!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                return;
            }
            bool deli   = false;
            bool prompt = false;

            if (itemDataGridView.Rows.Count == 0)
            {
                MessageBox.Show("当前并无需要提交的收货单!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                return;
            }
            for (int i = 0; i < itemDataGridView.Rows.Count; i++)
            {
                if (Convert.ToInt32(itemDataGridView[5, i].Value) == 0)
                {
                    deli = true;
                }

                if (Convert.ToInt32(itemDataGridView[6, i].Value) != 0)
                {
                    prompt = true;
                }
            }
            if (deli || prompt)
            {
                string   sInput   = "";
                DGPrompt dGPrompt = new DGPrompt();
                if (dGPrompt.ShowDialog() == DialogResult.OK)
                {//
                    sInput = dGPrompt.inputMess;
                    //MessageBox.Show(sInput);
                }
                if (!sInput.Equals("y"))
                {
                    return;
                }
            }

            List <DailyReceiveGoods> list = new List <DailyReceiveGoods>();

            //确定收货
            for (int i = 0; i < itemDataGridView.RowCount; i++)
            {
                DailyReceiveGoods obj = new DailyReceiveGoods();
                DataGridViewRow   dc  = itemDataGridView.Rows[i];
                obj.Id                  = Guid.NewGuid().ToString().Replace("-", "");
                obj.CreateTime          = DateTime.Now;
                obj.UpdateTime          = DateTime.Now;
                obj.SerialNumber        = dc.Cells[0].Value.ToString();
                obj.Name                = dc.Cells[1].Value.ToString();
                obj.Classify            = dc.Cells[11].Value.ToString();
                obj.GoodsUnit           = dc.Cells[10].Value.ToString();
                obj.GoodsSpecifications = dc.Cells[9].Value.ToString();
                obj.GooodsPrice         = dc.Cells[2].Value.ToString();
                obj.Nums                = dc.Cells[3].Value.ToString();
                obj.ActualQuantity      = dc.Cells[5].Value == null ? "" : dc.Cells[5].Value.ToString();
                obj.OrderAmount         = dc.Cells[7].Value.ToString();
                obj.ReceiveAmount       = dc.Cells[8].Value == null ? "" : dc.Cells[8].Value.ToString();
                obj.sortenum            = dc.Cells[4].Value.ToString();
                obj.Salesman            = LoginUserInfo.id;
                obj.BranchId            = LoginUserInfo.branchId;
                obj.receiveDate         = DateTime.Now;
                list.Add(obj);
            }
            BranchDailyReceiveGoodsService branchservice = new BranchDailyReceiveGoodsService();

            //存入本地数据库
            branchservice.AddDailyReceiveGoods(list);

            //将全部订单改为待提货
            BranchZcOrderTransitService branchZcOrderTransitService = new BranchZcOrderTransitService();

            branchZcOrderTransitService.UpdateOrderStatus(Constant.ORDER_STATUS_RECEIPT);
            //将亭点收获标识更新为true
            DownloadIdentifyService downloadService = new DownloadIdentifyService();

            downloadService.UpdateHarvestFlag(Constant.HARVEST_YES);

            List <ZcOrderTransit> tranlist = branchZcOrderTransitService.FindAll();

            ///上传数据处理
            if (PingTask.IsConnected)
            {
                //上传每日收货数据
                DailyReceiveGoodsService service = new DailyReceiveGoodsService();
                service.AddDailyReceiveGoods(list);

                ZcOrderTransitService zcOderTransitService = new ZcOrderTransitService();
                zcOderTransitService.UpdateStatus(tranlist);
            }
            else
            {
                List <UploadInfo> uploadList = new List <UploadInfo>();
                foreach (DailyReceiveGoods obj in list)
                {
                    UploadInfo uploadInfo = new UploadInfo();
                    uploadInfo.Id         = obj.Id;
                    uploadInfo.CreateTime = DateTime.Now;
                    uploadInfo.UpdateTime = DateTime.Now;
                    uploadInfo.Type       = Constant.DAILY_RECEIVE_GOODS;
                    uploadList.Add(uploadInfo);
                }
                foreach (ZcOrderTransit obj in tranlist)
                {
                    UploadInfo uploadInfo = new UploadInfo();
                    uploadInfo.Id         = obj.Id;
                    uploadInfo.CreateTime = DateTime.Now;
                    uploadInfo.UpdateTime = DateTime.Now;
                    uploadInfo.Type       = Constant.ZC_ORDER_TRANSIT_UPDATE;
                    uploadList.Add(uploadInfo);
                }

                UploadDao uploadDao = new UploadDao();
                uploadDao.AddUploadInfo(uploadList);
            }


            MessageBox.Show("收货成功!");
            this.branchMain.Show();
            this.Close();
        }
Beispiel #2
0
        /// <summary>
        /// 网络连通时,上传数据
        /// </summary>
        public static void Upload()
        {
            UploadDao dao   = new UploadDao();
            int       count = dao.QueryCount();

            if (count != 0)
            {
                List <UploadInfo> list = dao.FindAll();
                foreach (UploadInfo obj in list)
                {
                    if (obj.Type == Constant.DAILY_RECEIVE_GOODS)
                    {
                        BranchDailyReceiveGoodsDao dailyDao = new BranchDailyReceiveGoodsDao();
                        DailyReceiveGoods          drg      = dailyDao.FindById(obj.Id);
                        drg.CreateTime = DateTime.Now;
                        drg.UpdateTime = DateTime.Now;
                        DailyReceiveGoodsService service = new DailyReceiveGoodsService();
                        bool flag = service.AddDailyReceiveGoods(drg);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_TRANSIT_UPDATE)
                    {
                        ZcOrderTransitService service = new ZcOrderTransitService();
                        bool flag = service.UpdateStatus(obj.Id, Constant.ORDER_STATUS_RECEIPT);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.PAY_INFO)
                    {
                        BranchPayInfoService service = new BranchPayInfoService();
                        PayInfo        payInfo       = service.FindById(obj.Id);
                        PayInfoService masterService = new PayInfoService();
                        bool           flag          = masterService.AddPayInfoI(payInfo);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_HISTORY)
                    {
                        BranchZcOrderHistoryService branchService = new BranchZcOrderHistoryService();
                        ZcOrderHistory        history             = branchService.FindById(obj.Id);
                        ZcOrderHistoryService service             = new ZcOrderHistoryService();
                        bool flag = service.AddZcOrderHistoryI(history);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_HISTORY_ITEM)
                    {
                        BranchZcOrderHistoryItemService branchService = new BranchZcOrderHistoryItemService();
                        ZcOrderHistoryItem        item    = branchService.FindById(obj.Id);
                        ZcOrderHistoryItemService service = new ZcOrderHistoryItemService();
                        bool flag = service.AddZcOrderHistoryItemI(item);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_TRANSIT_DELETE)
                    {
                        ZcOrderTransitService service = new ZcOrderTransitService();
                        bool flag = service.DeleteById(obj.Id);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_TRANSIT_ITEM_DELETE)
                    {
                        ZcOrderTransitItemService service = new ZcOrderTransitItemService();
                        bool flag = service.DeleteByOrderIdI(obj.Id);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_REFUSE)
                    {
                        BranchZcOrderRefuseService branchService = new BranchZcOrderRefuseService();
                        ZcOrderRefuse        refuse  = branchService.FindById(obj.Id);
                        ZcOrderRefuseService service = new ZcOrderRefuseService();
                        bool flag = service.AddZcOrderRefuseI(refuse);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_REFUSE_ITEM)
                    {
                        BranchZcOrderRefuseItemService branchService = new BranchZcOrderRefuseItemService();
                        ZcOrderRefuseItem        item    = branchService.FindById(obj.Id);
                        ZcOrderRefuseItemService service = new ZcOrderRefuseItemService();
                        bool flag = service.AddZcOrderRefuseItemI(item);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_REFUND)
                    {
                        BranchZcOrderRefundService branchService = new BranchZcOrderRefundService();
                        ZcOrderRefund     refund  = branchService.FindById(obj.Id);
                        RefundInfoService service = new RefundInfoService();
                        bool flag = service.AddZcOrderRefundI(refund);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_REFUND_ITEM)
                    {
                        BranchZcOrderRefundItemService branchService = new BranchZcOrderRefundItemService();
                        ZcOrderRefundItem item    = branchService.FindById(obj.Id);
                        RefundInfoService service = new RefundInfoService();
                        bool flag = service.AddZcOrderRefundItemI(item);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                    else if (obj.Type == Constant.ZC_ORDER_HISTORY_UPDATE)
                    {
                        BranchZcOrderHistoryService branchService = new BranchZcOrderHistoryService();
                        ZcOrderHistory        history             = branchService.FindById(obj.Id);
                        ZcOrderHistoryService service             = new ZcOrderHistoryService();
                        bool flag = service.UpdateOrderStatusByIdsI(obj.Id, history.OrderStatus);
                        if (flag)
                        {
                            dao.DeleteByIdAndType(obj.Id, obj.Type);
                        }
                    }
                }
            }
        }