예제 #1
0
        //税收分类编码添加
        public static void WriteGoodsTaxNoAdd(IntPtr goodNoAddHw, string goodsTaxNo = "")
        {
            //税收分类编码
            var ssflbmBar = IntPtr.Zero;
            var toolStrip = IntPtr.Zero;

            var flag = HxShengQing.TryRetry(str =>
            {
                var childInfos = WinApi.FindChildInfo(goodNoAddHw);
                if (childInfos == null || childInfos.Count < 30)
                {
                    return(false);
                }

                //获取分类名称
                var flmnBar = childInfos.Find(b => b.szWindowName == "税收分类名称").hWnd;
                var temp1   = WinApi.FindWindowEx(goodNoAddHw, flmnBar, null, null);
                var temp2   = WinApi.FindWindowEx(temp1, IntPtr.Zero, null, null);
                ssflbmBar   = WinApi.FindWindowEx(temp1, temp2, null, null);

                //获取toolStrip
                toolStrip = childInfos.Find(b => b.szWindowName == "toolStrip1").hWnd;


                return(ssflbmBar != IntPtr.Zero && toolStrip != IntPtr.Zero);
            }, "", 40, 500);

            WinApi.SendMessage(ssflbmBar, WinApi.BM_TEXT, IntPtr.Zero, TaxSub(goodsTaxNo));
            Thread.Sleep(500);

            HxShengQing.ClickBtnByName(toolStrip, "保存");
        }
예제 #2
0
        /// <summary>
        /// 操作红字增值税专用发票信息表信息选择
        /// </summary>
        public static void Step2()
        {
            var zhuanRedBar = IntPtr.Zero;

            zhuanRedBar = HxShengQing.TryRetry <string, IntPtr>(
                str => WinApi.FindWindow(null, str), "红字增值税专用发票信息表信息选择",
                20, 500);
            if (zhuanRedBar == IntPtr.Zero)
            {
                //日志--红字增值税专用发票信息表信息选择查找失败
                return;
            }

            Thread.Sleep(500);

            HxShengQing.TryRetry <IntPtr, bool>(bar =>
            {
                var list = WinApi.EnumChildWindowsCallback(bar);
                var PurchaserApplicationBar = list.Find(b => b.szWindowName == "一、购买方申请");
                var SalesAllicationBar      = list.Find(b => b.szWindowName == "二、销售方申请");
                var DeductedBar             = list.Find(b => b.szWindowName == "1、已抵扣");
                var UnDeductedBar           = list.Find(b => b.szWindowName == "2、未抵扣");
                var FpInputBar = list.Find(b => b.szWindowName == "对应蓝字增值税专用发票信息");
                if (PurchaserApplicationBar.hWnd == IntPtr.Zero || SalesAllicationBar.hWnd == IntPtr.Zero ||
                    DeductedBar.hWnd == IntPtr.Zero || UnDeductedBar.hWnd == IntPtr.Zero || FpInputBar.hWnd == IntPtr.Zero)
                {
                    return(false);
                }

                //这里是判断条件--真实业务的时候添加
                Thread.Sleep(1000);
                WinApi.LeftClick(SalesAllicationBar.hWnd);//点击rediobutton
                Thread.Sleep(1000);

                var FpInputList = WinApi.FindChildBar(FpInputBar.hWnd);
                WinApi.SendMessage(FpInputList[0], 0X0C, IntPtr.Zero, "123456"); //发票号码
                WinApi.SendMessage(FpInputList[1], 0X0C, IntPtr.Zero, "654321"); //发票代码


                //Thread.Sleep(1000);
                //WinApi.LeftClick(PurchaserApplicationBar.hWnd);
                //Thread.Sleep(1000);
                //WinApi.LeftClick(DeductedBar.hWnd);
                //Thread.Sleep(1000);
                //WinApi.LeftClick(UnDeductedBar.hWnd);

                return(true);
            }, zhuanRedBar, 20, 500);
        }
