コード例 #1
0
        public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            DataRow dr             = (DataRow)dataItem;
            string  sHienThiDKhien = dr["HTHI_DIEU_KHIEN"].ToString();
            string  sGiaTri        = dr["GTRI_TTIN"].ToString();
            TextBox ctrCommon      = new TextBox();
            Binding valueBinding   = CreateValueBinding();

            if (sHienThiDKhien.Equals("Combobox"))
            {
                RadComboBox cmbCommon = new RadComboBox();
                List <AutoCompleteEntry> lstComboBox = new List <AutoCompleteEntry>();
                string maTruyVan = dr["HTHI_SQL"].ToString();
                if (dr["HTHI_SDUNG_TVAN"].Equals("CO"))
                {
                    KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, maTruyVan);
                    cmbCommon.SetBinding(DataContextProperty, valueBinding);
                    if (!sGiaTri.IsNullOrEmptyOrSpace())
                    {
                        cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(sGiaTri)));
                    }
                    else
                    {
                        cmbCommon.SelectedIndex = 0;
                    }
                }
                return(cmbCommon as FrameworkElement);
            }
            else if (sHienThiDKhien.Equals("Datetime"))
            {
                RadMaskedDateTimeInput radMaskDate = new RadMaskedDateTimeInput();
                radMaskDate.SetBinding(DataContextProperty, valueBinding);
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    radMaskDate.Value = LDateTime.StringToDate(sGiaTri);
                }
                else
                {
                    radMaskDate.Value = LDateTime.StringToDate(ApplicationConstant.defaultDateTimeFormat);
                }
                return(radMaskDate as FrameworkElement);
            }
            else
            {
                ctrCommon.SetBinding(DataContextProperty, valueBinding);
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    ctrCommon.Text = sGiaTri;
                }
                else
                {
                    ctrCommon.Text = "";
                }
                return(ctrCommon as FrameworkElement);
            }
        }
コード例 #2
0
        public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            Binding newBinding = CreateValueBinding();

            if (LObject.IsNullOrEmpty(newBinding.Source))
            {
                newBinding.Source = dataItem;
            }
            this.SetBinding(ColumnsMaskDateTime.ValueProperty, newBinding);
            Grid gridPanel = new Grid();
            RadMaskedDateTimeInput radMask    = new RadMaskedDateTimeInput();
            DatePicker             datePicker = new DatePicker();
            Binding datePickerBinding         = new Binding();

            datePickerBinding.Mode = BindingMode.TwoWay;
            datePickerBinding.NotifyOnValidationError = true;
            datePickerBinding.ValidatesOnExceptions   = true;
            datePickerBinding.UpdateSourceTrigger     = UpdateSourceTrigger.Explicit;
            datePickerBinding.Source = radMask;
            datePickerBinding.Path   = new PropertyPath(RadMaskedDateTimeInput.ValueProperty);
            datePicker.SetBinding(DatePicker.SelectedDateProperty, datePickerBinding);
            datePicker.IsTabStop = false;
            if (!LObject.IsNullOrEmpty(Value))
            {
                radMask.Value = LDateTime.StringToDate(Value, ApplicationConstant.defaultDateTimeFormat);
            }
            else
            {
                radMask.Value = DefaultValue;
            }
            if (!Mask.IsNullOrEmptyOrSpace())
            {
                radMask.Mask = Mask;
            }
            radMask.HorizontalAlignment  = HorizontalAlignment.Stretch;
            radMask.IsClearButtonVisible = false;
            var ControlDate = gridPanel.FindChildByType <RadMaskedDateTimeInput>();

            if (ControlDate == null)
            {
                gridPanel.Children.Add(radMask);
            }
            if (VisibilityCalendar)
            {
                radMask.Margin = new Thickness(0, 0, 35, 0);
                datePicker.HorizontalAlignment = HorizontalAlignment.Right;
                datePicker.Width = 30;
                var ControlDatePicker = gridPanel.FindChildByType <DatePicker>();
                if (ControlDatePicker == null)
                {
                    gridPanel.Children.Add(datePicker);
                }
            }
            return(gridPanel);
        }
