private bool Update(Model.Tracking trackModel, Model.History hisModel, Model.MixHistory mixModel) { BLL.MixHistory mixBLL = new BLL.MixHistory(); BLL.Tracking trackBLL = new BLL.Tracking(); BLL.History hisBLL = new BLL.History(); List <SqlCommand> cmdList = new List <SqlCommand>(); if (trackModel != null) { cmdList.Add(trackBLL.UpdateCommand(trackModel)); } if (hisModel != null) { cmdList.Add(hisBLL.AddCommand(hisModel)); } cmdList.Add(mixBLL.AddCommand(mixModel)); return(Common.DB.SqlDB.SetData_Rollback(cmdList, Common.DB.Connection.SqlServer.EMS)); }
private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //检测 是否把epoxy拿了出来. //bool isMaterialIn = Hardware.IO_LIST.Input.X207_Mix_Material_In(); //while (isMaterialIn) //{ // MessageBox.Show("Mixing complete, please open door and take out epoxy!"); // //重新检下测感应器状态. // isMaterialIn = Hardware.IO_LIST.Input.X207_Mix_Material_In(); //} //更新数据库 Model.MixHistory mixModel = new Model.MixHistory(); mixModel.PART_ID = this.txt_partID_input.Text; mixModel.MIX_TIME = decimal.Parse(mixTime.ToString()); mixModel.MIX_DATETIME = DateTime.Now; mixModel.MIX_BY = this.txt_userID.Text; mixModel.REMARK = ""; BLL.Tracking trackBLL = new BLL.Tracking(); Model.Tracking trackModel = trackBLL.GetModel(this.txt_partID.Text); if (trackModel != null) { trackModel.STATUS = StaticRes.Global.Status.Unload; trackModel.UPDATED_TIME = DateTime.Now; trackModel.ACTION = "Mix"; } BLL.History hisBLL = new BLL.History(); Model.History hisModel = hisBLL.CopyTrackModel(trackModel); if (!Update(trackModel, hisModel, mixModel)) { MessageBox.Show("Update database fail!"); Common.Reports.LogFile.Log("[Mix] [BackgroundWorker_RunWorkerCompleted] - Update database fail partID:" + this.txt_partID.Text); } //init 变量 onGoing = false; runningTime = 0; this.pb.Value = 0; //init ui InitMaterialInfo(); this.txt_partID_input.Text = ""; this.txt_partID_input.IsEnabled = true; this.txt_partID_input.Focus(); this.txt_partID_input.Background = StaticRes.ColorBrushes.Linear_Green; ShowWindow(); this.txt_Msg.Text = "搅拌完成, 请取出后关闭或继续搅拌."; }