Esempio n. 1
0
        void textDateTimeBinding_Format(object sender, ConvertEventArgs e)
        {
            Binding    b  = (Binding)sender;
            DataTable  dt = (DataTable)((BindingSource)b.DataSource).DataSource;
            DataColumn dc = dt.Columns[b.BindingMemberInfo.BindingMember];

            if (dc.DataType == typeof(DateTime) &&
                !string.IsNullOrEmpty(e.Value.ToString()) &&
                dt.Columns.Contains(dc.ColumnName.Trim().ToLower() + "_code"))
            {
                DataRowView drv        = (DataRowView)((BindingSource)b.DataSource).Current;
                string      dateFormat = "MM/dd/yyyy";
                if (_editMode)
                {
                    dateFormat = drv[dc.ColumnName + "_code"].ToString().Trim();
                }
                else
                {
                    dateFormat = _sharedUtils.GetLookupValueMember(drv.Row, "code_value_lookup", drv[dc.ColumnName + "_code"].ToString().Trim(), drv.Row.Table.Columns[dc.ColumnName + "_code"].ExtendedProperties["group_name"].ToString(), dateFormat);
                }
                e.Value = ((DateTime)e.Value).ToString(dateFormat);
            }
        }