using DIXPad.DataProtocol;
|
using DIXPadWPF.Helper;
|
using DIXWeb.Business.MySQLBiz;
|
using DIXWeb.DataRepository;
|
using DIXWeb.Entity.MySQLEntity;
|
using DIXWeb.Util;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
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.Navigation;
|
using System.Windows.Shapes;
|
|
namespace DIXPadWPF
|
{
|
/// <summary>
|
/// DixPadUpLoad.xaml 的交互逻辑
|
/// </summary>
|
public partial class DixPadUpLoad : Page
|
{
|
MySQLInspectAreaBiz ABIZ = null;
|
MySQLInspectObjectTypeBiz BIZ = null;
|
MySQLInspectObjectBiz OBIZ = null;
|
MySQLInspectBaseBiz BBIZ = null;
|
MySQLInspectFrequencyBiz BFZ = null;
|
string _ServiceUrl { get; set; } = "";
|
public DixPadUpLoad()
|
{
|
InitializeComponent();
|
_ServiceUrl = System.Configuration.ConfigurationManager.AppSettings["ServiceUrl"].ToString();
|
ABIZ = new MySQLInspectAreaBiz();
|
OBIZ = new MySQLInspectObjectBiz();
|
BBIZ = new MySQLInspectBaseBiz();
|
BIZ = new MySQLInspectObjectTypeBiz();
|
BFZ = new MySQLInspectFrequencyBiz();
|
}
|
|
private void btnSearch_Click(object sender, RoutedEventArgs e)
|
{
|
string inspectobjecttype = cbInspectObjectType.Text;
|
string inspectArea = cbInspectArea.Text;
|
string inspectFreq = cbInspectFreq.Text;
|
DataTable dt = OBIZ.GetAllInspectedItem(inspectobjecttype, inspectArea, inspectFreq);
|
UploadDataGrid.ItemsSource = dt.DefaultView;
|
cbInspectObjectType.SelectedIndex = -1;
|
cbInspectArea.SelectedIndex = -1;
|
cbInspectFreq.SelectedIndex = -1;
|
}
|
public void GetInspectObjectType()
|
{
|
cbInspectObjectType.Items.Clear();
|
cbInspectObjectType.Items.Add("全选");
|
List<MySQLInspectObjectType> list = BIZ.GetDataList("", "", new Pagination());
|
if (list.Count > 0)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
string typename = list[i].Name;
|
cbInspectObjectType.Items.Add(typename);
|
}
|
}
|
}
|
public void GetInspectArea()
|
{
|
cbInspectArea.Items.Clear();
|
cbInspectArea.Items.Add("全选");
|
List<MySQLInspectArea> list = ABIZ.GetDataList(0, new Pagination());
|
if (list.Count > 0)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
string typename = list[i].Name;
|
cbInspectArea.Items.Add(typename);
|
}
|
}
|
}
|
public void GetInspectFreq()
|
{
|
cbInspectFreq.Items.Clear();
|
cbInspectFreq.Items.Add("全选");
|
List<MySQLInspectFrequency> list = BFZ.GetDataList(0, new Pagination());
|
if (list.Count > 0)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
string typename = list[i].Frequency;
|
cbInspectFreq.Items.Add(typename);
|
}
|
}
|
}
|
private void btnUpLoad_Click(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
ResultMessage r = NetWorkCheck.NetWorkCheckResult();
|
if (r.Count < 0)
|
{
|
MessageBox.Show(r.Msg, "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
|
}
|
else
|
{
|
DataTable dtinfo = BBIZ.GetInspectedItems();
|
if (dtinfo.Rows.Count > 0)
|
{
|
string sn = Guid.NewGuid().ToString();
|
DIXPad.RSLC.BizServiceProxy localProxy = new DIXPad.RSLC.BizServiceProxy(_ServiceUrl);
|
DataTable table = new DataTable(Guid.NewGuid().ToString());
|
table.Columns.Add("sn", typeof(string));
|
table.Columns.Add("InspectObjectId", typeof(int));
|
table.Columns.Add("InspectItemId", typeof(int));
|
table.Columns.Add("CheckType", typeof(string));
|
table.Columns.Add("InspectLimit", typeof(double));
|
table.Columns.Add("NGReason", typeof(string));
|
table.Columns.Add("TotalJudge", typeof(bool));
|
table.Columns.Add("InspectTimes", typeof(int));
|
table.Columns.Add("CreateTime", typeof(DateTime));
|
table.Columns.Add("InspectOperator", typeof(string));
|
table.Columns.Add("IsImprovedOnSite", typeof(bool));
|
table.Columns.Add("DealDetial", typeof(string));
|
table.Columns.Add("ReInspectTimes", typeof(int));
|
table.Columns.Add("ImgString", typeof(string));
|
table.Columns.Add("IsBackup", typeof(int));
|
for (int i = 0; i < dtinfo.Rows.Count; i++)
|
{
|
DataRow dr = table.NewRow();
|
dr["sn"] = sn;
|
dr["InspectObjectId"] = Convert.ToInt32(dtinfo.Rows[i]["InspectObjectId"].ToString());
|
dr["InspectItemId"] = Convert.ToInt32(dtinfo.Rows[i]["InspectItemId"].ToString());
|
dr["CheckType"] = dtinfo.Rows[i]["CheckType"].ToString();
|
dr["InspectLimit"] = double.Parse(dtinfo.Rows[i]["InspectLimit"].ToString());
|
dr["NGReason"] = dtinfo.Rows[i]["NGReason"].ToString();
|
string judge = dtinfo.Rows[i]["TotalJudge"].ToString();
|
if (judge == "True")
|
{
|
dr["TotalJudge"] = true;
|
}
|
else
|
{
|
dr["TotalJudge"] = false;
|
}
|
dr["InspectTimes"] = Convert.ToInt32(dtinfo.Rows[i]["InspectTimes"].ToString());
|
dr["CreateTime"] = Convert.ToDateTime(dtinfo.Rows[i]["CreateTime"].ToString());
|
dr["InspectOperator"] = dtinfo.Rows[i]["InspectOperator"];
|
string improved = dtinfo.Rows[i]["IsImprovedOnSite"].ToString();
|
if (improved == "1")
|
{
|
dr["IsImprovedOnSite"] = true;
|
}
|
else
|
{
|
dr["IsImprovedOnSite"] = false;
|
}
|
dr["DealDetial"] = dtinfo.Rows[i]["DealDetial"];
|
dr["ReInspectTimes"] = Convert.ToInt32(dtinfo.Rows[i]["ReInspectTimes"]);
|
if (dtinfo.Rows[i]["ImgString"].ToString() == "")
|
{
|
dr["ImgString"] = "";
|
}
|
else
|
{
|
dr["ImgString"] = dtinfo.Rows[i]["ImgString"].ToString();
|
}
|
dr["IsBackup"] = Convert.ToInt32(dtinfo.Rows[i]["isbackup"].ToString());
|
table.Rows.Add(dr);
|
}
|
|
Dictionary<string, string> dir = new Dictionary<string, string>();
|
dir.Add("sn", "sn");
|
dir.Add("InspectObjectId", "InspectObjectId");
|
dir.Add("InspectItemId", "InspectItemId");
|
dir.Add("CheckType", "CheckType");
|
dir.Add("InspectLimit", "InspectLimit");
|
dir.Add("NGReason", "NGReason");
|
dir.Add("TotalJudge", "TotalJudge");
|
dir.Add("InspectTimes", "InspectTimes");
|
dir.Add("CreateTime", "CreateTime");
|
dir.Add("InspectOperator", "InspectOperator");
|
dir.Add("IsImprovedOnSite", "IsImprovedOnSite");
|
dir.Add("DealDetial", "DealDetial");
|
dir.Add("ReInspectTimes", "ReInspectTimes");
|
dir.Add("ImgString", "ImgString");
|
dir.Add("IsBackup", "IsBackup");
|
Dictionary<string, object> pdir = new Dictionary<string, object>();
|
pdir.Add("@sn", sn);
|
|
string imgsn = Guid.NewGuid().ToString();
|
DataTable dtimg = BBIZ.GetImageItems();
|
DataTable imgtable = new DataTable(Guid.NewGuid().ToString());
|
imgtable.Columns.Add("TableSN", typeof(string));
|
imgtable.Columns.Add("SN", typeof(string));
|
imgtable.Columns.Add("ImgId", typeof(int));
|
imgtable.Columns.Add("ImgString", typeof(string));
|
for (int i = 0; i < dtimg.Rows.Count; i++)
|
{
|
DataRow dr = imgtable.NewRow();
|
dr["TableSN"] = imgsn;
|
dr["SN"] = dtimg.Rows[i]["SN"].ToString();
|
dr["ImgId"] = Convert.ToInt32(dtimg.Rows[i]["ImgId"].ToString());
|
dr["ImgString"] = dtimg.Rows[i]["ImgString"].ToString();
|
imgtable.Rows.Add(dr);
|
}
|
Dictionary<string, string> imgdir = new Dictionary<string, string>();
|
imgdir.Add("TableSN", "TableSN");
|
imgdir.Add("SN", "SN");
|
imgdir.Add("ImgId", "ImgId");
|
imgdir.Add("ImgString", "ImgString");
|
Dictionary<string, object> idir = new Dictionary<string, object>();
|
idir.Add("@sn", imgsn);
|
|
MsgObject msg = localProxy.WSBulkCopyDataToDBWithHook(table, "InspectItemInfoDetial", dir, pdir, "yp_InspectItemInfo_bk2", DIXPad.RSLC.DBKeys.DIX);
|
if (msg.Count > 0)
|
{
|
MsgObject msg1 = localProxy.WSBulkCopyDataToDBWithHook(imgtable, "ItemImgDetial", imgdir, idir, "yp_GetImageList", DIXPad.RSLC.DBKeys.DIX);
|
if (msg1.Count > 0)
|
{
|
BBIZ.UpdateInspectedItems();
|
MessageBox.Show("点检数据上传至服务端成功!", "上传成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
DataTable dt = OBIZ.GetAllInspectedItem("", "", "");
|
UploadDataGrid.ItemsSource = dt.DefaultView;
|
}
|
else
|
{
|
MessageBox.Show("点检数据上传至服务端失败!" + msg1.Msg, "上传失败", MessageBoxButton.OK, MessageBoxImage.Error);
|
}
|
}
|
else
|
{
|
MessageBox.Show("点检数据上传至服务端失败!" + msg.Msg, "上传失败", MessageBoxButton.OK, MessageBoxImage.Error);
|
}
|
}
|
else
|
{
|
MessageBox.Show("当前无可上传的点检数据!请点检其他设备后再进行上传!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
|
}
|
}
|
}
|
catch (Exception er)
|
{
|
MessageBox.Show(er.Message, "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
|
}
|
}
|
|
private void Page_Loaded(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
DataTable dt = OBIZ.GetAllInspectedItem("", "", "");
|
UploadDataGrid.ItemsSource = dt.DefaultView;
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show(ex.Message);
|
}
|
}
|
|
private void btnChange_Click(object sender, RoutedEventArgs e)
|
{
|
var a = UploadDataGrid.CurrentItem as DataRowView;
|
if (a != null)
|
{
|
MySQLInspectTypeBiz TBIZ = new MySQLInspectTypeBiz();
|
string inspecttypes = a.Row[3].ToString();
|
string loadstatus= a.Row[0].ToString();
|
string code = a.Row[5].ToString();
|
int times = Convert.ToInt32(a.Row[11].ToString());
|
List<MySQLInspectObject> list = OBIZ.GetDataList("InspectObjectCode", code, new Pagination());
|
if (list.Count > 0)
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
int inspecttypeid = list[i].InspectTypeId;
|
List<MySQLInspectType> tlist = TBIZ.GetDataList(inspecttypeid, new Pagination());
|
string inspecttypestr = tlist[0].Name;
|
if (inspecttypestr == inspecttypes)
|
{
|
DIXPadInspectItemPage dpi = new DIXPadInspectItemPage();
|
dpi.mpcObject = list[i];
|
dpi.InspectTimes = times;
|
dpi.Code = "Update";
|
dpi.loadstatus = loadstatus;
|
dpi.createtime = Convert.ToDateTime(a.Row[12].ToString());
|
this.NavigationService.Navigate(dpi);
|
}
|
}
|
}
|
}
|
}
|
|
private void cbInspectObjectType_DropDownOpened(object sender, EventArgs e)
|
{
|
GetInspectObjectType();
|
}
|
|
private void cbInspectArea_DropDownOpened(object sender, EventArgs e)
|
{
|
GetInspectArea();
|
}
|
|
private void cbInspectFreq_DropDownOpened(object sender, EventArgs e)
|
{
|
GetInspectFreq();
|
}
|
}
|
}
|