Esempio n. 1
0
        protected void drpShiftTypeCodeEdit_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    DropDownListBuilder builder = new DropDownListBuilder(this.drpShiftTypeCodeEdit);
                    if (_facade == null)
                    {
                        _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
                    }
                    builder.HandleGetObjectList = new BenQGuru.eMES.Web.Helper.GetObjectListDelegate(this._facade.GetAllShiftType);

                    if (builder.HandleGetObjectList != null)
                    {
                        builder.Build("ShiftTypeDescription", "ShiftTypeCode");
                    }
                    else
                    {
                        this.drpShiftTypeCodeEdit.Items.Add(new ListItem("", ""));
                    }
                }
                catch (Exception)
                {
                    this.drpShiftTypeCodeEdit.Items.Add(new ListItem("", ""));
                }
            }
        }
Esempio n. 2
0
        //Bind上班时间下拉列表,返回根据当前时间选定的记录
        public int BindShiftTime(System.Collections.IList list, Resource res)
        {
            //根据res取得班制
            BenQGuru.eMES.BaseSetting.BaseModelFacade bm = new BenQGuru.eMES.BaseSetting.BaseModelFacade(this.DataProvider);

            if (res == null)
            {
                return(-1);
            }
            //Segment seg = bm.GetSegment(res.SegmentCode) as Segment;
            //if(seg == null) return -1;
            //string shifttype = seg.ShiftTypeCode;
            string shifttype = res.ShiftTypeCode;

            //根据
            BenQGuru.eMES.BaseSetting.ShiftModelFacade shift = new BenQGuru.eMES.BaseSetting.ShiftModelFacade(this.DataProvider);
            object[] objs = this.DataProvider.CustomQuery(typeof(Shift), new SQLCondition(string.Format("select {0} from TBLSHIFT where shifttypecode='{1}'order by SHIFTBTIME", DomainObjectUtility.GetDomainObjectFieldsString(typeof(Shift)), shifttype)));
            if (objs != null && objs.Length > 0)
            {
                foreach (object obj in objs)
                {
                    BenQGuru.eMES.Domain.BaseSetting.Shift s = obj as BenQGuru.eMES.Domain.BaseSetting.Shift;
                    if (s != null)
                    {
                        list.Add(new UIShift(s.ShiftCode, s.ShiftBeginTime, s.ShiftEndTime, s.IsOverDate));
                    }
                }
            }

            int time = FormatHelper.TOTimeInt(DateTime.Now);

            return(GetCurrShiftIndex(time, list));
        }
Esempio n. 3
0
        private void InitddlShiftCodeWhere()
        {
            if (ShiftFacade == null)
            {
                ShiftFacade = new ShiftModelFacade(base.DataProvider);
            }
            ;
            object[] objs = ShiftFacade.GetAllShift();
            this.ddlShiftCodeWhere.Items.Clear();


            this.ddlRating.Items.Clear();
            ddlRating.Items.Add(new ListItem("", ""));
            string[] ratingarr = new string[] { "很快", "快", "一般", "慢" };
            for (int i = 0; i < ratingarr.Length; i++)
            {
                ddlRating.Items.Add(new ListItem(ratingarr[i], ratingarr[i]));
            }
            ddlRating.Items[1].Selected = true;

            ddlShiftCodeWhere.Items.Add(new ListItem("", ""));
            if (objs != null)
            {
                foreach (Shift item in objs)
                {
                    ddlShiftCodeWhere.Items.Add(new ListItem(item.ShiftCode, item.ShiftCode));
                }
            }
            this.ddlMoTypeQuery.Items.Clear();
            ddlMoTypeQuery.Items.Add(new ListItem("", ""));
        }
Esempio n. 4
0
 protected override void UpdateDomainObject(object domainObject)
 {
     if (_facade == null)
     {
         _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
     }
     this._facade.UpdateShift((Shift)domainObject);
 }
Esempio n. 5
0
 protected override void DeleteDomainObjects(ArrayList domainObjects)
 {
     if (_facade == null)
     {
         _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
     }
     this._facade.DeleteShift((Shift[])domainObjects.ToArray(typeof(Shift)));
 }