예제 #3
0
        public static void WriteGoodsTaxNoAdd(IntPtr goodNoAddHw, RednotificationDetail detail)
        {
            if (detail == null)
            {
                detail = new RednotificationDetail()
                {
                    GoodsTaxNo = "101010102",
                    TaxPer     = "1",
                    TaxPerCon  = "不征税",
                    TaxRate    = "0.17"
                };
            }
            if (goodNoAddHw == IntPtr.Zero)
            {
                return;
            }

            //税收分类编码
            var ssflbmBar = IntPtr.Zero;
            var toolStrip = IntPtr.Zero;
            var suilvBar  = IntPtr.Zero;
            var yhBar     = IntPtr.Zero;
            var yhlBar    = IntPtr.Zero;

            HxShengQing.TryRetry(str =>
            {
                var childInfos = WinApi.FindChildInfo(goodNoAddHw);
                if (childInfos == null || childInfos.Count < 30)
                {
                    return(false);
                }

                //获取分类名称
                var flmnBar = childInfos.Find(b => b.szWindowName == "税收分类名称").hWnd;
                var temp1   = WinApi.FindWindowEx(goodNoAddHw, flmnBar, null, null);
                var temp2   = WinApi.FindWindowEx(temp1, IntPtr.Zero, null, null);
                ssflbmBar   = WinApi.FindWindowEx(temp1, temp2, null, null);

                //获取toolStrip
                toolStrip = childInfos.Find(b => b.szWindowName == "toolStrip1").hWnd;

                //获取税率句柄
                var suilv = childInfos.Find(b => b.szWindowName == "*税率").hWnd;
                suilvBar  = WinApi.FindWindowEx(goodNoAddHw, suilv, null, null);

                //获取享受优惠政策
                var yh = childInfos.Find(b => b.szWindowName == "规格型号").hWnd;
                yhBar  = WinApi.FindWindowEx(goodNoAddHw, yh, null, null);

                //优惠政策类型
                yhlBar = childInfos[8].hWnd;

                return(ssflbmBar != IntPtr.Zero && toolStrip != IntPtr.Zero &&
                       suilvBar != IntPtr.Zero && yhBar != IntPtr.Zero && yhlBar != IntPtr.Zero);
            }, "", 20, 500);

            if (ssflbmBar == IntPtr.Zero || toolStrip == IntPtr.Zero ||
                suilvBar == IntPtr.Zero || yhBar == IntPtr.Zero || yhlBar == IntPtr.Zero)
            {
                throw new Exception("商品编码窗体,句柄获取失败");
            }

            WinApi.SendMessage(ssflbmBar, WinApi.BM_TEXT, IntPtr.Zero, TaxSub(detail.GoodsTaxNo));
            Thread.Sleep(100);
            WinApi.SendKey(ssflbmBar, WinApi.VK_DOWN);
            Thread.Sleep(100);
            WinApi.SendKey(ssflbmBar, WinApi.VK_RETURN);
            Thread.Sleep(100);
            WinApi.ClickLocation(goodNoAddHw, 300, 10);
            Thread.Sleep(500);

            if ("1".Equals(detail.TaxPer) && !string.IsNullOrEmpty(detail.TaxPerCon))
            {
                UIHelper.SetCombox(yhBar, "是");

                //等待优惠政策enable
                Thread.Sleep(1000);
                UIHelper.SetCombox(yhlBar, detail.TaxPerCon.Trim());
            }
            else
            {
                UIHelper.SetCombox(suilvBar, GetByTaxRate(detail.TaxRate));
            }

            ClickBtnByName(toolStrip, "保存");
            Thread.Sleep(500);
        }