コード例 #3
0
        public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            DataRow   dr             = (DataRow)dataItem;
            string    sHienThiDKhien = dr["HTHI_DIEU_KHIEN"].ToString();
            string    sGiaTri        = dr["GTRI_TTIN"].ToString();
            string    sTruyVan       = dr["HTHI_SQL"].ToString();
            TextBlock ctrCommon      = new TextBlock();
            var       valueBinding   = new System.Windows.Data.Binding(this.DataMemberBinding.Path.Path);

            if (sHienThiDKhien.Equals("Combobox"))
            {
                RadComboBox cmbCommon = new RadComboBox();
                List <AutoCompleteEntry> lstComboBox = new List <AutoCompleteEntry>();
                string        maTruyVan   = DatabaseConstant.DanhSachTruyVan.COMBOBOX_DMUC.getValue();
                List <string> lstDieuKien = new List <string>();
                lstDieuKien.Add(DatabaseConstant.getValue(DatabaseConstant.DanhMuc.DON_VI));
                KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, maTruyVan, lstDieuKien);
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(sGiaTri)));
                }
                else
                {
                    cmbCommon.SelectedIndex = 0;
                }
                return(cmbCommon);
            }
            else if (sHienThiDKhien.Equals("Datetime"))
            {
                RadMaskedDateTimeInput radMaskDate = new RadMaskedDateTimeInput();
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    radMaskDate.Value = LDateTime.StringToDate(sGiaTri, ApplicationConstant.defaultDateTimeFormat);
                }
                else
                {
                    radMaskDate.Value = LDateTime.StringToDate(ApplicationConstant.defaultDateTimeFormat);
                }
                return(radMaskDate);
            }
            else
            {
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    ctrCommon.Text = sGiaTri;
                }
                else
                {
                    ctrCommon.Text = "";
                }
                return(ctrCommon);
            }
        }
コード例 #4
0
        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            this.BindingTarget = RadMaskedDateTimeInput.ValueProperty;

            RadMaskedDateTimeInput picker = new RadMaskedDateTimeInput();

            picker.FormatString = "dd/MM/yyyy";
            picker.SetBinding(this.BindingTarget, this.CreateValueBinding());
            picker.HorizontalAlignment = HorizontalAlignment.Stretch;
            picker.IsEnabled           = false;
            return(picker);
        }
コード例 #5
0
 public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
 {
     teldtCommon = new RadMaskedDateTimeInput();
     try
     {
         teldtCommon.IsEnabled = false;
         teldtCommon.SetBinding(RadMaskedDateTimeInput.ValueProperty, DataMemberBinding);
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     return(teldtCommon);
 }
コード例 #6
0
        public override object GetNewValueFromEditor(object editor)
        {
            Grid grid = editor as Grid;
            RadMaskedDateTimeInput datePicker = grid.FindChildByType <RadMaskedDateTimeInput>();

            if (datePicker != null)
            {
                return(datePicker.Value.GetValueOrDefault());
            }
            else
            {
                return(null);
            }
        }
        void CustomDateTimePicker_Loaded(object sender, RoutedEventArgs e)
        {
            var template = radMaskedDateTimeInput.Template;

            PopUpCalendar        = (RadCalendar)template.FindName("CalDisplay", radMaskedDateTimeInput);
            PopUpMaskedTimeInput = (RadMaskedDateTimeInput)template.FindName("radMaskedTimeInput", radMaskedDateTimeInput);
            if (PopUpCalendar != null && startDate != null)
            {
                PopUpCalendar.SelectableDateStart = startDate;
            }
            if (PopUpCalendar != null && endDate != null)
            {
                PopUpCalendar.SelectableDateEnd = endDate;
            }
        }
コード例 #8
0
        public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            RadMaskedDateTimeInput txtbCommon = new RadMaskedDateTimeInput();

            try
            {
                txtbCommon.Mask = "dd/MM/yyyy";
                txtbCommon.SetBinding(RadMaskedDateTimeInput.ValueProperty, DataMemberBinding);
            }
            catch (Exception ex)
            {
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
            cellEdit = cell;
            return(txtbCommon as FrameworkElement);
        }
コード例 #9
0
 /// <summary>
 /// Sự kiện chọn ngày của DatetimePicker
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         DatePicker    dtpControl = (DatePicker)sender;
         StringBuilder sbControl  = new StringBuilder();
         sbControl.Append("teldt");
         sbControl.Append(dtpControl.Name.Substring(3));
         RadMaskedDateTimeInput telControl = (RadMaskedDateTimeInput)grMain.FindName(sbControl.ToString());
         if (telControl != null)
         {
             telControl.Value = dtpControl.SelectedDate;
         }
         else
         {
             throw new System.NullReferenceException("Không tìm thấy control " + sbControl.ToString());
         }
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
 }