Esempio n. 6
0
 protected override void AddDomainObject(object domainObject)
 {
     if (_facade == null)
     {
         _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
     }
     this._facade.AddShiftType((ShiftType)domainObject);
 }
Esempio n. 7
0
 protected override int GetRowCount()
 {
     if (_facade == null)
     {
         _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
     }
     return(this._facade.QueryShiftTypeCount(
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtShiftTypeCodeQuery.Text))));
 }
Esempio n. 8
0
 protected override object[] LoadDataSource(int inclusive, int exclusive)
 {
     if (_facade == null)
     {
         _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
     }
     return(this._facade.QueryShiftType(
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtShiftTypeCodeQuery.Text)),
                inclusive, exclusive));
 }
Esempio n. 9
0
 protected void drpShifTypeCode_Load(object sender, System.EventArgs e)
 {
     if (!IsPostBack)
     {
         DropDownListBuilder builder = new DropDownListBuilder(this.drpShifTypeCode);
         if (_shiftFacade == null)
         {
             _shiftFacade = new ShiftModelFacadeFactory(base.DataProvider).Create();
         }
         builder.HandleGetObjectList = new BenQGuru.eMES.Web.Helper.GetObjectListDelegate(this._shiftFacade.GetAllShiftType);
         builder.Build("ShiftTypeDescription", "ShiftTypeCode");
         this.drpShifTypeCode.Items.Insert(0, new ListItem("", ""));
     }
 }
Esempio n. 10
0
        protected override object GetEditObject()
        {
            if (_facade == null)
            {
                _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
            }
            ShiftType shiftType = this._facade.CreateNewShiftType();

            shiftType.ShiftTypeDescription = FormatHelper.CleanString(this.txtShiftTypeDescriptionEdit.Text, 100);
            shiftType.EffectiveDate        = 0;                     //FormatHelper.TODateInt(this.dateEffectiveDateEdit.Text);
            shiftType.InvalidDate          = 0;                     //FormatHelper.TODateInt(this.dateInvalidDateEdit.Text);
            shiftType.ShiftTypeCode        = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtShiftTypeCodeEdit.Text, 40));
            shiftType.MaintainUser         = this.GetUserCode();

            return(shiftType);
        }
Esempio n. 11
0
 private void InitddlShiftCodeWhere()
 {
     if (ShiftFacade == null)
     {
         ShiftFacade = new ShiftModelFacade(base.DataProvider);
     }
     ;
     object[] objs = ShiftFacade.GetAllShift();
     this.ddlShiftCodeWhere.Items.Clear();
     ddlShiftCodeWhere.Items.Add(new ListItem("", ""));
     if (objs != null)
     {
         foreach (Shift item in objs)
         {
             ddlShiftCodeWhere.Items.Add(new ListItem(item.ShiftCode, item.ShiftCode));
         }
     }
 }
Esempio n. 12
0
        protected void ddlShiftCodeWhere_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ShiftFacade == null)
            {
                ShiftFacade = new ShiftModelFacade(base.DataProvider);
            }
            ;
            string shiftcode = this.ddlShiftCodeWhere.SelectedValue;

            object[] tpcodeobjs = ShiftFacade.GetTimePeriodByShiftCode(shiftcode);
            if (tpcodeobjs != null)
            {
                foreach (TimePeriod item in tpcodeobjs)
                {
                    ddlMoTypeQuery.Items.Add(new ListItem(item.TimePeriodCode, item.TimePeriodCode));
                }
            }
        }
