Beispiel #1
0
        private void dgvPapildSummas_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (e.ColumnIndex == dgcPSIDNO.Index)
            {
                if (e.RowIndex == dgvPapildSummas.NewRowIndex)
                {
                    e.Cancel = true;
                    return;
                }
                var cell = dgvPapildSummas[e.ColumnIndex, e.RowIndex] as DataGridViewComboBoxCell;
                var drv  = dgvPapildSummas.Rows[e.RowIndex].DataBoundItem as DataRowView;
                var dr   = drv.Row as KlonsADataSet.POSITIONS_PLUSMINUSRow;

                if (dr.IsIDSVNull())
                {
                    e.Cancel = true;
                    return;
                }
                var allowed = SomeDataDefs.GetAllowedEBonusFrom(dr.XBonusType);
                if (allowed.Length == 0)
                {
                    e.Cancel = true;
                    return;
                }
                var list = SomeDataDefs.GetBonusFromItems(allowed);
                cell.DataSource    = list;
                cell.DisplayMember = "Val";
                cell.ValueMember   = "Key";
            }
        }
Beispiel #2
0
        public void MakeColumnHeaders(CalendarMonthInfo calmt)
        {
            string[] daystr = SomeDataDefs.GetDaysStr(calmt.WeekDays);
            int      nr1 = dgcV1.Index, d1;
            string   s;

            for (int i = nr1; i < nr1 + 31; i++)
            {
                var col = dgvPlans.Columns[i];
                s  = daystr[i - nr1] + "\n" + (i - nr1 + 1);
                d1 = calmt.WeekDays[i - nr1];
                if (d1 == -1)
                {
                    s = "";
                }
                col.Visible    = d1 != -1;
                col.HeaderText = s;
                if (calmt.HolyDays[i - nr1] == EHolyDay.Holiday)
                {
                    col.HeaderCell.Style = myStyleDefs1.HeaderHolyDay;
                }
                else if (Utils.IN(d1, 6, 7))
                {
                    col.HeaderCell.Style = myStyleDefs1.HeaderWeekEnd;
                }
                else
                {
                    col.HeaderCell.Style = dgvPlans.RowHeadersDefaultCellStyle;
                }
            }
        }
Beispiel #3
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;
            }
        }
Beispiel #4
0
 private void POSITIONS_PLUSMINUS_ColumnChanged(object sender, DataColumnChangeEventArgs e)
 {
     if (e.Column == MyData.DataSetKlons.POSITIONS_PLUSMINUS.IDSVColumn)
     {
         var dr = e.Row as KlonsADataSet.POSITIONS_PLUSMINUSRow;
         if (e.ProposedValue == null || e.ProposedValue == DBNull.Value)
         {
             if (dr.IsIDNONull())
             {
                 return;
             }
             dr["IDNO"] = DBNull.Value;
             dr.EndEdit();
             return;
         }
         var bonustype = (EBonusType)e.ProposedValue;
         var allowed   = SomeDataDefs.GetAllowedEBonusFrom(bonustype);
         var list      = SomeDataDefs.GetBonusFromItems(allowed);
         if (list == null || list.Length == 0)
         {
             dr["IDNO"] = DBNull.Value;
             dr.EndEdit();
             return;
         }
         if (dr.XBonusFrom == EBonusFrom.None || !allowed.Contains(dr.XBonusFrom))
         {
             dr.XBonusFrom = allowed[0];
             dr.EndEdit();
             return;
         }
     }
 }
Beispiel #5
0
        public Form_PieceWorkCatalog()
        {
            InitializeComponent();
            CheckMyFontAndColors();
            SetupToolStrips();
            cbCat.SelectedIndex    = -1;
            cbActive.SelectedIndex = 0;

            var timeunits = SomeDataDefs.MakeListB("0", "st", "1", "min", "2", "sec");

            dgcTimeUnit.DataSource    = timeunits;
            dgcTimeUnit.DisplayMember = "Val";
            dgcTimeUnit.ValueMember   = "Key";
        }