コード例 #10
0
 /// <summary>
 /// Sự kiện chọn ngày của DatetimePicker
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         DatePicker    dtpControl = (DatePicker)sender;
         StringBuilder sbControl  = new StringBuilder();
         sbControl.Append("teldt");
         sbControl.Append(dtpControl.Name.Substring(3));
         RadMaskedDateTimeInput telControl = (RadMaskedDateTimeInput)grMain.FindName(sbControl.ToString());
         if (telControl != null)
         {
             telControl.Value = dtpControl.SelectedDate;
         }
         else
         {
             throw new System.NullReferenceException(LLanguage.SearchResourceByKey("M.TinDung.HanMuc.ucHanMucCT.KhongTimThayControl") + sbControl.ToString());
         }
     }
     catch (Exception ex)
     {
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
 }
コード例 #11
0
        public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            DataRow dr = null;

            if (dataItem.GetType().Equals(typeof(DataRow)))
            {
                dr = (DataRow)dataItem;
            }
            else
            {
                dr = ((DataRowView)dataItem).Row;
            }
            string sHienThiDKhien = dr["HTHI_DIEU_KHIEN"].ToString();
            string sHienThiTVan   = dr["HTHI_SDUNG_TVAN"].ToString();
            string sGiaTriTVan    = dr["HTHI_SQL"].ToString();
            string sGiaTri        = dr["GTRI_TTIN"].ToString();
            string sKieuDuLieu    = dr["KIEU_DU_LIEU"].ToString();
            var    valueBinding   = new System.Windows.Data.Binding(this.DataMemberBinding.Path.Path);

            if (sHienThiDKhien.Equals("Combobox"))
            {
                cmbCommon   = new RadComboBox();
                lstComboBox = new List <AutoCompleteEntry>();
                KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, sGiaTriTVan);
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(sGiaTri)));
                }
                else
                {
                    cmbCommon.SelectedIndex = 0;
                }
                cmbCommon.IsEnabled = false;
                return(cmbCommon);
            }
            else if (sHienThiDKhien.Equals("Datetimebox"))
            {
                radMaskDate = new RadMaskedDateTimeInput();
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    radMaskDate.Value = LDateTime.StringToDate(sGiaTri, ApplicationConstant.defaultDateTimeFormat);
                }
                else
                {
                    radMaskDate.Value = LDateTime.StringToDate(ClientInformation.NgayLamViecHienTai, ApplicationConstant.defaultDateTimeFormat);
                }
                radMaskDate.IsEnabled           = false;
                radMaskDate.HorizontalAlignment = HorizontalAlignment.Stretch;
                var Control = grdControl.FindChildByType <RadMaskedDateTimeInput>();
                if (Control != null)
                {
                    grdControl.Children.Remove(Control);
                }
                var ControlDTP = grdControl.FindChildByType <DatePicker>();
                if (ControlDTP != null)
                {
                    grdControl.Children.Remove(ControlDTP);
                }
                grdControl.Children.Add(radMaskDate);
                return(grdControl);
            }
            else
            {
                if (sKieuDuLieu.Equals("Number"))
                {
                    ctrMaskText      = new RadMaskedNumericInput();
                    ctrMaskText.Mask = "#18";
                    if (!sGiaTri.IsNullOrEmptyOrSpace())
                    {
                        ctrMaskText.Value = Convert.ToDouble(sGiaTri);
                    }
                    else
                    {
                        ctrMaskText.Value = null;
                    }
                    ctrMaskText.HorizontalAlignment = HorizontalAlignment.Stretch;
                    ctrMaskText.IsEnabled           = false;
                    return(ctrMaskText);
                }
                else
                {
                    ctrCommon           = new TextBox();
                    ctrCommon.IsEnabled = false;
                    if (!sGiaTri.IsNullOrEmptyOrSpace())
                    {
                        ctrCommon.Text = sGiaTri;
                    }
                    else
                    {
                        ctrCommon.Text = "";
                    }
                    return(ctrCommon);
                }
            }
        }
