Beispiel #1
0
        /// <summary>
        /// 根据信息表流水账号,查询对应的信息表流水账号账单并点击上传按钮
        /// </summary>
        public static void step7()
        {
            //获取所有桌面窗体句柄
            var alldeskBar = WinApi.FindChildInfo(IntPtr.Zero);

            //获取开票软件句柄
            var kprjBar = alldeskBar.Find(bar => bar.szWindowName != null && bar.szWindowName.Contains("开票软件"));

            //获取开票软件下面的所有子句柄
            var kprjList = WinApi.EnumChildWindowsCallback(kprjBar.hWnd);

            //获取toolStrip1句柄
            var toolStripBar = kprjList.Find(bar =>
                                             bar.szWindowName != null && bar.szWindowName == "toolStrip1");


            var inputTextBar = WinApi.FindWindowEx(toolStripBar.hWnd, IntPtr.Zero, null, null);

            WinApi.SendMessage(inputTextBar, 0X0C, IntPtr.Zero, "661735289405190530193705");
            Thread.Sleep(1000);
            WinApi.SendKey(inputTextBar, KeySnap.VK_ENTER);

            var indexClickBar = 0;

            for (var i = 0; i < kprjList.Count; i++)
            {
                if (kprjList[i].szWindowName == "红字发票信息表查询导出")
                {
                    indexClickBar = i + 2;
                }
            }
            //ClickBtnByName(kprjList[indexClickBar].hWnd, "");
            WinApi.ClickLocation(kprjList[indexClickBar].hWnd, 10, 55);
            HxShengQing.ClickBtnByName(toolStripBar.hWnd, "上传");
        }
Beispiel #2
0
        /// <summary>
        /// 开票软件前置,detail填写,暂时这样--如果分辨率调整肯定会受到影响的
        /// </summary>
        static void InfoTianKai()
        {
            Thread.Sleep(100);
            WinApi.ShowWindow((IntPtr)1442640, 2);
            Thread.Sleep(100);
            WinApi.ShowWindow((IntPtr)1442640, 3);
            Thread.Sleep(100);
            WinApi.SetFocus((IntPtr)1442640);
            Thread.Sleep(100);
            WinApi.SetForegroundWindow((IntPtr)1442640);


            Thread.Sleep(2000);
            for (var i = 0; i < 5; i++)
            {
                WinApi.ClickLocation((IntPtr)7145062, 10, 25 + 23 * i + 12); //可以点中第一行第一块
                HxShengQing.GetTableFocus();
                Thread.Sleep(100);
                SendKeys.SendWait($"{i}aaaaa");
                WinApi.keybd_event(Keys.Tab, 0, 0, 0);
                HxShengQing.WriteGoodsTaxNoAdd(IntPtr.Zero, null);
                Thread.Sleep(1000);
                HxShengQing.ClickBtnByName((IntPtr)7472786, "增行");
                Thread.Sleep(1000);
            }
        }
Beispiel #3
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, "保存");
        }
Beispiel #4
0
        /// <summary>
        /// 折扣处理,正式环境下折扣行只会有一行。
        /// </summary>
        public static void step4()
        {
            //获取所有桌面窗体句柄
            var alldeskBar = WinApi.FindChildInfo(IntPtr.Zero);

            //获取开票软件句柄
            var kprjBar = alldeskBar.Find(bar => bar.szWindowName != null && bar.szWindowName.Contains("开票软件"));

            //获取开票软件下面的所有子句柄
            var kprjList = WinApi.EnumChildWindowsCallback(kprjBar.hWnd);

            //获取红字信息填开句柄--模糊查询
            var hzxxtkBar = kprjList.Find(bar =>
                                          bar.szWindowName != null && bar.szWindowName.Contains("红字发票信息表填开"));

            //三个--最后一个对应toolBar
            var hzxxtklist = WinApi.FindChildInfo(hzxxtkBar.hWnd);

            //点击差额征税按钮
            HxShengQing.ClickBtnByName(hzxxtklist[hzxxtklist.Count - 1].hWnd, "差额");

            var zhekouWinBar = WinApi.FindWindow(null, "输入扣除额");
            var zhekouBar    = WinApi.FindWindowEx(zhekouWinBar, IntPtr.Zero, null, null);
            var zhekouList   = WinApi.FindChildBar(zhekouBar);

            //这是确定按钮
            var confirmBar = zhekouList[0];
            var amountBar  = zhekouList[zhekouList.Count - 1];

            //输入折扣金额
            WinApi.SendMessage(amountBar, 0X0C, IntPtr.Zero, "10");
            Thread.Sleep(1000);
            //点击确定按钮
            WinApi.LeftClickMsg(confirmBar);
        }
