Example #1
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var item = new ShiftItem(DateTime.Today, DateTime.Today, "Shift");

            radioGroup1.Properties.Items.Add(item.ToRadioItem());
            SaveShiftItem();
        }
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (CheckInput())
     {
         ShiftItem         = GetItemFromInput();
         this.DialogResult = DialogResult.OK;
     }
 }
Example #3
0
        private void mnu_Add_Click(object sender, EventArgs e)
        {
            FrmShiftItemDetail frm = new FrmShiftItemDetail();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                ShiftItem item = frm.ShiftItem;
                item.ID = Guid.NewGuid();
                AddShiftItemToGridView(item);
            }
        }
Example #4
0
        public ShiftItem MapShift(ShiftModel shift)
        {
            var shiftItem = new ShiftItem
            {
                StartDateTime = shift.StartDate,
                EndDateTime   = shift.EndDate,
                Activities    = MapActivities(shift),
                Theme         = _shiftThemeMap.MapTheme(shift.ThemeCode)
            };

            return(shiftItem);
        }
Example #5
0
 private void ShowShiftItemOnRow(DataGridViewRow row, ShiftItem item)
 {
     row.Tag = item;
     row.Cells["colStartTime"].Value           = item.StartTime.ToString();
     row.Cells["colEndTime"].Value             = item.NextDay ? "第二天 " + item.EndTime.ToString() : item.EndTime.ToString();
     row.Cells["colLogAtStart"].Value          = item.LogAtStart ? "是" : "否";
     row.Cells["colLogAtEnd"].Value            = item.LogAtEnd ? "是" : "否";
     row.Cells["colBeforeStartTime"].Value     = (int)item.BeforeStartTime;
     row.Cells["colAfterEndTime"].Value        = (int)item.AfterEndTime;
     row.Cells["colAllowLateTime"].Value       = (int)item.AllowLateTime;
     row.Cells["colAllowLeaveEarlyTime"].Value = (int)item.AllowLeaveEarlyTime;
     row.Cells["colDuration"].Value            = (int)item.Duration;
 }
Example #6
0
 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         ShiftItem          item = dataGridView1.Rows[e.RowIndex].Tag as ShiftItem;
         FrmShiftItemDetail frm  = new FrmShiftItemDetail();
         frm.ShiftItem = item;
         if (frm.ShowDialog() == DialogResult.OK)
         {
             ShiftItem item1 = frm.ShiftItem;
             AddShiftItemToGridView(item1);
         }
     }
 }
 private void ItemShowing(ShiftItem shift)
 {
     txtStartHour.Value           = shift.StartTime.Hour;
     txtStartMinute.Value         = shift.StartTime.Minute;
     chkNextDay.Checked           = shift.NextDay;
     txtEndHour.Value             = shift.EndTime.Hour;
     txtEndMinute.Value           = shift.EndTime.Minute;
     chkLogAtStart.Checked        = shift.LogAtStart;
     chkLogAtEnd.Checked          = shift.LogAtEnd;
     txtAllowLateTime.Value       = shift.AllowLateTime;
     txtAllowLeaveEarlyTime.Value = shift.AllowLeaveEarlyTime;
     txtBeforeStartTime.Value     = shift.BeforeStartTime;
     txtAfterEndTime.Value        = shift.AfterEndTime;
     txtShiftTime.Value           = shift.Duration;
 }
        private ShiftItem GetItemFromInput()
        {
            ShiftItem shift = ShiftItem as ShiftItem;

            if (shift == null)
            {
                shift = new ShiftItem();
            }
            shift.StartTime           = new MyTime((int)txtStartHour.Value, (int)txtStartMinute.Value, 0);
            shift.NextDay             = chkNextDay.Checked;
            shift.EndTime             = new MyTime((int)txtEndHour.Value, (int)txtEndMinute.Value, 0);
            shift.LogAtStart          = chkLogAtStart.Checked;
            shift.LogAtEnd            = chkLogAtEnd.Checked;
            shift.AllowLateTime       = txtAllowLateTime.Value;
            shift.AllowLeaveEarlyTime = txtAllowLeaveEarlyTime.Value;
            shift.BeforeStartTime     = txtBeforeStartTime.Value;
            shift.AfterEndTime        = txtAfterEndTime.Value;
            shift.Duration            = txtShiftTime.Value;
            return(shift);
        }
Example #9
0
        private void AddShiftItemToGridView(ShiftItem item)
        {
            bool exists = false;

            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                ShiftItem si = row.Tag as ShiftItem;
                if (si.ID == item.ID)
                {
                    ShowShiftItemOnRow(row, item);
                    exists = true;
                    break;
                }
            }
            if (!exists)
            {
                int row = dataGridView1.Rows.Add();
                ShowShiftItemOnRow(dataGridView1.Rows[row], item);
            }
        }
Example #10
0
 protected override void UpdatingItem(Shift newVal, Shift original, AttendanceDataContext attendance)
 {
     attendance.GetTable <Shift>().Attach(newVal, original);
     foreach (ShiftItem item in newVal.Items)
     {
         ShiftItem old = original.Items.SingleOrDefault(it => it.ID == item.ID);
         if (old != null)
         {
             attendance.GetTable <ShiftItem>().Attach(item, old);
         }
         else
         {
             attendance.GetTable <ShiftItem>().InsertOnSubmit(item);
         }
     }
     foreach (ShiftItem item in original.Items)
     {
         if (newVal.Items.SingleOrDefault(it => it.ID == item.ID) == null)
         {
             attendance.GetTable <ShiftItem>().Attach(item);
             attendance.GetTable <ShiftItem>().DeleteOnSubmit(item);
         }
     }
 }
        public void AddShift(Position cursor_position, Point shift)
        {
            var indices = GetClosestShiftIndexes(cursor_position, 2);

            if (indices != null && indices[0].Item2 < Options.Instance.calibration_mode.zone_size)
            {
                Shifts[indices[0].Item1] = new ShiftItem(cursor_position, shift);
                if (indices.Count > 1 && indices[1].Item2 < Options.Instance.calibration_mode.zone_size)
                {
                    Shifts.RemoveAt(indices[1].Item1);
                }
            }
            else if (Shifts.Count() < Options.Instance.calibration_mode.max_zones_count)
            {
                Shifts.Add(new ShiftItem(cursor_position, shift));
            }
            else
            {
                Shifts[GetClosestPointOfHihestDensity(cursor_position)] = new ShiftItem(cursor_position, shift);
            }

            AsyncSaver.Save(Filepath, GetDeepCopy);
            NotifyOnChange();
        }
 private int GetSectorNumber(ShiftItem shift, int max_sector_x)
 {
     return(shift.Position.SectorX + shift.Position.SectorY * (max_sector_x + 1));
 }