コード例 #12
0
        public override FrameworkElement CreateCellEditElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            DataRow dr = null;

            if (dataItem.GetType().Equals(typeof(DataRow)))
            {
                dr = (DataRow)dataItem;
            }
            else
            {
                dr = ((DataRowView)dataItem).Row;
            }
            string  sHienThiDKhien = dr["HTHI_DIEU_KHIEN"].ToString();
            string  sHienThiTVan   = dr["HTHI_SDUNG_TVAN"].ToString();
            string  sGiaTriTVan    = dr["HTHI_SQL"].ToString();
            string  sGiaTri        = dr["GTRI_TTIN"].ToString();
            string  sKieuDuLieu    = dr["KIEU_DU_LIEU"].ToString();
            TextBox ctrCommon      = new TextBox();
            Binding valueBinding   = CreateValueBinding();

            if (sHienThiDKhien.Equals("Combobox"))
            {
                lstComboBox = new List <AutoCompleteEntry>();
                cmbCommon   = new RadComboBox();
                KhoiTaoGiaTriComboBox(ref lstComboBox, ref cmbCommon, sGiaTriTVan);
                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    cmbCommon.SelectedIndex = lstComboBox.IndexOf(lstComboBox.FirstOrDefault(i => i.KeywordStrings.First().Equals(sGiaTri)));
                }
                else
                {
                    cmbCommon.SelectedIndex = 0;
                }
                cmbCommon.Tag = lstComboBox;
                cmbCommon.SetBinding(DisplayIndexProperty, valueBinding);
                cmbCommon.IsEnabled = true;
                return(cmbCommon as FrameworkElement);
            }
            else if (sHienThiDKhien.Equals("Datetimebox"))
            {
                var ControlRad = grdControl.FindChildByType <RadMaskedDateTimeInput>();
                if (ControlRad != null)
                {
                    grdControl.Children.Remove(ControlRad);
                }
                var ControlDTP = grdControl.FindChildByType <DatePicker>();
                if (ControlDTP != null)
                {
                    grdControl.Children.Remove(ControlDTP);
                }
                radMaskDate = new RadMaskedDateTimeInput();

                if (!sGiaTri.IsNullOrEmptyOrSpace())
                {
                    radMaskDate.Value = LDateTime.StringToDate(sGiaTri, ApplicationConstant.defaultDateTimeFormat);
                }
                else
                {
                    radMaskDate.Value = LDateTime.StringToDate(ClientInformation.NgayLamViecHienTai, ApplicationConstant.defaultDateTimeFormat);
                }
                radMaskDate.SetBinding(DisplayIndexProperty, valueBinding);
                radMaskDate.IsEnabled           = true;
                radMaskDate.HorizontalAlignment = HorizontalAlignment.Stretch;
                radMaskDate.Margin            = new Thickness(0, 0, 40, 0);
                dtpPicker.HorizontalAlignment = HorizontalAlignment.Right;
                dtpPicker.Width = 30;
                dtpPicker.SelectedDateChanged += new EventHandler <SelectionChangedEventArgs>(dtpPicker_SelectedDateChanged);
                grdControl.Children.Add(dtpPicker);
                grdControl.Children.Add(radMaskDate);
                return(grdControl as FrameworkElement);
            }
            else
            {
                if (sKieuDuLieu.Equals("Number"))
                {
                    ctrMaskText      = new RadMaskedNumericInput();
                    ctrMaskText.Mask = "#18";
                    if (!sGiaTri.IsNullOrEmptyOrSpace())
                    {
                        ctrMaskText.Value = Convert.ToDouble(sGiaTri);
                    }
                    else
                    {
                        ctrMaskText.Value = null;
                    }
                    ctrMaskText.SetBinding(DisplayIndexProperty, valueBinding);
                    ctrMaskText.HorizontalAlignment = HorizontalAlignment.Stretch;
                    return(ctrMaskText as FrameworkElement);
                }
                else
                {
                    ctrCommon = new TextBox();
                    if (!sGiaTri.IsNullOrEmptyOrSpace())
                    {
                        ctrCommon.Text = sGiaTri;
                    }
                    else
                    {
                        ctrCommon.Text = "";
                    }
                    ctrCommon.SetBinding(DisplayIndexProperty, valueBinding);
                    return(ctrCommon as FrameworkElement);
                }
            }
        }
 public CustomDateTimePicker()
 {
     InitializeComponent();
     MainMaskedDateTimeInput = radMaskedDateTimeInput;
 }