Beispiel #6
0
        private void dgvPlans_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            int curcol = dgvPlans.CurrentCell.ColumnIndex;

            if (curcol >= dgcV1.Index && curcol <= dgcV31.Index)
            {
                EDayPlanId daycode;
                float      hours;
                if (!SomeDataDefs.ParsePlanDayStr(e.Control.Text, out daycode, out hours))
                {
                    return;
                }
                e.Control.Text = hours.ToString();
            }
        }
Beispiel #7
0
        private void dgvPlans_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
        {
            if (e.ColumnIndex >= dgcV1.Index && e.ColumnIndex <= dgcV31.Index)
            {
                if (e.Value == null || e.Value == DBNull.Value)
                {
                    return;
                }

                if (e.Value is string)
                {
                    EDayPlanId daycode;
                    float      hours;

                    if (!SomeDataDefs.ParsePlanDayStr(e.Value as string, out daycode, out hours))
                    {
                        e.Value          = 0.0f;
                        e.ParsingApplied = true;
                        return;
                    }

                    int daynr = e.ColumnIndex - dgcV1.Index + 1;

                    var dr = (dgvPlans.Rows[e.RowIndex].DataBoundItem as DataRowView).Row as KlonsADataSet.TIMESHEETRow;

                    EDayPlanId curdaycode = dr.DxPlan[daynr - 1];

                    if (daycode == EDayPlanId.None)
                    {
                        daycode = curdaycode;
                    }
                    if (daycode == EDayPlanId.BD || daycode == EDayPlanId.SD)
                    {
                        hours = 0.0f;
                    }

                    e.Value          = hours;
                    e.ParsingApplied = true;

                    if (daycode != curdaycode)
                    {
                        dr.DxPlan[daynr - 1] = daycode;
                    }
                }
            }
        }
Beispiel #8
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;
        }
Beispiel #9
0
        private void dgvPlans_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex == dgcKind1.Index)
            {
                if (e.Value == null || e.Value == DBNull.Value)
                {
                    return;
                }
                if (!(e.Value is short))
                {
                    return;
                }
                EKind1 k = (EKind1)e.Value;
                string s;
                if (k == EKind1.PlanGroupDay || k == EKind1.PlanIndividualDay)
                {
                    s = "diena";
                }
                else
                {
                    s = "nakts";
                }
                e.Value             = s;
                e.FormattingApplied = true;
                return;
            }
            if (e.ColumnIndex >= dgcV1.Index && e.ColumnIndex <= dgcV31.Index)
            {
                if (dgvPlans.Rows[e.RowIndex].IsNewRow)
                {
                    return;
                }
                if (e.Value == null || e.Value == DBNull.Value)
                {
                    return;
                }
                float v = (float)e.Value;

                int daynr = e.ColumnIndex - dgcV1.Index + 1;

                var dr = (dgvPlans.Rows[e.RowIndex].DataBoundItem as DataRowView).Row as KlonsADataSet.TIMESHEETRow;
                int dk = MyData.DataSetKlons.TIMESHEET.D1Column.Ordinal;

                if (dr.XKind1 == EKind1.PlanGroupaNight)
                {
                    if (v == 0.0f)
                    {
                        e.Value             = "";
                        e.FormattingApplied = true;
                    }
                    return;
                }

                EDayPlanId daycode = dr.DxPlan[daynr - 1];

                if (daycode == EDayPlanId.DD)
                {
                    return;
                }

                string daystr = SomeDataDefs.GetPlanIdStr(daycode);

                if (daycode == EDayPlanId.BD || daycode == EDayPlanId.SD)
                {
                    if (v == 0.0f)
                    {
                        e.Value = string.Format("{0}", daystr);
                    }
                    else
                    {
                        e.Value = string.Format("{0} {1}", daystr, v);
                    }

                    e.FormattingApplied = true;
                    return;
                }

                e.Value = string.Format("{0} {1}", daystr, v);

                e.FormattingApplied = true;
            }
        }
Beispiel #10
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;
                }
            }
        }