Esempio n. 13
0
        protected override object GetEditObject()
        {
            if (_facade == null)
            {
                _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
            }
            Shift shift = this._facade.CreateNewShift();

            shift.ShiftDescription = FormatHelper.CleanString(this.txtShiftDescriptionEdit.Text, 100);
            shift.ShiftBeginTime   = FormatHelper.TOTimeInt(this.timeShiftBeginTimeEdit.Text);
            shift.ShiftEndTime     = FormatHelper.TOTimeInt(this.timeShiftEndTimeEdit.Text);
            shift.IsOverDate       = FormatHelper.BooleanToString(this.chbIsOverDateEdit.Checked);
            shift.ShiftSequence    = System.Decimal.Parse(this.txtShiftSequenceEdit.Text);
            shift.ShiftCode        = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtShiftCodeEdit.Text, 40));
            shift.ShiftTypeCode    = this.drpShiftTypeCodeEdit.SelectedValue;
            shift.MaintainUser     = this.GetUserCode();

            return(shift);
        }
Esempio n. 14
0
        protected override object GetEditObject(GridRecord row)
        {
            if (_facade == null)
            {
                _facade = new ShiftModelFacadeFactory(base.DataProvider).Create();
            }
            string strCode = string.Empty;
            object objCode = row.Items.FindItemByKey("ShiftCode").Value;

            if (objCode != null)
            {
                strCode = objCode.ToString();
            }
            object obj = _facade.GetShift(strCode);

            if (obj != null)
            {
                return((Shift)obj);
            }
            return(null);
        }
Esempio n. 15
0
        private string[] GetArrayFrom(DomainObject domain)
        {
            BenQGuru.eMES.Domain.Alert.FirstOnline obj = domain as BenQGuru.eMES.Domain.Alert.FirstOnline;
            if (obj != null)
            {
                string offtime = obj.OffLineTime == 0?string.Empty:FormatHelper.ToTimeString(obj.OffLineTime);

                //班次
                BenQGuru.eMES.BaseSetting.ShiftModelFacade shiftFacade = new BenQGuru.eMES.BaseSetting.ShiftModelFacade(this.DataProvider);
                BenQGuru.eMES.Domain.BaseSetting.Shift     shift       = shiftFacade.GetShift(obj.ShiftCode) as BenQGuru.eMES.Domain.BaseSetting.Shift;
                if (shift == null)
                {
                    return(null);
                }

                #region 首台下线耗时
                string tmOff = string.Empty;
                if (obj.ActionType == "OFF")
                {
                    //如果跨天,并且是在第二天
                    if (obj.OffLineTime < obj.ShiftTime && obj.IsOverDay == FormatHelper.TRUE_STRING)
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.OffLineTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime));
                        int      tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmOff = tm.ToString();
                    }
                    else
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.OffLineTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime));

                        int tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmOff = tm.ToString();
                    }
                }
                #endregion

                #region 生产准备耗时
                //如果跨天,并且是在第二天
                string tmOn = string.Empty;
                if (obj.OnLineTime < shift.ShiftEndTime                //上线时间在第二天
                    &&
                    obj.OnLineTime < obj.ShiftTime                     ///上班时间在第一天
                    &&
                    obj.ShiftTime > shift.ShiftEndTime 
                    &&
                    obj.IsOverDay == FormatHelper.TRUE_STRING)
                {
                    TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.ShiftTime));
                    int      tm  = it2.Hours * 60 + it2.Minutes;
                    if (tm >= 24 * 60)
                    {
                        tm = 24 * 60 - tm;
                    }
                    tmOn = tm.ToString();
                }
                else
                {
                    TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.OnLineTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.ShiftTime));
                    int      tm  = it2.Hours * 60 + it2.Minutes;
                    if (tm >= 24 * 60)
                    {
                        tm = 24 * 60 - tm;
                    }
                    tmOn = tm.ToString();
                }
                #endregion

                #region 末台下线耗时
                string tmLastOff = string.Empty;
                if (obj.LastType == "OFF")
                {
                    //如果跨天,上线和下线不在同一天
                    if (obj.LastOffTime < obj.LastOnTime && obj.IsOverDay == FormatHelper.TRUE_STRING)
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOnTime));
                        int      tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOff = tm.ToString();
                    }
                    else
                    {
                        TimeSpan it = DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOnTime));
                        int      tm = it.Hours * 60 + it.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOff = tm.ToString();
                    }
                }
                #endregion

                #region 无效生产时间
                //如果跨天,且下班时间和末件下线采集时间不在同一天
                string tmLastOn = string.Empty;
                if (obj.LastType == "OFF")
                {
                    //下班时间比上班时间小,末件下线比上班时间大,并且比下班时间大,则下线位于前一天,下班位于后一天
                    if (
                        obj.ShiftTime > shift.ShiftEndTime                  //上班时间在第一天
                        &&
                        obj.EndTime < obj.ShiftTime                         ///下班时间在第二天
                        &&
                        obj.LastOffTime > obj.ShiftTime                     ///采集时间在第1天
                        &&
                        obj.IsOverDay == FormatHelper.TRUE_STRING)
                    {
                        TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.EndTime)).AddDays(1) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime));
                        int      tm  = it2.Hours * 60 + it2.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOn = tm.ToString();
                    }
                    else
                    {
                        TimeSpan it2 = DateTime.Parse(FormatHelper.ToTimeString(obj.EndTime)) - DateTime.Parse(FormatHelper.ToTimeString(obj.LastOffTime));
                        int      tm  = it2.Hours * 60 + it2.Minutes;
                        if (tm >= 24 * 60)
                        {
                            tm = 24 * 60 - tm;
                        }

                        tmLastOn = tm.ToString();
                    }
                }
                #endregion

                return(new string[] {
                    FormatHelper.ToDateString(obj.MaintainDate),
                    obj.ShiftCode,
                    obj.SSCode,
                    obj.ItemCode,
                    FormatHelper.ToTimeString(obj.ShiftTime),
                    FormatHelper.ToTimeString(obj.OnLineTime),
                    offtime,
                    tmOff,
                    tmOn,
                    FmtTime(obj.EndTime),
                    FmtTime(obj.LastOnTime),
                    FmtTime(obj.LastOffTime),
                    tmLastOff,
                    tmLastOn
                });
            }

            return(null);
        }
