Files
wcs/货架标准上位机/Views/Windows/CalibrationWindow.xaml.cs
2025-01-13 14:10:32 +08:00

107 lines
3.1 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 Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WCS.Model;
using WCS.Model.ApiModel;
using WCS.Model.ApiModel.StoreInfo;
using WCS.Model.ApiModel.User;
using .Api;
namespace
{
/// <summary>
/// CalibrationWindow.xaml 的交互逻辑
/// </summary>
public partial class CalibrationWindow : System.Windows.Window
{
public int BoardId { get; set; }
public int ModuleId { get; set; }
public string ModuleCode { get; set; }
public CalibrationWindow(int boardId, int moduleId, string moduleCode)
{
InitializeComponent();
BoardId = boardId;
ModuleId = moduleId;
tagIdTxt.Text = $"板ID{boardId}";
ModuleCode = moduleCode;
moduleCodeTxt.Text = $"库位:{moduleCode}";
}
private void Button_Click(object sender, RoutedEventArgs e)
{
}
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
Button_Click(null, null);
}
else if (e.Key == Key.Escape)
{
this.Close();
}
}
public string GetDataFromHttp(string data, string url, string httpMethod)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = httpMethod;
request.ContentType = "application/json";
if (!string.IsNullOrEmpty(data))
{
string strContent = data; //参数data
using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
{
dataStream.Write(strContent);
dataStream.Close();
}
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
{
encoding = "UTF-8"; //默认编码
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = reader.ReadToEnd();
return retString;
}
catch (Exception ex)
{
return null;
}
}
public class RootLogin
{
public int code { get; set; }
public string msg { get; set; }
public object data { get; set; }
}
}
}