예제 #4
0
        public static void WriteGoodsSetting(IntPtr goodNoSettingHw, RednotificationDetail detail)
        {
            if (goodNoSettingHw == IntPtr.Zero)
            {
                return;
            }

            if (detail == null)
            {
                detail = new RednotificationDetail()
                {
                    GoodsTaxNo = "101010102",
                    //TaxPer = "1",
                    TaxPerCon = "不征税",
                    TaxRate   = "0.17"
                };
            }

            var suilvBar  = IntPtr.Zero;
            var yhBar     = IntPtr.Zero;
            var yhlBar    = IntPtr.Zero;
            var toolStrip = IntPtr.Zero;

            HxShengQing.TryRetry(str =>
            {
                var childInfos = WinApi.FindChildInfo(goodNoSettingHw);
                if (childInfos == null || childInfos.Count < 11)
                {
                    return(false);
                }

                //获取toolStrip
                toolStrip = childInfos.Find(b => b.szWindowName == "toolStrip1").hWnd;

                //税率句柄
                suilvBar = childInfos[10].hWnd;

                //享受优惠政策
                yhBar = childInfos[8].hWnd;

                //优惠政策类型
                yhlBar = childInfos[5].hWnd;

                return(toolStrip != IntPtr.Zero && suilvBar != IntPtr.Zero &&
                       yhBar != IntPtr.Zero && yhlBar != IntPtr.Zero);
            }, "", 20, 500);

            if ("1".Equals(detail.TaxPer) && !string.IsNullOrEmpty(detail.TaxPerCon))
            {
                UIHelper.SetCombox(yhBar, "是");

                //等待优惠政策enable
                Thread.Sleep(1000);
                UIHelper.SetCombox(yhlBar, detail.TaxPerCon.Trim());
            }
            else
            {
                UIHelper.SetCombox(suilvBar, GetByTaxRate(detail.TaxRate));
            }

            ClickBtnByName(toolStrip, "保存");
            Thread.Sleep(1000);

            HxShengQing.SystemOpera("确认", out var message);
            if (message != "修改成功!")
            {
                throw new Exception(message);
            }
        }
예제 #5
0
        /// <summary>
        /// 蓝字发票校验页面过度
        /// </summary>
        public static void lanzifapiaoguodu()
        {
            var blueInvoiceInputtHw = HxShengQing.TryRetry(str => WinApi.FindWindow(null, str), "销项正数发票代码号码填写、确认");

            var fapiaodaimaBar1 = IntPtr.Zero;
            var fapiaodaimaBar2 = IntPtr.Zero;
            var fapiaohaomaBar1 = IntPtr.Zero;
            var fapiaohaomaBar2 = IntPtr.Zero;
            var nextStepBar     = IntPtr.Zero;


            var flag = HxShengQing.TryRetry(bar =>
            {
                var list    = WinApi.EnumChildWindowsCallback(bar);
                nextStepBar = list.Find(b => b.szWindowName == "下一步").hWnd;

                var tabPage2 = list.Find(b => b.szWindowName == "tabPage2").hWnd;
                var childs   = WinApi.FindChildBar(tabPage2);

                fapiaodaimaBar1 = childs[6];
                fapiaodaimaBar2 = childs[0];
                fapiaohaomaBar1 = childs[3];
                fapiaohaomaBar2 = childs[1];

                if (fapiaodaimaBar1 == IntPtr.Zero || fapiaodaimaBar2 == IntPtr.Zero ||
                    fapiaohaomaBar1 == IntPtr.Zero ||
                    fapiaohaomaBar2 == IntPtr.Zero || nextStepBar == IntPtr.Zero)
                {
                    return(false);
                }
                return(true);
            }, blueInvoiceInputtHw);

            if (!flag)
            {
                throw new Exception("xxxx:蓝字发票校验页面句柄查找错误");
            }

            WinApi.SendMessage(fapiaodaimaBar1, 0X0C, IntPtr.Zero, "4400154620");
            Thread.Sleep(100);
            WinApi.SendMessage(fapiaodaimaBar2, 0X0C, IntPtr.Zero, "4400154620");
            Thread.Sleep(100);
            WinApi.SendMessage(fapiaohaomaBar1, 0X0C, IntPtr.Zero, "51365035");
            Thread.Sleep(100);
            WinApi.SendMessage(fapiaohaomaBar2, 0X0C, IntPtr.Zero, "51365035");
            WinApi.SendKey(fapiaohaomaBar2, WinApi.VK_RETURN);
            Thread.Sleep(100);

            //点击下一步按钮
            WinApi.LeftClick(nextStepBar);


            var confirmBtn     = IntPtr.Zero;
            var cancelBtn      = IntPtr.Zero;
            var isClickConfirm = IntPtr.Zero;

            var nextFlag = HxShengQing.TryRetry(bar =>
            {
                var list       = WinApi.EnumChildWindowsCallback(bar);
                confirmBtn     = list.Find(b => b.szWindowName == "确  定").hWnd;
                cancelBtn      = list.Find(b => b.szWindowName == "取 消").hWnd;
                isClickConfirm = list.Find(b => b.szWindowName == "本张发票可以开红字发票!").hWnd;
                if (confirmBtn == IntPtr.Zero || cancelBtn == IntPtr.Zero)
                {
                    return(false);
                }
                return(true);
            }, blueInvoiceInputtHw);

            if (!nextFlag)
            {
                throw new Exception("xxxx:蓝字发票校验页面下一步之后,句柄查找错误");
            }

            //点击确定按钮
            if (isClickConfirm != IntPtr.Zero)
            {
                WinApi.LeftClick(confirmBtn);
            }
            else
            {
                throw new Exception("xxxx:本张发票不可以开红字发票!");
            }
        }