Esempio n. 16
0
        /// <summary>
        /// 1.sequence must greater than exsited ones
        /// 2.start datetime must greater than the last timeperiod which sequence
        ///	  equals to the this sequence - 1
        ///	3.this datetime must connected to the end date time of last one.
        ///	  eg.last one is 11:59:59,the start of the this one must be 12:00:00
        /// </summary>
        /// <returns></returns>
        bool BenQGuru.eMES.Web.Helper.ICheck.Check()
        {
            DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

            #region TimePeriod本身的时间检查
            TimePeriod currTimePeriod = new TimePeriod();

            currTimePeriod.TimePeriodSequence  = this._timePeriod.TimePeriodSequence;
            currTimePeriod.TimePeriodBeginTime = this._timePeriod.TimePeriodBeginTime;
            currTimePeriod.TimePeriodEndTime   = this._timePeriod.TimePeriodEndTime;
            currTimePeriod.IsOverDate          = this._timePeriod.IsOverDate;

            this.adjustTimePeriodTime(currTimePeriod);

            // 起始时间应小于结束时间
            if (currTimePeriod.TimePeriodBeginTime >= currTimePeriod.TimePeriodEndTime)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_TimePeriod_BeginTime_Greater_Than_EndTime");
                return(false);
            }
            #endregion

            #region 取出同一Shift下的所有TimePeriod,并按Sequence排序
            object obj = new ShiftModelFacade(this.DataProvider).GetShift(this._timePeriod.ShiftCode);

            if (obj == null)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_TimePeriod_Shift_Not_Exist");
                return(false);
            }

            int shiftBeginTime = ((Shift)obj).ShiftBeginTime;
            int shiftEndTime   = ((Shift)obj).ShiftEndTime;

            if (((Shift)obj).IsOverDate == FormatHelper.TRUE_STRING)
            {
                if (shiftEndTime < shiftBeginTime)
                {
                    shiftEndTime = shiftEndTime + 240000;
                }
                else
                {
                    shiftBeginTime = shiftBeginTime + 240000;
                    shiftEndTime   = shiftEndTime + 240000;
                }
            }

            //从数据库中取出同一Shift下,当前TimePeriod之前的所有TimePeriod
            object[] prevTimePeriods = this.DataProvider.CustomQuery(
                typeof(TimePeriod),
                new SQLCondition(string.Format("select {0} from tbltp where shiftcode= '{1}' and tpseq <= {2} and tpcode <> '{3}' order by tpseq",
                                               DomainObjectUtility.GetDomainObjectFieldsString(typeof(TimePeriod)),
                                               this._timePeriod.ShiftCode,
                                               this._timePeriod.TimePeriodSequence,
                                               this._timePeriod.TimePeriodCode)));

            //从数据库中取出同一Shift下,当前TimePeriod之后的所有TimePeriod
            object[] nextTimePeriods = this.DataProvider.CustomQuery(
                typeof(TimePeriod),
                new SQLCondition(string.Format("select {0} from tbltp where shiftcode= '{1}' and tpseq >= {2} and tpcode <> '{3}' order by tpseq",
                                               DomainObjectUtility.GetDomainObjectFieldsString(typeof(TimePeriod)),
                                               this._timePeriod.ShiftCode,
                                               this._timePeriod.TimePeriodSequence,
                                               this._timePeriod.TimePeriodCode)));
            #endregion

            #region 将跨日期后的TimePeriod的时间加24小时
            if (prevTimePeriods != null)
            {
                foreach (TimePeriod timePeriod in prevTimePeriods)
                {
                    this.adjustTimePeriodTime(timePeriod);
                }
            }

            if (nextTimePeriods != null)
            {
                foreach (TimePeriod timePeriod in nextTimePeriods)
                {
                    this.adjustTimePeriodTime(timePeriod);
                }
            }
            #endregion

            #region 时间交叉判断
            // 当前TimePeriod是第一个
            if (prevTimePeriods == null || prevTimePeriods.Length == 0)
            {
                // TimePeriod起始时间不能小于Shift的起始时间
                if (currTimePeriod.TimePeriodBeginTime != shiftBeginTime)
                {
                    ExceptionManager.Raise(this.GetType(), "$Error_First_TimePeriod_Should_Be_Shift_BeginTime");
                    return(false);
                }
            }
            else
            {
                //DateTime temp = FormatHelper.ToDateTime(currentDateTime.DBDate, ((TimePeriod)prevTimePeriods[prevTimePeriods.Length - 1]).TimePeriodEndTime);
                //int tempEndTime = FormatHelper.TOTimeInt(temp.AddSeconds(1));
                int tempEndTime = FormatHelper.TimeAddSeconds(((TimePeriod)prevTimePeriods[prevTimePeriods.Length - 1]).TimePeriodEndTime, 1);


                // TimePeriod的起始时间必须与上一个TimePeriod的结束时间连续
                if (tempEndTime != currTimePeriod.TimePeriodBeginTime)
                {
                    ExceptionManager.Raise(this.GetType(), "$Error_TimePeriod_Time_Should_Be_Continuous");
                    return(false);
                }
            }

            if (nextTimePeriods == null || nextTimePeriods.Length == 0)
            {
                // TimePeriod的结束时间不能大于Shift的结束时间
                if (currTimePeriod.TimePeriodEndTime > shiftEndTime)
                {
                    ExceptionManager.Raise(this.GetType(), "$Error_TimePeriod_EndTime_Greater_Than_Shift_EndTime");
                    return(false);
                }
            }
            else
            {
                //DateTime temp = FormatHelper.ToDateTime(currentDateTime.DBDate, currTimePeriod.TimePeriodEndTime);
                //int tempEndTime = FormatHelper.TOTimeInt(temp.AddSeconds(1));
                int tempEndTime = FormatHelper.TimeAddSeconds(currTimePeriod.TimePeriodEndTime, 1);

                // TimePeriod的结束时间必须与下一个TimePeriod的起始时间连续
                if (tempEndTime != ((TimePeriod)nextTimePeriods[0]).TimePeriodBeginTime)
                {
                    ExceptionManager.Raise(this.GetType(), "$Error_TimePeriod_Time_Should_Be_Continuous");
                    return(false);
                }
            }
            #endregion

            return(true);
        }