Ejemplo n.º 1
0
        private void DoAction()
        {
            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);

                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                Messages msg = new Messages();

                //取得当前时间所在的班次
                int i = _facade.GetCurrShiftIndex(FormatHelper.TOTimeInt(this.dtpBegin.Text), this.cbxShiftTime.ComboBoxData.Items);
                if (i != -1)
                {
                    this.cbxShiftTime.ComboBoxData.SelectedIndex = i;
                }
                else
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "选择的时间没有班次"));                    //请选择班次
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }
                UIShift shift = this.cbxShiftTime.ComboBoxData.SelectedItem as UIShift;
                if (shift == null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$班次不存在"));                    //请选择班次
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                BenQGuru.eMES.DataCollect.DataCollectFacade dcFacade = new DataCollectFacade(this.DataProvider);
                BenQGuru.eMES.Domain.DataCollect.Simulation sim      = dcFacade.GetSimulation(ucRCard.InnerTextBox.Text.Trim()) as BenQGuru.eMES.Domain.DataCollect.Simulation;

                string itemcode;
                if (sim == null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "$Error_First_No_Rcard"));                    //产线上不存在这个产品序列号
                    ApplicationRun.GetInfoForm().Add(msg);
                    ucRCard.TextFocus(false, true);
                    return;
                }
                else
                {
                    itemcode = sim.ItemCode;
                }

                //判断是否已经有上线了
                DateTime dtShiftDay = dtNow;

                /////如是跨天的班次,并且是处在第二天,则用前一天做为上线日期
                if (shift.IsOverDay == FormatHelper.TRUE_STRING)
                {
                    if (FormatHelper.TOTimeInt(dtShiftDay) < shift.EndTime)
                    {
                        dtShiftDay = dtShiftDay.AddDays(-1);
                    }
                }

                #region                 //判断时间规则:班次起始时间<=上班时间<=NOW<=班次终止时间
