69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using Xamarin.Forms;
|
|
using Xamarin.Forms.Xaml;
|
|
using XXCpzs.helper;
|
|
using XXCpzs.Models;
|
|
using XXCpzs.ViewModels;
|
|
|
|
namespace XXCpzs.Views
|
|
{
|
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
|
public partial class PageAddCustomer : ContentPage
|
|
{
|
|
//id uid companyId departmentId diviceId contacts phone email address company note create_time update_time
|
|
private AddCustomerModel ViewModel;
|
|
private UserInfo userInfo;
|
|
private int DeviceId = 1;
|
|
public PageAddCustomer(UserInfo userInfo)
|
|
{
|
|
InitializeComponent();
|
|
this.userInfo = userInfo;
|
|
this.BindingContext = ViewModel = new AddCustomerModel(userInfo.uid);
|
|
}
|
|
|
|
private async void Button_Clicked(object sender, EventArgs e)
|
|
{
|
|
|
|
if (Company.Text == null)
|
|
{
|
|
await DisplayAlert("提示:", "客户企业名不能为空!", "确定");
|
|
return;
|
|
}
|
|
if (Contacts.Text == null)
|
|
{
|
|
await DisplayAlert("提示:", "客户联系人不能为空!", "确定");
|
|
return;
|
|
}
|
|
if (Phone.Text == null)
|
|
{
|
|
await DisplayAlert("提示:", "客户电话不能为空!", "确定");
|
|
return;
|
|
}
|
|
|
|
bool response = await DisplayAlert("提示:", "确认添加?", "Yes", "No");
|
|
if (response)
|
|
{
|
|
var request = HttpHelper.Refresh<Customer>("addcustomer",
|
|
new Dictionary<string, string>{
|
|
{"Uid", userInfo.uid.ToString()},
|
|
{"Company", Company.Text.Trim()},
|
|
{"Contacts",Contacts.Text.Trim()},
|
|
{"Phone", Phone.Text.Trim()},
|
|
{"Email", Email.Text},
|
|
{"Address", Address.Text},
|
|
{"Note", Note.Text},
|
|
{"deviceId", this.DeviceId.ToString()}
|
|
});
|
|
if (request.Code != 0)
|
|
{
|
|
|
|
MessagingCenter.Send(this, "AddCustomer", request.Data as Customer);
|
|
await Navigation.PopModalAsync();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
} |