Beispiel #5
0
        /// <summary>
        /// 点击发票填开
        /// </summary>
        public static void Step1()
        {
            var mainBar = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190427");//需要改动,模糊查询所有窗体
            var bar     = WinApi.FindWindowEx(mainBar, IntPtr.Zero, null, null);

            HxShengQing.ClickBtnByName(bar, "发票管理");//点击发票管理

            //找信息表管理父句柄
            var barInfoList   = WinApi.EnumChildWindowsCallback(mainBar);
            var infoParentBar = IntPtr.Zero;

            barInfoList.ForEach(i => {
                if (i.szWindowName == "发票管理")
                {
                    infoParentBar = i.hWnd;
                }
            });
            infoParentBar = WinApi.FindWindowEx(infoParentBar, IntPtr.Zero, null, null);
            var infoBar = WinApi.FindWindowEx(infoParentBar, IntPtr.Zero, null, null);

            WinApi.LeftClick(infoBar);//点击信息表成功

            //打开红字增值税专用发票信息表信息选择--没有防遮挡
            WinApi.keybd_event(VBKEY.vbKeyDown, 0, 0, 0);
            Thread.Sleep(100);
            WinApi.keybd_event(VBKEY.vbKeyReturn, 0, 0, 0);
        }
Beispiel #6
0
        public static void GetDropDown()
        {
            var winBar  = WinApi.FindWindow(null, "开具增值税专用发票");
            var toolBar = WinApi.EnumChilWindowsIntptr(winBar).LastOrDefault();

            HxShengQing.ClickBtnByName(toolBar, "红字");
            Thread.Sleep(500);
            var dropDown = WinApi.FindWindowEx(winBar, IntPtr.Zero, null, null);

            WinApi.SendKey(dropDown, WinApi.VK_UP);
            Thread.Sleep(100);
            WinApi.SendKey(dropDown, WinApi.VK_RETURN);
            Thread.Sleep(100);
        }
