简单的物流项目实战,WPF的MVVM设计模式(四)
2021-02-08 23:15
标签:ber wordcount ISE nlog mes box private pre 之间 接下来写ViewModels 创建运单的ViewModel类 以上分别为创建运单,查看运单,以及注册,以及登录的ViewModels,作为Views和Models之间的连接器 简单的物流项目实战,WPF的MVVM设计模式(四) 标签:ber wordcount ISE nlog mes box private pre 之间 原文地址:https://www.cnblogs.com/R00R/p/11332141.html public class CreateExpressWindowViewModel: NotificationObject
{
private string province;
public string Province
{
get
{
return province;
}
set
{
province = value;
this.RaisePropertyChanged("Province");
}
}
private string city;
public string City
{
get
{
return city;
}
set
{
city = value;
this.RaisePropertyChanged("City");
}
}
private string area;
public string Area
{
get
{
return area;
}
set
{
area = value;
this.RaisePropertyChanged("Area");
}
}
private string street;
public string Street
{
get
{
return street;
}
set
{
street = value;
this.RaisePropertyChanged("Street");
}
}
private string username;
public string Username
{
get
{
return username;
}
set
{
username = value;
this.RaisePropertyChanged("Username");
}
}
private string phonenumber;
public string Phonenumber
{
get
{
return phonenumber;
}
set
{
phonenumber = value;
this.RaisePropertyChanged("Phonenumber");
}
}
private string createtime;
public string Createtime
{
get
{
return createtime;
}
set
{
createtime = value;
this.RaisePropertyChanged("Createtime");
}
}
public DelegateCommand CreateExpressCommand { get; set; }
public CreateExpressWindowViewModel()
{
Createtime = DateTime.Now.ToShortDateString();
CreateExpressCommand = new DelegateCommand(new Action(InsertExpress));
}
private void InsertExpress()
{
//Random rd = new Random();
//int num = rd.Next(10000000, 99999999);
InsertExpressService insertExpressService = new InsertExpressService();
Express express = new Express();
insertExpressService.InsertExpress(Province,City,Area,Street,Username,Phonenumber,Createtime);
MessageBox.Show("成功下单!");
ExpressWindow expressWindow = new ExpressWindow();
ReadExpressWindow readExpressWindow = new ReadExpressWindow();
readExpressWindow.Show();
expressWindow.Close();
}
}
public class GetExpressWindow : NotificationObject
{
private string province;
public string Province
{
get
{
return province;
}
set
{
province = value;
this.RaisePropertyChanged("Province");
}
}
private string city;
public string City
{
get
{
return city;
}
set
{
city = value;
this.RaisePropertyChanged("City");
}
}
private string area;
public string Area
{
get
{
return area;
}
set
{
area = value;
this.RaisePropertyChanged("Area");
}
}
private string street;
public string Street
{
get
{
return street;
}
set
{
street = value;
this.RaisePropertyChanged("Street");
}
}
private string username;
public string Username
{
get
{
return username;
}
set
{
username = value;
this.RaisePropertyChanged("Username");
}
}
private string phonenumber;
public string Phonenumber
{
get
{
return phonenumber;
}
set
{
phonenumber = value;
this.RaisePropertyChanged("Phonenumber");
}
}
private string createtime;
public string Createtime
{
get
{
return createtime;
}
set
{
createtime = value;
this.RaisePropertyChanged("Createtime");
}
}
public DelegateCommand GetExpressCommand { get; set; }
public GetExpressWindow()
{
GetExpressCommand = new DelegateCommand(new Action(GetExpress));
}
private void GetExpress()
{
GetExpressService getExpressService = new GetExpressService();
Express express = new Express();
express = getExpressService.GetExpressData();
Province = express.Province;
City = express.City;
Area = express.Area;
Street = express.Street;
Username = express.UserName;
Phonenumber = express.PhoneNumber;
Createtime = express.CteateTime;
}
}
public class RegisteredWindowViewModel : NotificationObject
{
private string userAccount;
public string UserAccount
{
get
{
return userAccount;
}
set
{
userAccount = value;
this.RaisePropertyChanged("UserAccount");
}
}
private string password;
public string Password
{
get
{
return password;
}
set
{
password = value;
this.RaisePropertyChanged("Password");
}
}
public DelegateCommand InsertCommand { get; set; }
public RegisteredWindowViewModel()
{
InsertCommand = new DelegateCommand(new Action(InsertUserData));
}
private void InsertUserData()
{
InsertRegisteredService insertRegisteredService = new InsertRegisteredService();
User user = new User();
user.UserAccount = UserAccount;
user.Password = Password;
user = insertRegisteredService.InsertUser(UserAccount, Password);
MessageBox.Show("注册成功!");
}
}
public class UserViewModel: NotificationObject
{
///
public class UserWindowViewModel : NotificationObject
{
//var logger = NLog.LogManager.GetCurrentClassLogger();
//logger.Info("Hello World");
//var a = LogManager.GetCurrentClassLogger();
private string username;
public string Username
{
get
{
return username;
}
set
{
username = value;
this.RaisePropertyChanged("Username");
}
}
private string userpassword;
public string Userpassword
{
get
{
return userpassword;
}
set
{
userpassword = value;
this.RaisePropertyChanged("Userpassword");
}
}
public DelegateCommand GetCommand { get; set; }
public UserWindowViewModel()
{
GetCommand = new DelegateCommand(new Action(GetUser));
}
private void GetUser()
{
GetUserService getUserServicelist = new GetUserService();
List
上一篇:WIN10关闭同步主机服务
下一篇:socket 错误之:OSError: [WinError 10057] 由于套接字没有连接并且(当使用一个 sendto 调用发送数据报套接字时)没有提供地址,发送或接收数据的请求没有被接受。
文章标题:简单的物流项目实战,WPF的MVVM设计模式(四)
文章链接:http://soscw.com/index.php/essay/52846.html