工单开始传递信息修改
This commit is contained in:
commit
c3c724be3d
3 files changed
+49
-31
No files matched your search
@@ -38,14 +38,14 @@ namespace DyeingComputer.View
|
||||
InitializeComponent();
|
||||
//Grid.DataContext = new MainWindowViewModel();
|
||||
FocusManager.SetFocusedElement(Grid, Grid);
|
||||
if (workName != null)
|
||||
{
|
||||
TechnologicalProcess_Import();
|
||||
}
|
||||
else
|
||||
{
|
||||
// if (workName != null)
|
||||
// {
|
||||
// TechnologicalProcess_Import();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
TechnologicalProcess_sql();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
public static object workName;
|
||||
@@ -91,8 +91,12 @@ namespace DyeingComputer.View
|
||||
string sql_script = "select * from RUN";
|
||||
if (sql != null) sql.Clear(); //清空缓存
|
||||
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取表写入缓存
|
||||
MainWindowViewModel.ProgramName = SQLiteHelpers.ExecuteScalar("select Program from RUN where Step = '1'", null).ToString();
|
||||
MainWindowViewModel.WorkNumder = SQLiteHelpers.ExecuteScalar("select DYELOT from RUN where Step = '1'", null).ToString();
|
||||
try
|
||||
{
|
||||
MainWindowViewModel.ProgramName = SQLiteHelpers.ExecuteScalar("select Program from RUN where Step = '1'", null).ToString();
|
||||
MainWindowViewModel.WorkNumder = SQLiteHelpers.ExecuteScalar("select WorkOrder from RUN where Step = '1'", null).ToString();
|
||||
}
|
||||
catch (Exception) { }
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
if (sql != null) dt_TP = sql.Tables[0]; //转换显示计划表
|
||||
|
||||
+33
-20
@@ -23,6 +23,7 @@ using System.Xml.Linq;
|
||||
using static DyeingComputer.UserClass.SqliteHelper;
|
||||
using static DyeingComputer.Windows.ViewProgram;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
namespace DyeingComputer.View
|
||||
{
|
||||
@@ -59,7 +60,7 @@ namespace DyeingComputer.View
|
||||
}
|
||||
void Tick_Event_1S(object sender, EventArgs e)
|
||||
{
|
||||
Workorder_sql();
|
||||
if(!SQL_UPDATE) Workorder_sql();
|
||||
}
|
||||
|
||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
@@ -71,13 +72,14 @@ namespace DyeingComputer.View
|
||||
string Process_Name;
|
||||
string Process_id;
|
||||
string _lock;
|
||||
bool SQL_UPDATE = false;
|
||||
|
||||
public void Workorder_sql()
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
|
||||
string sql_script = "select * from WorkOrder where StartTime > '" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "'";
|
||||
string sql_script = "select * from WorkOrder where EndTime > '" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "'";
|
||||
|
||||
if (sql != null) sql.Clear(); //清空缓存
|
||||
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
||||
@@ -89,8 +91,6 @@ namespace DyeingComputer.View
|
||||
Process_Name = null;
|
||||
Process_id = null;
|
||||
_lock = null;
|
||||
//sql.Clear(); //清除缓存
|
||||
//System.GC.Collect();
|
||||
}
|
||||
|
||||
|
||||
@@ -166,34 +166,47 @@ namespace DyeingComputer.View
|
||||
Process_Name = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||
Process_id = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||
_lock = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||
|
||||
SQL_UPDATE = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控
|
||||
{
|
||||
if (e.Key == Key.Y) //按键y
|
||||
if (e.Key == Key.Y) //按键
|
||||
{
|
||||
if(string.IsNullOrEmpty(WorkOrder_Numder)) return;
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
string sql_script = "select * from ProgramName where ProgramID = '" + Process_id + "'";
|
||||
int i = SQLiteHelpers.ExecuteDataSet(sql_script, null).Tables[0].Rows.Count; //读取工艺表返回0工艺不存在
|
||||
|
||||
if (i == 0) //工艺不存在提示
|
||||
updata_temp.Clear(); //使用前清缓存
|
||||
updata_temp.Add("State", 101);
|
||||
SQLiteHelpers.Update("WorkOrder", updata_temp, "WorkOrder='" + WorkOrder_Numder + "'", null);
|
||||
|
||||
DataTable WorkorderSteps = SQLiteHelpers.ExecuteDataSet(
|
||||
"select * from WorkorderSteps where WorkOrder='" + WorkOrder_Numder + "'", null).Tables[0]; //读取表写入缓存
|
||||
MainWindowViewModel.ProgramName = Process_Name;
|
||||
SQLiteHelpers.Delete("RUN", null, null); //删除run信息
|
||||
DataTable data_t = new DataTable();
|
||||
data_t = WorkorderSteps.Clone();
|
||||
int a = WorkorderSteps.Rows.Count;
|
||||
for (int i = 0; i < a; i++)
|
||||
{
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
WorkOrder_Numder = null;
|
||||
Process_id = null;
|
||||
if (System.Windows.Forms.MessageBox.Show("["+Process_Name+"] "+ Properties.Resources.process_not, "800 ",
|
||||
System.Windows.Forms.MessageBoxButtons.OK) == System.Windows.Forms.DialogResult.OK) return;
|
||||
}
|
||||
else //否则修改工艺执行状态
|
||||
{
|
||||
updata_temp.Clear(); //使用前清缓存
|
||||
updata_temp.Add("State", 101);
|
||||
SQLiteHelpers.Update("WorkOrder", updata_temp, "ProgramID='" + Process_id + "'", null);
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
data_t.Clear();//清空
|
||||
DataRow dt = WorkorderSteps.Rows[i];//行转
|
||||
DataRow dr = data_t.NewRow();
|
||||
dr.ItemArray = dt.ItemArray;
|
||||
dr.BeginEdit(); //添加订单号
|
||||
dr["ProgramID"] = Process_id;
|
||||
dr["Program"] = MainWindowViewModel.ProgramName;
|
||||
dr.EndEdit();
|
||||
data_t.Rows.InsertAt(dr, 0); //行转换
|
||||
|
||||
SQLiteHelpers.InsertData("RUN", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
||||
}
|
||||
|
||||
SQLiteHelpers.Close(); //关闭连接
|
||||
|
||||
if (Process_id != null) //选定工艺有效跳转准备
|
||||
{
|
||||
MainWindowViewModel.WorkNumder = WorkOrder_Numder;
|
||||
|
||||
@@ -282,7 +282,8 @@ namespace DyeingComputer.ViewModel
|
||||
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
||||
{
|
||||
if (!LINK_OK) Modbus_link();
|
||||
Chart();//写入记录
|
||||
|
||||
if(WORK_RUN !=0) Chart();//写入记录
|
||||
|
||||
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 1) || (Selet_dtm("1010") > 160)))
|
||||
{ Name_err = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示
|
||||
@@ -1377,7 +1378,7 @@ namespace DyeingComputer.ViewModel
|
||||
}//清除输出状态
|
||||
if (string.IsNullOrEmpty(Name_err.ToString()))
|
||||
{
|
||||
WorkNumder = "----------";
|
||||
//WorkNumder = "----------";
|
||||
int TIMEH = DIDETime / 3600;
|
||||
int TIMEM = (DIDETime - TIMEH * 3600) / 60;
|
||||
int TIMES = DIDETime - TIMEH * 3600 - TIMEM * 60;
|
||||
|
||||
Reference in new issue
Block a user