Beispiel #7
0
        /// <summary>
        /// 对名称和识别号进行赋值
        /// </summary>
        public static void step3()
        {
            //获取所有桌面窗体句柄
            var alldeskBar = WinApi.FindChildInfo(IntPtr.Zero);

            //获取开票软件句柄
            var kprjBar = alldeskBar.Find(bar => bar.szWindowName != null && bar.szWindowName.Contains("开票软件"));

            //获取开票软件下面的所有子句柄
            var kprjList = WinApi.EnumChildWindowsCallback(kprjBar.hWnd);

            //获取红字信息填开句柄--模糊查询
            var hzxxtkBar = kprjList.Find(bar =>
                                          bar.szWindowName != null && bar.szWindowName.Contains("红字发票信息表填开"));

            //三个--最后一个对应toolBar
            var hzxxtklist = WinApi.FindChildInfo(hzxxtkBar.hWnd);

            var hzxxtkInfoList  = WinApi.FindChildInfo(hzxxtklist[0].hWnd);
            var hzxxtkInfoChild = WinApi.FindChildInfo(hzxxtkInfoList[2].hWnd);
            var sfxxlist        = WinApi.FindChildInfo(hzxxtkInfoChild[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"));

            //点击价格

            //ClickBtnByName(hzxxtklist[hzxxtklist.Count - 1].hWnd, "价格");//这里貌似不需要点击 默认都是不含税
            HxShengQing.ClickBtnByName(hzxxtklist[hzxxtklist.Count - 1].hWnd, "价格");//这里貌似不需要点击 默认都是不含税
        }
Beispiel #8
0
        //普票测试通过
        public static void Method8()
        {
            var winBar    = WinApi.FindWindow(null, "开具增值税普通发票");
            var winBarUia = UiaHelper.GetUIAutomation().ElementFromHandle(winBar);

            var toolBar = winBarUia.FindFirst(UIAutomationClient.TreeScope.TreeScope_Descendants, UiaHelper.GetUIAutomation().CreatePropertyCondition(
                                                  UIA_PropertyIds.UIA_AutomationIdPropertyId, "toolStrip3"));

            for (var i = 0; i < 4; i++)
            {
                HxShengQing.ClickBtnByName(toolBar.CurrentNativeWindowHandle, "减行");
                Thread.Sleep(100);
            }
            for (var i = 0; i < 4; i++)
            {
                ClickBtnUia(toolBar.CurrentNativeWindowHandle, "增行");
                Thread.Sleep(100);
            }

            var dataGridUia = winBarUia.FindFirst(UIAutomationClient.TreeScope.TreeScope_Descendants, UiaHelper.GetUIAutomation().CreatePropertyCondition(
                                                      UIA_PropertyIds.UIA_AutomationIdPropertyId, "DataGrid1"));

            var rectdatatable = dataGridUia.CurrentBoundingRectangle;

            var childs = dataGridUia.FindAll(TreeScope.TreeScope_Children, UiaHelper.GetUIAutomation().CreateTrueCondition());

            for (var i = 2; i < childs.Length; i++)
            {
                var comElement = childs.GetElement(i);
                var rect       = comElement.CurrentBoundingRectangle;

                var subChilds = childs.GetElement(i).FindAll(TreeScope.TreeScope_Children,
                                                             UiaHelper.GetUIAutomation().CreateTrueCondition());

                //对名称进行赋值
                var pt3 = (IUIAutomationLegacyIAccessiblePattern)subChilds.GetElement(1)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);

                //pt3.DoDefaultAction();
                Thread.Sleep(500);
                var childinfos1 = WinApi.EnumChildWindowsCallback(dataGridUia.CurrentNativeWindowHandle);
                WinApi.SendMessage(childinfos1[childinfos1.Count - 1].hWnd, 12, IntPtr.Zero, $"AAA");

                try
                {
                    //pt3.DoDefaultAction();
                }
                catch (Exception e)
                {
                    var noaddBar = WinApi.FindWindow(null, "商品编码添加");
                    Bug.WriteGoodsTaxNoAdd(noaddBar, "101010104");
                    Console.WriteLine(e);
                }

                //改变税率

                var subElement = subChilds.GetElement(7);
                var retcsub    = subElement.CurrentBoundingRectangle;
                var pt2        = (IUIAutomationLegacyIAccessiblePattern)subChilds.GetElement(7)
                                 .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
                pt2.DoDefaultAction();

                childinfos1 = WinApi.EnumChildWindowsCallback(dataGridUia.CurrentNativeWindowHandle);
                UIHelper.SetCombox(childinfos1[1].hWnd, "17%");
                //WinApi.SendMessage(childinfos1[childinfos1.Count - 1].hWnd, 12, IntPtr.Zero, "17%");

                Thread.Sleep(500);

                for (var j = 2; j < 6; j++)
                {
                    var pt1 = (IUIAutomationLegacyIAccessiblePattern)subChilds.GetElement(j)
                              .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);

                    if (j == 2)
                    {
                        pt1.DoDefaultAction();
                        var childinfos = WinApi.EnumChildWindowsCallback(dataGridUia.CurrentNativeWindowHandle);
                        WinApi.SendMessage(childinfos[childinfos.Count - 1].hWnd, 12, IntPtr.Zero, "小");
                        Thread.Sleep(100);
                    }
                    else if (j == 3)
                    {
                        pt1.DoDefaultAction();
                        var childinfos = WinApi.EnumChildWindowsCallback(dataGridUia.CurrentNativeWindowHandle);
                        WinApi.SendMessage(childinfos[childinfos.Count - 1].hWnd, 12, IntPtr.Zero, "kg");
                        Thread.Sleep(100);
                    }
                    else if (j == 4)
                    {
                        pt1.DoDefaultAction();
                        var childinfos = WinApi.EnumChildWindowsCallback(dataGridUia.CurrentNativeWindowHandle);
                        WinApi.SendMessage(childinfos[childinfos.Count - 1].hWnd, 12, IntPtr.Zero, "3");
                        Thread.Sleep(100);
                    }
                    else if (j == 5)
                    {
                        pt1.DoDefaultAction();
                        var childinfos = WinApi.EnumChildWindowsCallback(dataGridUia.CurrentNativeWindowHandle);
                        WinApi.SendMessage(childinfos[childinfos.Count - 1].hWnd, 12, IntPtr.Zero, "100");
                        Thread.Sleep(100);
                        pt1.DoDefaultAction();
                        Thread.Sleep(1000);
                    }
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// 红字申请测试
        /// </summary>
        public static void Method14()
        {
            Thread.Sleep(10000);
            var winBar = WinApi.FindWindow(null, "增值税发票税控开票软件(金税盘版) V2.2.34.190628 - [红字发票信息表填开]");
            var tkUia  = UiaHelper.GetUIAutomation().ElementFromHandle(winBar).FindFirst(TreeScope.TreeScope_Descendants, UiaHelper.GetUIAutomation().CreatePropertyCondition(
                                                                                             UIA_PropertyIds.UIA_AutomationIdPropertyId, "SqdTianKai"));
            var toolBarUia = tkUia.FindFirst(TreeScope.TreeScope_Descendants, UiaHelper.GetUIAutomation()
                                             .CreatePropertyCondition(UIA_PropertyIds.UIA_AutomationIdPropertyId, "toolStrip2"));

            for (var i = 0; i < 7; i++)
            {
                HxShengQing.ClickBtnByName(toolBarUia.CurrentNativeWindowHandle, "增行");
                Thread.Sleep(100);
            }

            var tableUia = tkUia.FindFirst(TreeScope.TreeScope_Descendants, UiaHelper.GetUIAutomation().CreatePropertyCondition(
                                               UIA_PropertyIds.UIA_NamePropertyId, "DataGridView"));
            var tableBar = tableUia.CurrentNativeWindowHandle;
            var shUia    = tableUia.FindFirst(TreeScope.TreeScope_Children, UiaHelper.GetUIAutomation()
                                              .CreatePropertyCondition(UIA_PropertyIds.UIA_NamePropertyId, "首行"));
            var shRect = shUia.CurrentBoundingRectangle;

            for (var i = 0; i < 8; i++)
            {
                var row = tableUia.FindFirst(TreeScope.TreeScope_Children, UiaHelper.GetUIAutomation()
                                             .CreatePropertyCondition(UIA_PropertyIds.UIA_NamePropertyId, $"行 {i}"));
                var cols = row.FindAll(TreeScope.TreeScope_Children, UiaHelper.GetUIAutomation().CreateTrueCondition());

                Console.WriteLine($"{i}:col0:{cols.GetElement(0).CurrentName},col1:{cols.GetElement(1).CurrentName}");
                var nameRect = cols.GetElement(0).CurrentBoundingRectangle;
                WinApi.ClickLocation(tableBar, nameRect.left - shRect.left + 50, nameRect.top - shRect.top + 10);
                Thread.Sleep(100);
                WinApi.ClickLocation(tableBar, nameRect.left - shRect.left + 50, nameRect.top - shRect.top + 10);
                Thread.Sleep(500);
                var childs = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childs[childs.Count - 1].hWnd, 12, IntPtr.Zero, $"BBB{i}");

                WinApi.SendKey(tableBar, 9);//发送tab按键

                //var guigeRect = cols.GetElement(1).CurrentBoundingRectangle;
                //WinApi.ClickLocation(tableBar, guigeRect.left - shRect.left + 10, guigeRect.top - shRect.top + 10);
                Thread.Sleep(2000);
                var noaddBar = WinApi.FindWindow(null, "商品编码添加");
                if (noaddBar != IntPtr.Zero)
                {
                    Bug.WriteGoodsTaxNoAdd(noaddBar, "101010104");
                    Thread.Sleep(500);
                }

                var pt1 = (IUIAutomationLegacyIAccessiblePattern)cols.GetElement(1)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
                pt1.DoDefaultAction();
                Thread.Sleep(500);
                childs = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childs[childs.Count - 1].hWnd, 12, IntPtr.Zero, "大");
                pt1.DoDefaultAction();
                Thread.Sleep(200);

                var pt6 = (IUIAutomationLegacyIAccessiblePattern)cols.GetElement(6)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
                pt6.DoDefaultAction();
                Thread.Sleep(500);
                childs = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childs[childs.Count - 1].hWnd, 12, IntPtr.Zero, "10%");
                Thread.Sleep(500);
                pt6.DoDefaultAction();
                Thread.Sleep(500);

                //var danweiRect = cols.GetElement(2).CurrentBoundingRectangle;
                //WinApi.ClickLocation(tableBar, danweiRect.left - shRect.left + 10, danweiRect.top - shRect.top + 10);
                var pt2 = (IUIAutomationLegacyIAccessiblePattern)cols.GetElement(2)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
                pt2.DoDefaultAction();
                Thread.Sleep(500);
                childs = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childs[childs.Count - 1].hWnd, 12, IntPtr.Zero, "kg");

                //var numRect = cols.GetElement(3).CurrentBoundingRectangle;
                //WinApi.ClickLocation(tableBar, numRect.left - shRect.left + 10, numRect.top - shRect.top + 10);
                var pt3 = (IUIAutomationLegacyIAccessiblePattern)cols.GetElement(3)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
                pt3.DoDefaultAction();
                Thread.Sleep(500);
                childs = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childs[childs.Count - 1].hWnd, 12, IntPtr.Zero, "-3");

                //var priceRect = cols.GetElement(4).CurrentBoundingRectangle;
                //WinApi.ClickLocation(tableBar, priceRect.left - shRect.left + 10, priceRect.top - shRect.top + 10);
                var pt4 = (IUIAutomationLegacyIAccessiblePattern)cols.GetElement(4)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
                pt4.DoDefaultAction();
                Thread.Sleep(500);
                childs = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childs[childs.Count - 1].hWnd, 12, IntPtr.Zero, "100.00");
                Thread.Sleep(100);
                pt4.DoDefaultAction();
                Thread.Sleep(500);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 卷票测试--通过--有点小问题需要调整--调整完毕,大于5的话从4开始,其他从3开始--默认五条数据
        /// </summary>
        public static void Method10()
        {
            var winBar    = WinApi.FindWindow(null, "开具增值税普通发票(卷票)");
            var winBarUia = UiaHelper.GetUIAutomation().ElementFromHandle(winBar);

            var toolBarUia = winBarUia.FindFirst(TreeScope.TreeScope_Descendants, UiaHelper.GetUIAutomation().CreatePropertyCondition(
                                                     UIA_PropertyIds.UIA_AutomationIdPropertyId, "toolStrip3"));

            var dataGridUia = winBarUia.FindFirst(TreeScope.TreeScope_Descendants, UiaHelper.GetUIAutomation().CreatePropertyCondition(
                                                      UIA_PropertyIds.UIA_AutomationIdPropertyId, "DataGrid1"));
            var tableBar = (IntPtr)dataGridUia.CurrentNativeWindowHandle;

            var shouhangRetc = dataGridUia.FindFirst(TreeScope.TreeScope_Descendants,
                                                     UiaHelper.GetUIAutomation().CreatePropertyCondition(
                                                         UIA_PropertyIds.UIA_NamePropertyId, "首行")).CurrentBoundingRectangle;

            for (var i = 0; i < 2; i++)
            {
                HxShengQing.ClickBtnByName(toolBarUia.CurrentNativeWindowHandle, "减行");
                Thread.Sleep(100);
            }
            for (var i = 0; i < 3; i++)
            {
                ClickBtnUia(toolBarUia.CurrentNativeWindowHandle, "增行");
                Thread.Sleep(500);
                //对名称进行赋值
                var childinfos1 = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childinfos1[childinfos1.Count - 1].hWnd, 12, IntPtr.Zero, $"uuyy{i}");

                var element = dataGridUia.FindFirst(TreeScope.TreeScope_Children, UiaHelper.GetUIAutomation()
                                                    .CreatePropertyCondition(
                                                        UIA_PropertyIds.UIA_NamePropertyId, $"行 {i}"));

                var elementChilds = element.FindAll(TreeScope.TreeScope_Children,
                                                    UiaHelper.GetUIAutomation().CreateTrueCondition());

                var pt2 = (IUIAutomationLegacyIAccessiblePattern)elementChilds.GetElement(2)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);

                var rectcol2 = elementChilds.GetElement(2).CurrentBoundingRectangle;

                //触发商品编码添加窗体
                pt2.DoDefaultAction();
                Thread.Sleep(2000);
                var noaddBar = WinApi.FindWindow(null, "商品编码添加");
                if (noaddBar != IntPtr.Zero)
                {
                    Bug.WriteGoodsTaxNoAdd(noaddBar, "101010104");
                    Thread.Sleep(500);

                    WinApi.ClickLocation(tableBar, rectcol2.left - shouhangRetc.left + 10,
                                         rectcol2.top - shouhangRetc.top + 10);
                    Thread.Sleep(500);
                }
                childinfos1 = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childinfos1[childinfos1.Count - 1].hWnd, 12, IntPtr.Zero, "2.00");

                var pt3 = (IUIAutomationLegacyIAccessiblePattern)elementChilds.GetElement(3)
                          .GetCurrentPattern(UIA_PatternIds.UIA_LegacyIAccessiblePatternId);
                pt3.DoDefaultAction();
                Thread.Sleep(500);
                childinfos1 = WinApi.EnumChildWindowsCallback(tableBar);
                WinApi.SendMessage(childinfos1[childinfos1.Count - 1].hWnd, 12, IntPtr.Zero, "200.00");
                pt3.DoDefaultAction();
                Thread.Sleep(500);

                var rect = elementChilds.GetElement(5).CurrentBoundingRectangle;
                WinApi.ClickLocation(tableBar, rect.left - shouhangRetc.left + 10, rect.top - shouhangRetc.top + 10);
                Thread.Sleep(500);
                childinfos1 = WinApi.EnumChildWindowsCallback(tableBar);
                //修改税率
                UIHelper.SetCombox(childinfos1.Find(b => b.szClassName.Contains("COMBOBOX")).hWnd, "17%");
            }
            Console.WriteLine("success...");
        }
