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); }
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", $"税收分类编码设置窗体,设置成功"); }