예제 #1
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            if (!_DateColumns.Contains(GridView.Columns[e.ColumnIndex]))
            {
                return;
            }
            if (!Operator.CurrentOperator.Permit(Permission.ShiftArrange))
            {
                return;
            }
            Staff    staff = GridView.Rows[e.RowIndex].Tag as Staff;
            DateTime dt    = Convert.ToDateTime(GridView.Columns[e.ColumnIndex].Tag);

            if (staff.HireDate.Date > dt.Date)
            {
                return;                                 //人员入职日期之前不必排班
            }
            List <Shift>      shifts = GridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag as List <Shift>;
            FrmShiftSelection frm    = new FrmShiftSelection();

            frm.SelectedShifts = shifts;
            frm.StartPosition  = FormStartPosition.Manual;
            //让选择窗体刚好位于单元格下方,或者当下方显示不下时显示在上方
            Rectangle r = GridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);

            frm.Location = GetFrmSelectionPosition(r, frm);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                List <Shift>  selectedItems = frm.SelectedShifts;
                CommandResult ret           = (new ShiftArrangeBLL(AppSettings.CurrentSetting.ConnectUri)).ShiftArrange(staff.ID, dt, selectedItems);
                if (ret.Result == ResultCode.Successful)
                {
                    GridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = GetShiftString(selectedItems);
                    GridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag   = selectedItems;
                }
                else
                {
                    MessageBox.Show(ret.Message);
                }
            }
        }
 private void lnkShift_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     for (int i = 1; i <= 6; i++)
     {
         if (object.ReferenceEquals(this.Controls["lnkShift" + i.ToString()], sender))
         {
             FrmShiftSelection frm = new FrmShiftSelection();
             frm.StartPosition  = FormStartPosition.CenterParent;
             frm.SelectedShifts = this.Controls["txtShifts" + i.ToString()].Tag as List <Shift>;
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 List <Shift> shifts = frm.SelectedShifts;
                 this.Controls["txtShifts" + i.ToString()].Tag = shifts;
                 (this.Controls["txtShifts" + i.ToString()] as TextBox).Text = GetShiftString(shifts);
             }
         }
     }
 }
예제 #3
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0) return;
            if (!_DateColumns.Contains(GridView.Columns[e.ColumnIndex])) return;
            if (!Operator.CurrentOperator.Permit(Permission.ShiftArrange)) return;
            Staff staff = GridView.Rows[e.RowIndex].Tag as Staff;
            DateTime dt = Convert.ToDateTime(GridView.Columns[e.ColumnIndex].Tag);
            if (staff.HireDate.Date > dt.Date) return;  //人员入职日期之前不必排班
            List<Shift> shifts = GridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag as List<Shift>;
            FrmShiftSelection frm = new FrmShiftSelection();
            frm.SelectedShifts = shifts;
            frm.StartPosition = FormStartPosition.Manual;
            //让选择窗体刚好位于单元格下方,或者当下方显示不下时显示在上方
            Rectangle r = GridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
            frm.Location = GetFrmSelectionPosition(r, frm);

            if (frm.ShowDialog() == DialogResult.OK)
            {
                List<Shift> selectedItems = frm.SelectedShifts;
                CommandResult ret = (new ShiftArrangeBLL(AppSettings.CurrentSetting.ConnectUri)).ShiftArrange(staff.ID, dt, selectedItems);
                if (ret.Result == ResultCode.Successful)
                {
                    GridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = GetShiftString(selectedItems);
                    GridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag = selectedItems;
                }
                else
                {
                    MessageBox.Show(ret.Message);
                }
            }
        }
 private void lnkShift_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     for (int i = 1; i <= 6; i++)
     {
         if (object.ReferenceEquals(this.Controls["lnkShift" + i.ToString()], sender))
         {
             FrmShiftSelection frm = new FrmShiftSelection();
             frm.StartPosition = FormStartPosition.CenterParent;
             frm.SelectedShifts = this.Controls["txtShifts" + i.ToString()].Tag as List<Shift>;
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 List<Shift> shifts = frm.SelectedShifts;
                 this.Controls["txtShifts" + i.ToString()].Tag = shifts;
                 (this.Controls["txtShifts" + i.ToString()] as TextBox).Text = GetShiftString(shifts);
             }
         }
     }
 }