Beispiel #1
0
        //========================================第一个接口=======================================================
        /// <summary>
        ///
        /// </summary>
        public static void DiYigeJieKou(RednotificationInfo redInfo)
        {
            //获取开票软件主窗体
            var kprjBar = GetKprjMainPageBar();

            if (kprjBar == IntPtr.Zero)
            {
                return;
            }
            //前置主窗体
            ShowForm(kprjBar);

            var kprjToolBar = WinApi.FindChildInfo(kprjBar)[0].hWnd;

            //1:点击发票管理
            ClickBtnByName(kprjToolBar, "发票管理");

            Thread.Sleep(1000);

            //2:主界面进入 - 增值税专用发票信息表填开
            var kprjToolBar2 = WinApi.FindChildInfo(kprjBar)[1].hWnd;

            InvokeMenuItem(kprjToolBar2, "红字增值税专用发票信息表填开");

            //3:操作-增值税专用发票信息表填开
            if (!RedInfoTianKai(redInfo))
            {
                //日志--操作增值税专用发票信息表填开页面失败
            }

            //4:操作红字发票信息表填开--里面有明细
            if (!RedInfoFpTianKai(kprjBar, redInfo, out var hzbm))
            {
                //日志--红字信息填开失败
            }
            //5:点击打印--选择不打印
            DaYin();
            //6:点击取消
            SystemOpera("取消");

            Thread.Sleep(1000);

            //7:进入查询导出页面
            InvokeMenuItem(kprjToolBar2, "红字增值税专用发票信息表查询导出");

            //8:上传红字信息表
            UploadHzInfo(kprjBar, hzbm);

            //9:等待信息表上传
            if (!WaitLoadingForm("信息表上传中"))
            {
                //throw new Exception("信息表上传失败");
                Console.WriteLine("信息表上传错误");
            }

            //10:获取对应的红字信息
            var entity = DateBaseHelper.GetHzscResult(hzbm);

            Console.WriteLine("success...");
        }