Beispiel #11
0
        public static void JuanPiaoTianKai(Entitys.InvoiceInfo invoiceInfo)
        {
            //有时候会有插件加载
            Thread.Sleep(3000);

            var winJuanBar    = IntPtr.Zero;
            var toolBar       = IntPtr.Zero;
            var dataBar       = IntPtr.Zero;
            var FPtiankai_new = IntPtr.Zero;

            //购方名称
            var gfmcBar = IntPtr.Zero;

            //纳税人识别号
            var nsrsbhBar = IntPtr.Zero;

            //收款员
            var skyBar = IntPtr.Zero;

            //备注
            var remarkBar = IntPtr.Zero;

            var flag = TryRetry(str =>
            {
                winJuanBar = WinApi.FindWindow(null, str);
                if (winJuanBar == IntPtr.Zero)
                {
                    return(false);
                }
                var child  = WinApi.FindWindowEx(winJuanBar, IntPtr.Zero, null, "FPtiankai_new");
                var child1 = WinApi.FindWindowEx(child, IntPtr.Zero, null, null);
                toolBar    = WinApi.FindWindowEx(child, child1, null, null);

                var parentBar = WinApi.FindWindowEx(child1, IntPtr.Zero, null, null);
                var childs    = WinApi.FindChildBar(parentBar);

                skyBar    = childs[18];
                remarkBar = childs[19];
                gfmcBar   = childs[childs.Count - 1];
                nsrsbhBar = childs[childs.Count - 2];
                dataBar   = childs[childs.Count - 5];

                if (toolBar == IntPtr.Zero || skyBar == IntPtr.Zero || remarkBar == IntPtr.Zero ||
                    gfmcBar == IntPtr.Zero || nsrsbhBar == IntPtr.Zero || dataBar == IntPtr.Zero)
                {
                    return(false);
                }
                return(true);
            }, "开具增值税普通发票(卷票)", 20, 500);

            if (flag == false)
            {
                Console.Write("句柄查找错误");
                return;
            }

            //窗体前置
            SetForHead(winJuanBar, false);
            Thread.Sleep(100);

            HxShengQing.ClickBtnByName(toolBar, "减行");

            //填写备注
            if (!string.IsNullOrEmpty(invoiceInfo?.Head.Remark))
            {
                WinApi.SendMessage(remarkBar, WinApi.BM_TEXT, IntPtr.Zero, invoiceInfo?.Head.Remark);
            }

            //收款人
            if (!string.IsNullOrEmpty(invoiceInfo?.Head.CashierName))
            {
                var nsMation = AutomationElement.FromHandle(skyBar);
                var temp     = nsMation.FindFirst(TreeScope.Children,
                                                  new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
                if (temp != null)
                {
                    temp.TryGetCurrentPattern(ValuePattern.Pattern, out var objPattern);
                    ((ValuePattern)objPattern)?.SetValue(invoiceInfo?.Head.CashierName);
                }
                else
                {
                    var list = WinApi.FindChildBar(skyBar);
                    foreach (var b in list)
                    {
                        WinApi.SendMessage(b, WinApi.BM_TEXT, IntPtr.Zero, invoiceInfo?.Head.CashierName);
                    }
                }
            }

            //填写购买方名称
            if (!string.IsNullOrEmpty(invoiceInfo?.Head.PurchaserName))
            {
                var nsMation = AutomationElement.FromHandle(gfmcBar);
                var temp     = nsMation.FindFirst(TreeScope.Children,
                                                  new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
                if (temp != null)
                {
                    temp.TryGetCurrentPattern(ValuePattern.Pattern, out var objPattern);
                    ((ValuePattern)objPattern)?.SetValue(invoiceInfo?.Head.PurchaserName);
                }
                else
                {
                    var list = WinApi.FindChildBar(gfmcBar);
                    foreach (var b in list)
                    {
                        WinApi.SendMessage(b, WinApi.BM_TEXT, IntPtr.Zero, invoiceInfo?.Head.PurchaserName);
                    }
                }
                Thread.Sleep(500);
                WinApi.keybd_event(Keys.Down, 0, 0, 0);
                Thread.Sleep(500);
                WinApi.keybd_event(Keys.Enter, 0, 0, 0);
            }

            //填写纳税人识别号
            if (!string.IsNullOrEmpty(invoiceInfo?.Head.PurchaserTaxNo))
            {
                //var txtbar = WinApi.FindChildInfo(nsrsbhBar);

                var nsMation = AutomationElement.FromHandle(nsrsbhBar);
                var temp     = nsMation.FindFirst(TreeScope.Children,
                                                  new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit));
                if (temp != null)
                {
                    temp.TryGetCurrentPattern(ValuePattern.Pattern, out var objPattern);
                    if (((ValuePattern)objPattern)?.Current.Value != invoiceInfo?.Head.PurchaserTaxNo)
                    {
                        ((ValuePattern)objPattern)?.SetValue(invoiceInfo?.Head.PurchaserTaxNo);
                    }
                }
                else
                {
                    var list = WinApi.FindChildBar(nsrsbhBar);
                    foreach (var b in list)
                    {
                        WinApi.SendMessage(b, WinApi.BM_TEXT, IntPtr.Zero, invoiceInfo?.Head.PurchaserTaxNo);
                    }
                }
                WinApi.ClickLocation(FPtiankai_new, 100, 100);
            }

            //填写明细
            for (var i = 0; i < invoiceInfo.InvoiceDetails.Count; i++)
            {
                if (invoiceInfo.InvoiceDetails[i].DetailKind == "1")
                {
                    continue;
                }

                HxShengQing.ClickBtnByName(toolBar, "增行");

                Thread.Sleep(500);
                //WinApi.ClickLocation(dataBar, 40, 24 + 30 * i + 15); //可以点中第一行第一块
                //Thread.Sleep(200);
                if (invoiceInfo.InvoiceDetails[i].DetailKind == "2")
                {
                    var next = invoiceInfo.InvoiceDetails.Find(detail => detail.DetailKind == "1" &&
                                                               detail.ItemName ==
                                                               invoiceInfo.InvoiceDetails[i].ItemName);
                    JuanPiaoMingXi(toolBar, invoiceInfo.InvoiceDetails[i], next); //填写卷票明细
                }
                else
                {
                    JuanPiaoMingXi(toolBar, invoiceInfo.InvoiceDetails[i]); //填写卷票明细
                }
            }

            Thread.Sleep(500);
        }
Beispiel #12
0
        public static void WriteGoodsTaxNoAdd(IntPtr goodNoAddHw, string goodsTaxNo = "",
                                              string taxPer = "", string taxPerCon = "", string taxRate = "")
        {
            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;

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

            WinApi.SendMessage(ssflbmBar, WinApi.BM_TEXT, IntPtr.Zero, HxShengQing.TaxSub(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(taxPer) && !string.IsNullOrEmpty(taxPerCon))
            {
                UIHelper.SetCombox(yhBar, "是");

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

            HxShengQing.ClickBtnByName(toolStrip, "保存");
            Thread.Sleep(500);
        }
Beispiel #13
0
        public static void WriteGoodsSetting(IntPtr goodNoSettingHw, string taxPer = "", string taxPerCon = "", string taxRate = "")
        {
            if (goodNoSettingHw == IntPtr.Zero)
            {
                return;
            }

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

            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 (toolStrip == IntPtr.Zero || suilvBar == IntPtr.Zero || yhBar == IntPtr.Zero || yhlBar == IntPtr.Zero)
            {
                //AmLogger.Error("WriteGoodsSetting", $"税收分类编码设置窗体,控件句柄获取失败");
                //throw new AmExceptionCode("税收分类编码设置窗体,控件句柄获取失败");
            }

            if ("1".Equals(taxPer) && !string.IsNullOrEmpty(taxPerCon))
            {
                UIHelper.SetCombox(yhBar, "是");

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

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

            HxShengQing.SystemOpera("确认", out var message);
            if (message != "修改成功!")
            {
                throw new Exception(message);
            }
            //AmLogger.Info("WriteGoodsSetting", $"税收分类编码设置窗体,设置成功");
        }
Beispiel #14
0
        /// <summary>
        /// 卷票明细
        /// </summary>
        /// <param name="detail"></param>
        /// <param name="next"></param>
        /// <param name="toolBar"></param>
        public static void JuanPiaoMingXi(IntPtr toolBar, Entitys.InvoiceDetail detail, Entitys.InvoiceDetail next = null)
        {
            try
            {
                GetTableFocus();
                //填写货物名称
                SendKeys.SendWait(detail.ItemName);
                Thread.Sleep(500);
                WinApi.keybd_event(Keys.Tab, 0, 0, 0);

                var ssbmszBar = IntPtr.Zero;
                var ssbmtjBar = IntPtr.Zero;
                TryRetry(str =>
                {
                    ssbmszBar = WinApi.FindWindow(null, "税收分类编码设置");
                    ssbmtjBar = WinApi.FindWindow(null, "商品编码添加");
                    return(ssbmszBar != IntPtr.Zero || ssbmtjBar != IntPtr.Zero);
                }, "", 4, 500);

                if (ssbmszBar != IntPtr.Zero)
                {
                    WriteGoodsSetting(ssbmszBar,
                                      detail.TaxPer, detail.TaxperCon, detail.TaxRate);
                }
                if (ssbmtjBar != IntPtr.Zero)
                {
                    WriteGoodsTaxNoAdd(ssbmtjBar, detail.GoodsTaxNo,
                                       detail.TaxPer, detail.TaxperCon, detail.TaxRate);
                }

                if (!string.IsNullOrWhiteSpace(detail.Quantity))
                {
                    GetTableFocus();
                    //填写数量
                    SendKeys.SendWait(detail.Quantity);
                }

                Thread.Sleep(500);
                WinApi.keybd_event(Keys.Tab, 0, 0, 0);
                if (!string.IsNullOrWhiteSpace(detail.UnitPrice))
                {
                    GetTableFocus();
                    //填写单价
                    if (detail.PriceMethod != "1")
                    {
                        detail.UnitPrice = ((1 + Convert.ToDouble(detail.TaxRate))
                                            * Convert.ToDouble(detail.UnitPrice)).ToString();
                    }
                    SendKeys.SendWait(detail.UnitPrice);
                }

                Thread.Sleep(500);
                WinApi.keybd_event(Keys.Tab, 0, 0, 0);
                Thread.Sleep(500);
                //AmLogger.Info("JuanPiaoMingXi", "一行明细填写成功");

                //添加折扣逻辑
                if (detail.DetailKind != "2" || next == null)
                {
                    return;
                }

                //点击折扣按钮
                HxShengQing.ClickBtnByName(toolBar, "折扣");
                Thread.Sleep(500);

                var jbar = IntPtr.Zero;
                for (var i = 0; i < 10; i++)
                {
                    jbar = WinApi.FindWindow(null, "添加折扣行");
                    if (jbar != IntPtr.Zero)
                    {
                        break;
                    }

                    Thread.Sleep(500);
                }

                var list = WinApi.EnumChilWindowsIntptr(jbar);
                if (list == null || list.Count < 8)
                {
                    return;
                }

                //发送折扣金额
                WinApi.SendMessage((IntPtr)list[6], WinApi.BM_TEXT, IntPtr.Zero, next.AmountWithTax.Substring(1, next.AmountWithTax.Length - 1));

                //点击确定按钮
                Thread.Sleep(500);
                WinApi.LeftClickMsg(list[4]);
            }
            catch (Exception e)
            {
                //CaptureScreen.TakeScreenShot("添加明细", $"{e.Message}");
                //AmLogger.Error("JuanPiaoMingXi", e);
            }
        }