//				int shiftBegin = shift.BeginTime; //班次起始时间
//
//				int begin = FormatHelper.TOTimeInt(this.dtpBegin.Text); //上班时间
//				if(shift.IsOverDay == FormatHelper.TRUE_STRING && begin <shiftBegin)
//					begin += 1000000;
//
//				int iNow = FormatHelper.TOTimeInt(dtNow);//NOW
//				if(shift.IsOverDay == FormatHelper.TRUE_STRING && iNow < shiftBegin)
//					iNow += 1000000;
//
//				//下班时间
//				int shiftEnd = shift.EndTime;
//				if(shift.IsOverDay == FormatHelper.TRUE_STRING)
//					shiftEnd += 1000000;
//
//				if(!
//					(shiftBegin<=begin
//					&&
//					begin<=iNow
//					&&
//					iNow<=shiftEnd)
//					)
//				{
//					if(MessageBox.Show("上班时间可能输入错误(规则为:班次起始时间<=上班时间<=上线时间<=班次终止时间),是否继续?",
//															"确认要继续",
//															MessageBoxButtons.YesNo)==DialogResult.No)
//						return;
//				}
                #endregion

                object obj = _facade.GetFirstOnline(this.ucSSName.Value, FormatHelper.TODateInt(dtShiftDay), itemcode, shift.ShiftCode, FormatHelper.TOTimeInt(this.dtpBegin.Text));
                BenQGuru.eMES.Domain.Alert.FirstOnline first = obj as BenQGuru.eMES.Domain.Alert.FirstOnline;

                if (first != null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "今天这个上班时间,此产线上此产品已经有一个上线首件"));                   //"$Error_FirstOn_Repeat")); //今天这个班次,此产线上此产品已经有一个上线首件
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }
                try
                {
                    this.DataProvider.BeginTransaction();

                    first                   = _facade.CreateNewFirstOnline();
                    first.ItemCode          = itemcode;
                    first.ModelCode         = sim.ModelCode;
                    first.SSCode            = this.ucSSName.Value;
                    first.RunningCard       = this.ucRCard.Value;
                    first.OfflineRuningCard = string.Empty;
                    first.ActionType        = LineActionType.ON;
                    first.MaintainDate      = FormatHelper.TODateInt(dtShiftDay);                ////如是跨天的班次,并且是处在第二天,则用前一天做为上线日期
                    first.MaintianUser      = ApplicationService.Current().UserCode;
                    first.OffLineTime       = 0;
                    first.OnLineTime        = FormatHelper.TOTimeInt(dtNow);
                    first.ShiftCode         = shift.ShiftCode;
                    first.ShiftTime         = FormatHelper.TOTimeInt(this.dtpBegin.Text);
                    first.IsOverDay         = shift.IsOverDay;

                    this.DataProvider.Insert(first);

                    ucMessage.Add(new UserControl.Message("上班时间" + this.dtpBegin.Text + "," +
                                                          String.Format(_firstMsg,
                                                                        dtShiftDay.ToLongDateString(),
                                                                        first.SSCode,
                                                                        first.ItemCode,
                                                                        FormatHelper.ToTimeString(first.OnLineTime)
                                                                        )
                                                          )
                                  );

                    this.DataProvider.CommitTransaction();
                    msg.Add(new UserControl.Message(MessageType.Success, "$Error_FirstOn_Sucess"));                    //首件上线成功
                    ApplicationRun.GetInfoForm().Add(msg);
                }
                catch (System.Exception ex)
                {
                    this.DataProvider.RollbackTransaction();
                    msg.Add(new UserControl.Message(MessageType.Success, 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();
            }
        }
Ejemplo n.º 2
0
        //执行末件上线动作
        private void ucBtnOK_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (this.cbxBeginTime.ComboBoxData.SelectedIndex == -1)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "请先选择首件的上班时间"));
                    return;
                }

                Messages msg = new Messages();

                object obj_on = _facade.GetFirstOnline(this.ucSSName.Value, this._shiftDate, _itemcode, _shiftCode, FormatHelper.TOTimeInt(this.cbxBeginTime.ComboBoxData.SelectedItem.ToString()));
                BenQGuru.eMES.Domain.Alert.FirstOnline first_on = obj_on as BenQGuru.eMES.Domain.Alert.FirstOnline;
                if (first_on == null)
                {
                    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;
                }

                if (first_on.LastType == LineActionType.OFF)
                {
                    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.LastOnRCard = this.ucRCard.Value.Trim();
                    first_on.LastType    = LineActionType.ON;
                    first_on.LastOnTime  = FormatHelper.TOTimeInt(dtNow);
                    first_on.EndTime     = FormatHelper.TOTimeInt(this.dtpEnd.Text);

                    this.DataProvider.BeginTransaction();

                    this.DataProvider.Update(first_on);

                    ucMessage.Add("下班时间" + this.dtpEnd.Text + "," +
                                  "产线" + first_on.SSCode + "," +
                                  "产品代码" + first_on.ItemCode + "," +
                                  "末件上线时间" + FormatHelper.ToTimeString(first_on.LastOnTime)
                                  );

                    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.ucRCard.Value = string.Empty;
                this.ucRCard.TextFocus(false, true);
                CloseConnection();
            }
        }
