Пример #1
0
        private void txtManufacturerSysNo_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (string.IsNullOrEmpty(this.txtManufacturerSysNo.Text))
                {
                    SelectedManufacturerSysNo      = null;
                    this.txtManufacturerSysNo.Text = string.Empty;
                    SelectedManufacturerName       = null;
                    this.txtManufacturerName.Text  = string.Empty;
                    return;
                }
                int manufacturerSysNo = 0;
                if (!int.TryParse(this.txtManufacturerSysNo.Text.Trim(), out manufacturerSysNo))
                {
                    CurrentWindow.Alert("无效的代理厂商编号!");
                    SelectedManufacturerSysNo      = null;
                    this.txtManufacturerSysNo.Text = string.Empty;
                    return;
                }

                serviceFacade.QueryManufacturerBySysNo(manufacturerSysNo.ToString(), (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    if (null != args.Result && args.Result.SysNo.HasValue &&
                        args.Result.ManufacturerNameLocal != null)
                    {
                        SelectedManufacturerSysNo     = manufacturerSysNo.ToString();
                        this.txtManufacturerName.Text = SelectedManufacturerName = args.Result.ManufacturerNameLocal.Content;
                    }
                    else
                    {
                        //CurrentWindow.Alert("未找到相关的代理厂商!");
                        SelectedManufacturerSysNo      = null;
                        this.txtManufacturerSysNo.Text = string.Empty;
                        return;
                    }
                });
            }
        }
        private void txtManufacturerSysNo_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                int manufacturerSysNo = 0;
                if (!int.TryParse(this.txtManufacturerSysNo.Text.Trim(), out manufacturerSysNo))
                {
                    CurrentWindow.Alert("无效的厂商编号!");
                    this.SelectedManufacturerName  = null;
                    this.SelectedManufacturerSysNo = null;
                    this.txtManufacturerSysNo.Text = string.Empty;
                    return;
                }

                serviceFacade.QueryManufacturerBySysNo(manufacturerSysNo.ToString(), (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    if (args.Result.ManufacturerNameLocal == null)
                    {
                        CurrentWindow.Alert("无效的厂商编号!");
                        this.SelectedManufacturerName  = null;
                        this.SelectedManufacturerSysNo = null;
                        this.txtManufacturerSysNo.Text = string.Empty;
                        return;
                    }
                    this.SelectedManufacturerSysNo = args.Result.SysNo.Value.ToString();
                    this.SelectedManufacturerName  = args.Result.ManufacturerNameLocal.Content;

                    BrandQueryFilter requestBrand = new BrandQueryFilter()
                    {
                        ManufacturerSysNo = int.Parse(SelectedManufacturerSysNo),
                        ManufacturerName  = SelectedManufacturerName,
                        PagingInfo        = new QueryFilter.Common.PagingInfo()
                        {
                            PageIndex = 0, PageSize = 1
                        }
                    };
                    serviceFacade.QueryBrands(requestBrand, (obj2, args2) =>
                    {
                        if (args2.FaultsHandle())
                        {
                            return;
                        }
                        var brandList = args2.Result.Rows;
                        if (null != brandList)
                        {
                            try
                            {
                                SelectedBrandSysNo = null != brandList[0]["SysNo"] ? brandList[0]["SysNo"].ToString() : string.Empty;
                                SelectedBrandName  = brandList[0]["BrandName_Ch"];
                            }
                            catch
                            {
                                SelectedBrandName  = null;
                                SelectedBrandSysNo = null;
                            }
                        }
                    });
                });
            }
        }