Beispiel #2
0
        /// <summary>
        /// 红字发票信息表填开--填写红字信息表
        /// </summary>
        /// <returns></returns>
        public static bool RedInfoFpTianKai(IntPtr kprjBar, RednotificationInfo redInfoEntity, out string hzbm)
        {
            hzbm = "";
            if (kprjBar == IntPtr.Zero)
            {
                //日志---开票软件句柄获取失败
                return(false);
            }
            var hzxxtklist = new List <WindowInfo>();

            //红字信息编码
            TryRetry <IntPtr, bool>(b =>
            {
                //获取开票软件下面的所有子句柄
                var kprjList = WinApi.EnumChildWindowsCallback(kprjBar);
                //获取红字信息填开句柄--模糊查询
                var hzxxtkBar = kprjList.Find(bar =>
                                              bar.szWindowName != null && bar.szWindowName.Contains("红字发票信息表填开"));
                hzxxtklist = WinApi.FindChildInfo(hzxxtkBar.hWnd);
                return(hzxxtkBar.hWnd != IntPtr.Zero && hzxxtklist.Count >= 5);
            }, kprjBar, 20, 500);

            if (hzxxtklist.Count < 5)
            {
                //日志--句柄查找错误
                return(false);
            }

            //销方申请进来的--已经填写完毕直接返回就好
            if (redInfoEntity.notificationHead.RequestMemo.Trim() == "2")
            {
                return(true);
            }

            //三个--最后一个对应toolBar
            var hzxxtkInfoList  = WinApi.FindChildInfo(hzxxtklist[0].hWnd);
            var hzxxtkInfoChild = WinApi.FindChildInfo(hzxxtkInfoList[2].hWnd);
            var sfxxlist        = WinApi.FindChildInfo(hzxxtkInfoChild[1].hWnd);
            var toolBar         = hzxxtklist[hzxxtklist.Count - 1].hWnd;

            //对销方名称进行赋值
            var mclist = WinApi.FindChildBar(sfxxlist[1].hWnd);

            mclist.ForEach(mc => WinApi.SendMessage(mc, 0x0C, IntPtr.Zero, "名称测试"));

            //对纳税人识别号进行赋值
            var bmlist = WinApi.FindChildBar(sfxxlist[0].hWnd);

            bmlist.ForEach(mc => WinApi.SendMessage(mc, 0x0C, IntPtr.Zero, "12345678901234567"));

            var taxKind = redInfoEntity.notificationHead.TaxKind.Trim();

            if (taxKind != "2" && taxKind != "0")
            {
                //日志--没有该业务场景
                return(false);
            }

            //差额逻辑
            if (taxKind == "2")
            {
                if (redInfoEntity.notificationDetails?.Count != 1)
                {
                    //日志--差额征收--明细只能有一行
                    return(false);
                }
                ClickBtnByName(toolBar, "差额");
                if (!ChaEPage("100"))
                {
                    //日志--扣除额界面过度失败
                    return(false);
                }
                Thread.Sleep(200);
                //不含税
                ClickBtnByName(toolBar, "价格");
            }

            //获取table数据句柄
            var dataBar = WinApi.FindWindowEx(hzxxtklist[0].hWnd, IntPtr.Zero, null, null);

            dataBar = WinApi.FindWindowEx(dataBar, IntPtr.Zero, null, null);

            //填开数据---分类编码设置还没有走通--需要测试
            if (!RedInfoFpTianKaiData(dataBar, toolBar, redInfoEntity.notificationDetails))
            {
                //--日志数据填写异常
                return(false);
            }
            //获取税号
            var hzshList = WinApi.FindChildInfo(hzxxtklist[3].hWnd);

            hzbm = hzshList[1].szWindowName;
            //点击打印
            ClickBtnByName(toolBar, "打印");
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 操作增值税专用发票信息表填开页面
        /// </summary>
        /// <param name="redInfoEntity"></param>
        /// <returns></returns>
        public static bool RedInfoTianKai(RednotificationInfo redInfoEntity)
        {
            var zhuanRedBar = TryRetry <string, IntPtr>(
                str => WinApi.FindWindow(null, str), "红字增值税专用发票信息表信息选择",
                20, 500);

            if (zhuanRedBar == IntPtr.Zero)
            {
                //日志--红字增值税专用发票信息表信息选择查找失败
                return(false);
            }
            //等待组件加载
            Thread.Sleep(500);

            var purchaserApplicationBar = new WindowInfo();
            var salesAllicationBar      = new WindowInfo();
            var deductedBar             = new WindowInfo();
            var unDeductedBar           = new WindowInfo();
            var fpInputBar    = new WindowInfo();
            var confirmBtnBar = new WindowInfo();
            var nextStepBar   = new WindowInfo();

            var flag = TryRetry <IntPtr, bool>(bar =>
            {
                var list = WinApi.EnumChildWindowsCallback(bar);
                purchaserApplicationBar = list.Find(b => b.szWindowName == "一、购买方申请");
                salesAllicationBar      = list.Find(b => b.szWindowName == "二、销售方申请");
                deductedBar             = list.Find(b => b.szWindowName == "1、已抵扣");
                unDeductedBar           = list.Find(b => b.szWindowName == "2、未抵扣");
                fpInputBar    = list.Find(b => b.szWindowName == "对应蓝字增值税专用发票信息");
                confirmBtnBar = list.Find(b => b.szWindowName == "确定");
                nextStepBar   = list.Find(b => b.szWindowName == "下一步");
                if (purchaserApplicationBar.hWnd == IntPtr.Zero || salesAllicationBar.hWnd == IntPtr.Zero ||
                    confirmBtnBar.hWnd == IntPtr.Zero || nextStepBar.hWnd == IntPtr.Zero ||
                    deductedBar.hWnd == IntPtr.Zero || unDeductedBar.hWnd == IntPtr.Zero || fpInputBar.hWnd == IntPtr.Zero)
                {
                    return(false);
                }

                return(true);
            }, zhuanRedBar, 20, 500);

            if (!flag)
            {
                //日志--句柄获取失败,打印上述句柄
                return(false);
            }

            //销方申请
            if (redInfoEntity.notificationHead.RequestMemo.Trim() == "2")
            {
                WinApi.LeftClick(salesAllicationBar.hWnd);
                Thread.Sleep(1000);
                var FpInputList = WinApi.FindChildBar(fpInputBar.hWnd);
                WinApi.SendMessage(FpInputList[0], 0X0C, IntPtr.Zero, "02038375");   //发票号码
                Thread.Sleep(100);
                WinApi.SendMessage(FpInputList[1], 0X0C, IntPtr.Zero, "4400081140"); //发票代码
                Thread.Sleep(500);
                WinApi.LeftClick(nextStepBar.hWnd);
                if (!RedInfoConfirm(zhuanRedBar))
                {
                    //日志--不能开具红字专票
                    return(false);
                }
                return(true);
            }

            //购方申请
            WinApi.LeftClick(purchaserApplicationBar.hWnd);
            Thread.Sleep(100);

            //未抵扣
            if (redInfoEntity.notificationHead.RequestMemo.Trim() == "0")
            {
                WinApi.LeftClick(deductedBar.hWnd);
            }

            //已抵扣
            if (redInfoEntity.notificationHead.RequestMemo.Trim() == "1")
            {
                WinApi.LeftClick(unDeductedBar.hWnd);
                Thread.Sleep(500);

                var fpInputList = WinApi.FindChildBar(fpInputBar.hWnd);
                WinApi.SendMessage(fpInputList[0], 0X0C, IntPtr.Zero, "0203837");    //发票号码
                Thread.Sleep(100);
                WinApi.SendMessage(fpInputList[1], 0X0C, IntPtr.Zero, "4400081140"); //发票代码
            }

            Thread.Sleep(500);
            //点击确定按钮
            WinApi.LeftClick(confirmBtnBar.hWnd);

            return(true);
        }