Ejemplo n.º 3
0
        private void DoAction()
        {
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                Messages msg = new Messages();

                UIFirstOnline ufo = this.cbxBeginTime.ComboBoxData.SelectedItem as UIFirstOnline;
                if (ufo == null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "请选择上班时间"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                //取得班次信息
                BenQGuru.eMES.BaseSetting.ShiftModelFacade bf    = new BenQGuru.eMES.BaseSetting.ShiftModelFacade(this.DataProvider);
                BenQGuru.eMES.Domain.BaseSetting.Shift     shift = bf.GetShift(ufo._first.ShiftCode) as BenQGuru.eMES.Domain.BaseSetting.Shift;
                if (shift == null)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "班次不存在"));
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                string itemcode = ufo._first.ItemCode;

                //2006/11/17,Laws Lu add get DateTime from db Server
                DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                DateTime dtNow = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime);

                //DateTime dtNow = DateTime.Now;
                _facade = new FirstOnlineFacade(this.DataProvider);

                DateTime dtShiftDay = dtNow;

                /////如是跨天的班次,并且是处在第二天,则用前一天做为上线日期
                if (shift.IsOverDate == FormatHelper.TRUE_STRING)
                {
                    if (FormatHelper.TOTimeInt(dtShiftDay) < shift.ShiftEndTime)
                    {
                        dtShiftDay = dtShiftDay.AddDays(-1);
                    }
                }

                //object obj_on = _facade.GetFirstOnline(this.ucSSName.Value,FormatHelper.TODateInt(dtShiftDay),itemcode,ul._first.ShiftCode,FormatHelper.TOTimeInt(this.dtpBegin.Text));

                BenQGuru.eMES.Domain.Alert.FirstOnline first_on = ufo._first;                 //= obj_on as BenQGuru.eMES.Domain.Alert.FirstOnline;
//				if(first_on == null)
//				{
//					msg.Add(new UserControl.Message(MessageType.Error,"今天这个上班时间,此产线上此产品还没有首件上线"));//,"$Error_FirstOn_None")); //今天这个班次,此产线上此产品还没有首件上线
//					ApplicationRun.GetInfoForm().Add(msg);
//					return;
//				}

                if (first_on.ActionType == LineActionType.OFF)
                {
                    msg.Add(new UserControl.Message(MessageType.Error, "今天这个上班时间,此产线上此产品已经有一个下线首件"));                   //"$Error_FirstOff_Repeat")); //今天这个班次,此产线上此产品已经有一个下线首件
                    ApplicationRun.GetInfoForm().Add(msg);
                    return;
                }

                try
                {
                    first_on.OfflineRuningCard = this.ucRCard.InnerTextBox.Text.Trim();
                    first_on.ActionType        = LineActionType.OFF;
                    first_on.OffLineTime       = FormatHelper.TOTimeInt(dtNow);

                    this.DataProvider.BeginTransaction();

                    this.DataProvider.Update(first_on);

                    TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(first_on.OffLineTime)) - DateTime.Parse(FormatHelper.ToTimeString(first_on.OnLineTime));

                    //如果跨天,并且是在第二天
                    if (shift.IsOverDate == FormatHelper.TRUE_STRING && FormatHelper.TOTimeInt(dtShiftDay) < shift.ShiftEndTime)
                    {
                        it = DateTime.Parse(FormatHelper.ToTimeString(first_on.OffLineTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(first_on.OnLineTime));
                    }


                    ucMessage.Add(new UserControl.Message("上班时间" + FormatHelper.ToTimeString(first_on.ShiftTime) + "," +
                                                          String.Format(_firstMsg,
                                                                        (DateTime.Parse((FormatHelper.ToDateString(first_on.MaintainDate)))).ToLongDateString(),
                                                                        first_on.SSCode,
                                                                        first_on.ItemCode,
                                                                        FormatHelper.ToTimeString(first_on.OnLineTime)
                                                                        )
                                                          )
                                  );

                    ucMessageOff.Add(new UserControl.Message("上班时间" + FormatHelper.ToTimeString(first_on.ShiftTime) + "," +
                                                             String.Format(_offMsg,
                                                                           (DateTime.Parse((FormatHelper.ToDateString(first_on.MaintainDate)))).ToLongDateString(),
                                                                           first_on.SSCode,
                                                                           first_on.ItemCode,
                                                                           FormatHelper.ToTimeString(first_on.OffLineTime),
                                                                           it.Hours,
                                                                           it.Minutes
                                                                           )
                                                             )
                                     );

                    this.DataProvider.CommitTransaction();
                    msg.Add(new UserControl.Message(MessageType.Success, "$Error_FirstOff_Sucess"));                    //首件下线成功
                    ApplicationRun.GetInfoForm().Add(msg);
                    this.cbxBeginTime.ComboBoxData.Items.Clear();
                }
                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();
            }
        }
Ejemplo n.º 4
0
        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();
            }
        }