/// <summary> /// 新增客户 /// </summary> /// <param name="addClientPara"></param> /// <returns></returns> public static async Task <string> AddNewClient(AddClientPara addClientPara) { string uri = "NewInquiry"; //string httpContent = JsonConvert.SerializeObject(addClientPara); string httpContent = ""; Type type = addClientPara.GetType(); foreach (var item in type.GetProperties()) { httpContent += (item.Name + "=" + item.GetValue(addClientPara, null) + "&"); } httpContent = httpContent.TrimEnd('&'); string content = await RestSharpHelper <string> .PostFormAsyncWithoutDeserialization(uri, httpContent); return(content); }
/// <summary> /// 上传服务器 /// </summary> private async void Add() { string areaID = ""; foreach (var item in areaInfoArray) { if (Block == item.AreaName) { areaID = item.AreaID; } } AddClientPara addClientPara = new AddClientPara { CustName = ClientName, CustMobile = ClientPhoneNum, Trade = Trade, Country = CensusRegister, PropertyFloor = Marriage, PropertyUsage = Usage, CustGrade = Level == null || Level == "" ? "*" : Level, PropertyDecoration = Decoration == null || Decoration == "" ? "*" : Decoration, PropertyType = HouseType == null || HouseType == "" ? "*" : HouseType, PriceMin = MinBudget == null || MinBudget == "" ? "0" : MinBudget, PriceMax = MaxBudget == null || MaxBudget == "" ? "0" : MaxBudget, SquareMin = MinArea == null || MinArea == "" ? "0" : MinArea, SquareMax = MaxArea == null || MaxArea == "" ? "0" : MaxArea, FoorStart = MinFloor == null || MinFloor == "" ? "*" : MinFloor, FoorEnd = MaxFloor == null || MaxFloor == "" ? "*" : MaxFloor, CountF = MaxRooms == null || MaxRooms == "" ? "*" : MaxRooms, CountFStart = MinRooms == null || MinRooms == "" ? "*" : MinRooms, DistrictName = District == null || District == "" ? "*" : District, AreaID = areaID == null || areaID == "" ? "*" : areaID, DBName = GlobalVariables.LoggedUser.DBName, EmpNoOrTel = GlobalVariables.LoggedUser.EmpNo };//此处EmpNoOrTel只能是电话号码 string content = await RestSharpService.AddNewClient(addClientPara); if (string.IsNullOrWhiteSpace(content)) { CrossToastPopUp.Current.ShowToastError("服务器错误", ToastLength.Short); return; } BaseResponse baseResponse = JsonConvert.DeserializeObject <BaseResponse>(content); if (baseResponse.Flag == "success") { if (baseResponse.Msg == "KYExists") { CrossToastPopUp.Current.ShowToastError("重复的客源,拒绝新增", ToastLength.Long); } else { CrossToastPopUp.Current.ShowToastSuccess("客源新增成功", ToastLength.Long); await Application.Current.MainPage.Navigation.PopAsync(); } } else { CrossToastPopUp.Current.ShowToastError("客源新增失败", ToastLength.Long); } }