//根据用户选择的下班时间,构建上班时间供选择 private void cbxEndTime_SelectedIndexChanged(object sender, System.EventArgs e) { UILastOnline ul = this.cbxEndTime.ComboBoxData.SelectedItem as UILastOnline; this.txtBeginTime.Value = FormatHelper.ToTimeString(ul._first.ShiftTime); }
private void btnOffline_Click(object sender, System.EventArgs e) { try { if (this.cbxEndTime.ComboBoxData.SelectedIndex == -1) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "请选择下班时间")); ucRCard.TextFocus(false, true); return; } Messages msg = new Messages(); UILastOnline ul = this.cbxEndTime.ComboBoxData.SelectedItem as UILastOnline; BenQGuru.eMES.Domain.Alert.FirstOnline first_on = ul._first; if (first_on == null) { msg.Add(new UserControl.Message(MessageType.Error, "请先做首件上/下线")); ApplicationRun.GetInfoForm().Add(msg); return; } if (first_on.LastType == LineActionType.OFF) { msg.Add(new UserControl.Message(MessageType.Error, "已经做过末件下线了")); ApplicationRun.GetInfoForm().Add(msg); return; } if (first_on.LastType != LineActionType.ON) { msg.Add(new UserControl.Message(MessageType.Error, "请先做末件上线")); ApplicationRun.GetInfoForm().Add(msg); return; } try { //2006/11/17,Laws Lu add get DateTime from db Server DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider); DateTime dtNow = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime); first_on.LastOffRCard = this.ucRCard.Value.Trim(); first_on.LastType = LineActionType.OFF; first_on.LastOffTime = FormatHelper.TOTimeInt(dtNow); this.DataProvider.BeginTransaction(); this.DataProvider.Update(first_on); ucMessage.Add("下班时间" + this.cbxEndTime.ComboBoxData.SelectedItem.ToString() + "," + "产线" + first_on.SSCode + "," + "产品代码" + first_on.ItemCode + "," + "末件下线时间" + FormatHelper.ToTimeString(first_on.LastOffTime) ); this.DataProvider.CommitTransaction(); msg.Add(new UserControl.Message(MessageType.Success, "末件下线成功")); // ClearForm(); ApplicationRun.GetInfoForm().Add(msg); } catch (System.Exception ex) { this.DataProvider.RollbackTransaction(); msg.Add(new UserControl.Message(MessageType.Error, ex.Message)); ApplicationRun.GetInfoForm().Add(msg); } } finally { this.Cursor = System.Windows.Forms.Cursors.Arrow; this.ucRCard.Value = string.Empty; this.ucRCard.TextFocus(false, true); CloseConnection(); } }