Ejemplo n.º 1
0
        private void grdSubbies_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                if (e.Item.DataItem != null)
                {
                    Entities.SubContractorDataItem subbyDataItem = (Entities.SubContractorDataItem)e.Item.DataItem;
                    GridEditableItem         item    = e.Item as GridEditableItem;
                    GridTemplateColumnEditor editor  = (GridTemplateColumnEditor)item.EditManager.GetColumnEditor("Rate");
                    HtmlInputText            txtRate = (HtmlInputText)editor.ContainerControl.FindControl("txtSubContractRate");

                    CultureInfo culture = new CultureInfo(subbyDataItem.LCID);
                    txtRate.Value = subbyDataItem.ForeignRate.ToString("C", culture);
                }
            }
        }
Ejemplo n.º 2
0
        void grdOrders_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                if (e.Item.DataItem != null)
                {
                    DataRowView              orderRow = (DataRowView)e.Item.DataItem;
                    GridEditableItem         item     = e.Item as GridEditableItem;
                    GridTemplateColumnEditor editor   = (GridTemplateColumnEditor)item.EditManager.GetColumnEditor("Rate");
                    HtmlInputText            txtRate  = (HtmlInputText)editor.ContainerControl.FindControl("txtOrderRate");

                    CultureInfo culture = new CultureInfo(orderRow["LCID"] == DBNull.Value ? 2057: (int)orderRow["LCID"]);
                    txtRate.Value = Convert.ToDecimal(orderRow["ForeignRate"].ToString()).ToString("C", culture);
                    txtRate.Attributes.Add("OldRate", txtRate.Value);
                }
            }
        }
Ejemplo n.º 3
0
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem editedItem = e.Item as GridEditableItem;
                GridEditManager  editMan    = editedItem.EditManager;
                foreach (GridViewColumn column in Columns)
                {
                    if (column is GridViewDropDownListColumn)
                    {
                        // Binding DDL type fields
                        GridViewDropDownListColumn ddlColumn = column as GridViewDropDownListColumn;
                        if (!ddlColumn.IsReadOnly)
                        {
                            GridTemplateColumnEditor templateEditor = (GridTemplateColumnEditor)editMan.GetColumnEditor(ddlColumn.DataFieldKey);
                            RadComboBox ddl = templateEditor.ContainerControl.FindControl(ddlColumn.DataFieldKey) as RadComboBox;
                            if (ddlColumn.enableEmptyItem)
                            {
                                ddl.Items.Add(new RadComboBoxItem(BindingListItem.EmptyText, BindingListItem.EmptyValue));
                                ddl.AppendDataBoundItems = true;
                            }
                            ddl.DataSource     = ddlColumn.ListDataSource;
                            ddl.DataValueField = BindingListItem.ValueProperty;
                            ddl.DataTextField  = BindingListItem.TextProperty;
                            ddl.DataBind();
                            // Set current value
                            //if (e.Item is GridDataInsertItem || e.Item is GridEditFormInsertItem)
                            if (e.Item is IGridInsertItem)
                            {
                                ddl.SelectedValue = null;
                            }
                            else
                            {
                                object currentValue = DataBinder.Eval(e.Item.DataItem, ddlColumn.DataFieldKey);
                                if (currentValue != null)
                                {
                                    ddl.SelectedValue = currentValue.ToString();
                                }
                            }
                        }
                    }
                    else if (column is GridViewLinkButtonColumn)
                    {
                        // Binding Link button type fields
                        GridViewLinkButtonColumn linkColumn = column as GridViewLinkButtonColumn;
                        if (!linkColumn.IsReadOnly)
                        {
                            GridTemplateColumnEditor templateEditor = (GridTemplateColumnEditor)editMan.GetColumnEditor(linkColumn.DataTextField);
                            RadTextBox textBox = templateEditor.ContainerControl.FindControl(linkColumn.DataTextField) as RadTextBox;

                            // Set current value
                            if (e.Item is IGridInsertItem)
                            {
                                textBox.Text = null;
                            }
                            else
                            {
                                object currentValue = DataBinder.Eval(e.Item.DataItem, linkColumn.DataTextField);
                                if (currentValue != null)
                                {
                                    textBox.Text = currentValue.ToString();
                                }
                            }
                        }
                    }
                    else if (column is GridViewDataDateColumn)
                    {
                    }
                }
            }
        }
