示例#1
0
        private void FLastOnline_Load(object sender, System.EventArgs e)
        {
            _firstMsg = UserControl.MutiLanguages.ParserMessage("$Error_FirstOn_Time");            //{0}{1}产线首件上线时间是:{2};
            this.ucRCard.TextFocus(false, true);
            Messages msg = new Messages();

            _facade = new FirstOnlineFacade(this.DataProvider);

            //取产线
            BenQGuru.eMES.BaseSetting.BaseModelFacade _baseFacade = new BenQGuru.eMES.BaseSetting.BaseModelFacade(this.DataProvider);
            Resource res = (Resource)_baseFacade.GetResource(ApplicationService.Current().ResourceCode);

            if (res != null && res.StepSequenceCode != null)
            {
                this.ucSSName.Value = res.StepSequenceCode;
            }
            else
            {
                msg.Add(new UserControl.Message(MessageType.Error, this.ucSSName.Caption + "$Error_Input_Empty"));
                ApplicationRun.GetInfoForm().Add(msg);
                return;
            }

            int i = this._facade.BindShiftTime(this.cbxShiftTime.ComboBoxData.Items, res);

            if (i >= 0)
            {
                this.cbxShiftTime.ComboBoxData.SelectedIndex = i;
                UIShift shift = this.cbxShiftTime.ComboBoxData.SelectedItem as UIShift;
                if (shift != null)
                {
                    this.dtpEnd.Text = FormatHelper.ToTimeString(shift.EndTime);
                }
            }

            this.ucRCard.InnerTextBox.Multiline = false;
        }
示例#2
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();
            }
        }
示例#3
0
        //根据班次,产品代码,产线,查出今天做过的首件上线和跨天的班次昨天做的首件上线,填充在“上班时间”下拉列表中
        private void FillBeginTime()
        {
            #region 检查界面输入
            if (this.ucSSName.Value == string.Empty)
            {
                Messages msg = new Messages();
                msg.Add(new UserControl.Message(MessageType.Error, this.ucSSName.Caption + " $Error_Input_Empty"));
                ApplicationRun.GetInfoForm().Add(msg);
                this.ucRCard.TextFocus(false, true);
                return;
            }
            if (this.ucRCard.Value == string.Empty)
            {
                Messages msg = new Messages();
                msg.Add(new UserControl.Message(MessageType.Error, this.ucRCard.Caption + " $Error_Input_Empty"));
                ApplicationRun.GetInfoForm().Add(msg);
                this.ucRCard.TextFocus(false, true);
                return;
            }
            #endregion

            #region             //取得当前时间所在的班次

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

            #region 判断产品序列号是否存在
            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;

            if (sim == null)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_First_No_Rcard"));
                ucRCard.TextFocus(false, true);
                return;
            }
            else
            {
                _itemcode = sim.ItemCode;
            }
            #endregion

            //判断是否已经有上线了
            //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 dtShiftDay = dtNow;

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

            this.cbxBeginTime.ComboBoxData.Items.Clear();
            this._shiftCode = shift.ShiftCode;
            this._shiftDate = FormatHelper.TODateInt(dtShiftDay);

            //取出做的首件信息
            object[] objs = _facade.QueryFirst(this.ucSSName.Value, this._shiftDate, _itemcode, this._shiftCode);
            if (objs == null || objs.Length == 0)
            {
                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "请先做首件上/下线"));
                return;
            }

            foreach (BenQGuru.eMES.Domain.Alert.FirstOnline first in objs)
            {
                if (first != null)
                {
                    //将做过末件上线和下线的排除掉
                    if (first.LastType == LineActionType.ON || first.LastType == LineActionType.OFF)
                    {
                        continue;
                    }

                    this.cbxBeginTime.ComboBoxData.Items.Add(FormatHelper.ToTimeString(first.ShiftTime));
                }
            }
            if (this.cbxBeginTime.ComboBoxData.Items.Count > 0)
            {
                this.cbxBeginTime.ComboBoxData.SelectedIndex = 0;
            }
        }