Beispiel #1
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 #2
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;
                    }
                }
            }
        }