Ejemplo n.º 4
0
        void grdExtraTypes_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {
                if (e.Item.OwnerTableView.IsItemInserted)
                {
                    //*******************************
                    //item is about to be inserted **
                    //*******************************
                }
                else
                {
                    //*******************************
                    //item is about to be edited   **
                    //*******************************
                    if (e.Item.DataItem != null && e.Item.DataItem.GetType() != typeof(GridInsertionObject) && e.Item.IsInEditMode && e.Item.DataItem.GetType() != typeof(GridEditFormInsertItem))
                    {
                        Entities.ExtraType et = (Entities.ExtraType)e.Item.DataItem;

                        GridEditableItem         item            = e.Item as GridEditableItem;
                        GridTemplateColumnEditor editor          = (GridTemplateColumnEditor)item.EditManager.GetColumnEditor("NominalCode");
                        DropDownList             cboNominalCodes = (DropDownList)editor.ContainerControl.FindControl("cboNominalCodes");
                        HtmlInputText            txtDescription  = (HtmlInputText)editor.ContainerControl.FindControl("txtDescription");
                        CheckBox chkIsEnabled            = (CheckBox)editor.ContainerControl.FindControl("chkIsEnabled");
                        CheckBox chkFuelSurchargeApplies = (CheckBox)editor.ContainerControl.FindControl("chkFuelSurchargeApplies");

                        CheckBox      chkIsTimeBased = (CheckBox)e.Item.FindControl("chkIsTimeBased");
                        RadTimePicker rdiStartTime   = (RadTimePicker)e.Item.FindControl("rdiStartTime");
                        RadTimePicker rdiEndTime     = (RadTimePicker)e.Item.FindControl("rdiEndTime");

                        CheckBox chkIsDayBased = (CheckBox)e.Item.FindControl("chkIsDayBased");
                        CheckBox chkMonday     = (CheckBox)e.Item.FindControl("chkMonday");
                        CheckBox chkTuesday    = (CheckBox)e.Item.FindControl("chkTuesday");
                        CheckBox chkWednesday  = (CheckBox)e.Item.FindControl("chkWednesday");
                        CheckBox chkThursday   = (CheckBox)e.Item.FindControl("chkThursday");
                        CheckBox chkFriday     = (CheckBox)e.Item.FindControl("chkFriday");
                        CheckBox chkSaturday   = (CheckBox)e.Item.FindControl("chkSaturday");
                        CheckBox chkSunday     = (CheckBox)e.Item.FindControl("chkSunday");



                        if (et != null && cboNominalCodes != null)
                        {
                            txtDescription.Value            = et.Description;
                            chkIsEnabled.Checked            = et.IsEnabled;
                            chkFuelSurchargeApplies.Checked = et.FuelSurchargeApplies;
                            rdiStartTime.SelectedTime       = et.ExtraTypeStartTime.HasValue ? TimeSpan.FromMinutes(et.ExtraTypeStartTime.Value) : new TimeSpan();
                            rdiEndTime.SelectedTime         = et.ExtraTypeStartTime.HasValue ? TimeSpan.FromMinutes(et.ExtraTypeEndTime.Value) : new TimeSpan();

                            chkIsDayBased.Checked = et.IsDayBased;
                            chkMonday.Checked     = et.Monday;
                            chkTuesday.Checked    = et.Tuesday;
                            chkWednesday.Checked  = et.Wednesday;
                            chkThursday.Checked   = et.Thursday;
                            chkFriday.Checked     = et.Friday;
                            chkSaturday.Checked   = et.Saturday;
                            chkSunday.Checked     = et.Sunday;

                            if (et.IsSystem == true)
                            {
                                txtDescription.Disabled = true;
                                chkIsEnabled.Enabled    = false;
                            }

                            if (!EnableExtraTypeNominalCodes)
                            {
                                cboNominalCodes.Visible = false;
                            }

                            if (et.IsTimeBased)
                            {
                                chkIsTimeBased.Checked = true;
                            }

                            // populate the nominal codes
                            if (cboNominalCodes != null && EnableExtraTypeNominalCodes)
                            {
                                if (_dsNominalCodes == null)
                                {
                                    Facade.INominalCode facNominalCode = new Facade.NominalCode();
                                    _dsNominalCodes = facNominalCode.GetAllActive();
                                }

                                cboNominalCodes.Items.Insert(0, new ListItem("--- [ Please Select ] ---", "0"));

                                foreach (DataRow row in _dsNominalCodes.Tables[0].Rows)
                                {
                                    ListItem li = new ListItem();
                                    li.Value = row["NominalCodeId"].ToString();
                                    li.Text  = row["NominalCode"].ToString() + " - " + row["Description"].ToString();
                                    cboNominalCodes.Items.Add(li);
                                }

                                // Set the currently selected nominal code.
                                if (e.Item.DataItem.GetType() == typeof(Entities.ExtraType))
                                {
                                    if (et != null && et.NominalCode.NominalCodeID > 0)
                                    {
                                        cboNominalCodes.Items.FindByValue(et.NominalCode.NominalCodeID.ToString()).Selected = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }