112 lines
3.6 KiB
C#
112 lines
3.6 KiB
C#
using HandyControl.Controls;
|
||
using SqlSugar;
|
||
using System;
|
||
using System.Windows;
|
||
using WCS.BLL.DbModels;
|
||
using WCS.Model;
|
||
using WCS.Model.ApiModel.MatDetailCurrentInfo;
|
||
using WCS.Model.ApiModel.StoreInfo;
|
||
using WCS.Model.ApiModel.User;
|
||
using 智慧物流软件系统.Api;
|
||
using 智慧物流软件系统.ViewModel;
|
||
|
||
namespace 智慧物流软件系统
|
||
{
|
||
public partial class MatDetailCurrentInfoUpdateView : System.Windows.Window
|
||
{
|
||
public MatDetailCurrentInfoUpdateViewModel ViewModel = new MatDetailCurrentInfoUpdateViewModel();
|
||
|
||
public MatDetailCurrentInfoUpdateView(string _titleText, MatDetailCurrentInfoModel _matDetailCurrentInfoModel = null)
|
||
{
|
||
InitializeComponent();
|
||
|
||
this.DataContext = ViewModel;
|
||
ViewModel.textBox = txtMatQty;
|
||
ViewModel.SetValues(_matDetailCurrentInfoModel);
|
||
//绑定标题
|
||
Title.Text = "修改货架存量";
|
||
|
||
|
||
}
|
||
|
||
|
||
private void btnOk_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
#region 校验填写的值
|
||
try
|
||
{
|
||
txtMatQty.Text = txtMatQty.Text.Trim();
|
||
var qty = int.Parse(txtMatQty.Text);
|
||
if (qty < 0)
|
||
{
|
||
HandyControl.Controls.MessageBox.Show("数量请输入大于0的值!");
|
||
return;
|
||
}
|
||
else if (qty == 0)
|
||
{
|
||
HandyControl.Controls.MessageBox.Show("数量请输入大于0的值!\r\n如果需要设置为0请使用【删除】功能!");
|
||
return;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
HandyControl.Controls.MessageBox.Show("数量请输入有效的数字!");
|
||
return;
|
||
}
|
||
#endregion
|
||
|
||
#region 保存/修改值
|
||
var body = new AddLocaionInfoRequest<MatDetailCurrentInfoModel>()
|
||
{
|
||
UserName = LocalStatic.CurrentUser,
|
||
DeviceType = LocalFile.Config.DeviceType,
|
||
LocationInfo = ViewModel.GetValues(),
|
||
AddOrUpdate = AddOrUpdate.Update
|
||
};
|
||
var Result = ApiHelp.GetDataFromHttp<ResponseBase<object>>(LocalFile.Config.ApiIpHost + "matDetailCurrenInfo/updateMatDetailCurrentInfo", body, "POST");
|
||
if (Result != null && Result.Code == 200)
|
||
{
|
||
|
||
Growl.Success("修改成功!");
|
||
this.DialogResult = true;
|
||
this.Close();
|
||
}
|
||
else
|
||
{
|
||
Growl.Error($"{Result?.Message?.ToString()}");
|
||
}
|
||
#endregion
|
||
}
|
||
//绑定数据
|
||
catch (Exception ex)
|
||
{
|
||
Growl.Error($"操作异常:{ex.Message}");
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void closeClick(object sender, RoutedEventArgs e)
|
||
{
|
||
this.DialogResult = false;
|
||
this.Close();
|
||
}
|
||
|
||
private void txtMatQty_GotFocus(object sender, RoutedEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
var textBox = sender as System.Windows.Controls.TextBox;
|
||
if (textBox != null)
|
||
{
|
||
textBox.CaretIndex = textBox.Text.Length;
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
}
|
||
}
|
||
}
|