예제 #6
0
        //发票确认重构
        public static bool ClickVerifyInvoicePage(ref string invoiceCode, ref string invoiceNo,
                                                  ref string invoiceType, bool isEnter = true)
        {
            var formBar = HxShengQing.TryRetry(str => WinApi.FindWindow(null, "发票号码确认"), "", 40, 500);

            var dmInfo          = new WindowInfo();
            var hmInfo          = new WindowInfo();
            var invoiceTypeInfo = new WindowInfo();
            var confirmBar      = IntPtr.Zero;
            var cancelBar       = IntPtr.Zero;

            var flag = HxShengQing.TryRetry(str =>
            {
                var childs = WinApi.EnumChildWindowsCallback(formBar);
                if (childs.Count < 10)
                {
                    return(false);
                }
                if (childs[7].szWindowName.Length == 10 || childs[7].szWindowName.Length == 12)
                {
                    dmInfo = childs[7];
                }
                else
                {
                    dmInfo = childs.FirstOrDefault(info =>
                                                   info.szWindowName.Length == 10 || info.szWindowName.Length == 12);
                }
                if (childs[5].szWindowName.Length == 8)
                {
                    hmInfo = childs[5];
                }
                else
                {
                    hmInfo = childs.FirstOrDefault(info => info.szWindowName.Length == 8 && int.TryParse(info.szWindowName, out var hm));
                }
                invoiceTypeInfo = childs[4];
                confirmBar      = childs.FirstOrDefault(b => b.szWindowName == "确认").hWnd;
                cancelBar       = childs.FirstOrDefault(b => b.szWindowName == "取消").hWnd;
                return(confirmBar != IntPtr.Zero && cancelBar != IntPtr.Zero && !string.IsNullOrEmpty(invoiceTypeInfo.szWindowName) &&
                       !string.IsNullOrEmpty(dmInfo.szWindowName) && !string.IsNullOrEmpty(hmInfo.szWindowName));
            }, "", 10, 500);

            //赋值
            invoiceNo   = hmInfo.szWindowName;
            invoiceCode = dmInfo.szWindowName;
            invoiceType = invoiceTypeInfo.szWindowName;


            if (isEnter)
            {
                for (var i = 0; i < 10; i++)
                {
                    WinApi.LeftClick(confirmBar);
                    Thread.Sleep(1000);
                    formBar = WinApi.FindWindow(null, "发票号码确认");
                    if (formBar == IntPtr.Zero)
                    {
                        break;
                    }
                }
            }
            else
            {
                WinApi.LeftClick(cancelBar);
            }

            return(true);
        }
