Files
wcs/货架标准上位机/Views/MatDetailCurrentInfoUpdateView.xaml.cs
2025-01-14 11:18:38 +08:00

112 lines
3.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
{
}
}
}
}