示例#1
0
        private void dgvNotikumi_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dgcNotDate1.Index)
            {
                object oidn = dgvNotikumi.CurrentRow.Cells[dgcNotIDN.Index].Value;
                if (oidn != null && oidn != DBNull.Value && SomeDataDefs.EventHasPayDate((EEventId)oidn))
                {
                    var dt = dgvNotikumi[e.ColumnIndex, e.RowIndex].Value;
                    if (dt == null || dt != DBNull.Value)
                    {
                        dt = DBNull.Value;
                    }
                    else
                    {
                        dt = ((DateTime)dt).AddDays(-1);
                    }
                    dgvNotikumi[dgcNotDT3.Index, e.RowIndex].Value = dt;
                }
                return;
            }
            if (e.ColumnIndex == dgcNotIDN.Index)
            {
                object oidn = dgvNotikumi.CurrentRow.Cells[dgcNotIDN.Index].Value;
                if (oidn == null || oidn == DBNull.Value || !SomeDataDefs.IsFromToEvent((EEventId)oidn))
                {
                    dgvNotikumi[dgcNotDate2.Index, e.RowIndex].Value = DBNull.Value;
                    dgvNotikumi[dgcNotDT3.Index, e.RowIndex].Value   = DBNull.Value;
                    dgvNotikumi[dgcNotDays.Index, e.RowIndex].Value  = 0;
                    dgvNotikumi[dgcNotDays2.Index, e.RowIndex].Value = 0;
                }

                return;
            }
        }
示例#2
0
        private void CheckdgvNotikumiColumns()
        {
            if (dgvNotikumi.CurrentRow == null || dgvNotikumi.CurrentRow.IsNewRow)
            {
                dgcNotDT3.Visible = false;
                return;
            }
            object oidn = dgvNotikumi.CurrentRow.Cells[dgcNotIDN.Index].Value;
            bool   b    = oidn != null && SomeDataDefs.EventHasPayDate((EEventId)oidn);

            dgcNotDT3.Visible = b;
            b = oidn != null && SomeDataDefs.IsFromToEvent((EEventId)oidn);
            dgcNotDate2.Visible = b;
            b = oidn != null && ((EEventId)oidn) == EEventId.Atvaļinājums;
            dgcNotDays.Visible  = b;
            dgcNotDays2.Visible = b;
        }
示例#3
0
        private void dgvNotikumi_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (IsLoading || InSwitchingTabs || ActiveControl != mySplitContainer1 || !dgvNotikumi.Focused)
            {
                return;
            }
            if (e.RowIndex == -1 || dgvNotikumi.NewRowIndex == e.RowIndex)
            {
                return;
            }
            object oidn = dgvNotikumi.CurrentRow.Cells[dgcNotIDN.Index].Value;

            if (oidn == null || oidn == DBNull.Value)
            {
                e.Cancel = true;
                return;
            }
            var    ev   = (EEventId)oidn;
            bool   b    = SomeDataDefs.IsFromToEvent(ev);
            object odt1 = dgvNotikumi[dgcNotDate1.Index, e.RowIndex].Value;
            object odt2 = dgvNotikumi[dgcNotDate2.Index, e.RowIndex].Value;

            if (odt1 == DBNull.Value)
            {
                odt1 = null;
            }
            if (odt2 == DBNull.Value)
            {
                odt2 = null;
            }
            bool baddates = false;

            if (b)
            {
                if (odt1 == null || odt2 == null)
                {
                    baddates = true;
                }
                else
                {
                    var dt1 = (DateTime)odt1;
                    var dt2 = (DateTime)odt2;
                    if (dt1 > dt2 || dt1.Year < 1950 || dt1.Year > 2100 ||
                        dt2.Year < 1950 || dt2.Year > 2100)
                    {
                        baddates = true;
                    }
                }
            }
            else
            {
                if (odt1 == null)
                {
                    baddates = true;
                }
            }
            if (baddates)
            {
                MyMainForm.ShowWarning("Nekorekti norādīti datumi no - līdz.");
                e.Cancel = true;
                return;
            }

            b = SomeDataDefs.EventHasPayDate(ev);
            if (b)
            {
                object odt3 = dgvNotikumi[dgcNotDT3.Index, e.RowIndex].Value;
                if (odt3 == DBNull.Value)
                {
                    odt3 = null;
                }
                if (odt3 == null)
                {
                    baddates = true;
                }
                else
                {
                    var dt3 = (DateTime)odt3;
                    if (dt3.Year < 1950 || dt3.Year > 2100 ||
                        (odt1 != null && (DateTime)odt1 <= dt3))
                    {
                        baddates = true;
                    }
                }
            }
            if (baddates)
            {
                MyMainForm.ShowWarning("Nekorekti norādīts izmaksas datums.");
                e.Cancel = true;
                return;
            }

            if (ev == EEventId.Piešķirts_amats || ev == EEventId.Atbrīvots_no_amata)
            {
                object oida = dgvNotikumi[dgcNotIDA.Index, e.RowIndex].Value;
                if (oida == null || oida == DBNull.Value)
                {
                    MyMainForm.ShowWarning("Janorāda amats.");
                    e.Cancel = true;
                    return;
                }
            }

            if (SomeDataDefs.EventHasSCode(ev))
            {
                string scode = dgvNotikumi[dgcNotSCode.Index, e.RowIndex].Value.AsString();
                if (string.IsNullOrEmpty(scode))
                {
                    MyMainForm.ShowWarning("Janorāda ziņu kods.");
                    e.Cancel = true;
                    return;
                }
            }

            if (SomeDataDefs.EventHasOccCode(ev))
            {
                string occcode = dgvNotikumi[dgcNotOcc.Index, e.RowIndex].Value.AsString();
                if (string.IsNullOrEmpty(occcode))
                {
                    MyMainForm.ShowWarning("Janorāda profesijas kods.");
                    e.Cancel = true;
                    return;
                }
            }
        }