예제 #7
0
        /// <summary>
        /// 红冲信息表下载demo,缺少成功验证逻辑
        /// </summary>
        public static void downLoadInfo()
        {
            var infoBar   = WinApi.FindWindow(null, "信息表选择");
            var list      = WinApi.EnumChildWindowsCallback(infoBar);
            var toolStrip = list.Find(bar => bar.szWindowName == "toolStrip1");

            if (toolStrip.hWnd == IntPtr.Zero)
            {
                return;
            }

            ClickBtnByName(toolStrip.hWnd, "下载");
            Thread.Sleep(500);

            var beginDateBar = IntPtr.Zero;
            var endDateBar   = IntPtr.Zero;

            var purTaxNoBar  = IntPtr.Zero;
            var saleTaxNoBar = IntPtr.Zero;
            var infoBhBar    = IntPtr.Zero;

            var confirmBar = IntPtr.Zero;

            HxShengQing.TryRetry(str =>
            {
                var downinfoBar = WinApi.FindWindow(null, str);
                var infoChilds  = WinApi.FindChildInfo(downinfoBar);
                confirmBar      = infoChilds.Find(b => b.szWindowName == "确定").hWnd;

                var infoTableInfoBar = infoChilds.Find(b => b.szWindowName == "信息表信息");
                var infoTableChilds  = WinApi.FindChildBar(infoTableInfoBar.hWnd);
                purTaxNoBar          = infoTableChilds[5];
                saleTaxNoBar         = infoTableChilds[4];
                infoBhBar            = infoTableChilds[1];

                var dateBar    = infoChilds.Find(b => b.szWindowName == "填开日期");
                var dateChilds = WinApi.FindChildBar(dateBar.hWnd);
                beginDateBar   = dateChilds[1];
                endDateBar     = dateChilds[0];

                if (beginDateBar == IntPtr.Zero || endDateBar == IntPtr.Zero ||
                    purTaxNoBar == IntPtr.Zero || saleTaxNoBar == IntPtr.Zero ||
                    infoBhBar == IntPtr.Zero || confirmBar == IntPtr.Zero)
                {
                    return(false);
                }
                return(true);
            }, "红字发票信息表审核结果下载条件设置");

            WinApi.LeftClick(beginDateBar);
            Thread.Sleep(500);
            //修改填开日期起为2018-1-1
            Thread.Sleep(100);
            SendKeys.SendWait("2018");
            Thread.Sleep(100);
            SendKeys.SendWait("{right}");
            Thread.Sleep(100);
            SendKeys.SendWait("01");
            Thread.Sleep(100);
            SendKeys.SendWait("{right}");
            Thread.Sleep(100);
            SendKeys.SendWait("01");

            Thread.Sleep(100);
            WinApi.SendMessage(purTaxNoBar, 0X0C, IntPtr.Zero, "1234567890");
            Thread.Sleep(100);
            WinApi.SendMessage(saleTaxNoBar, 0X0C, IntPtr.Zero, "0987654321");
            Thread.Sleep(100);
            WinApi.SendMessage(infoBhBar, 0X0C, IntPtr.Zero, "12345678901234567");
            Thread.Sleep(500);

            WinApi.LeftClick(confirmBar);

            var infoDownLoadBar = HxShengQing.TryRetry(str => WinApi.FindWindow(null, str), "信息表下载中");

            if (infoDownLoadBar != IntPtr.Zero)
            {
                for (var i = 0; i < 100; i++)
                {
                    infoDownLoadBar = WinApi.FindWindow(null, "信息表下载中");
                    var SysMessageBox = WinApi.FindWindow(null, "SysMessageBox");
                    if (SysMessageBox != IntPtr.Zero)
                    {
                        HxShengQing.SystemOpera("确认");
                        break;
                    }
                    if (infoDownLoadBar == IntPtr.Zero)
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
            }
        }