示例#1
0
        protected void btnSaveAssetTypeChanges_Click(object sender, EventArgs e)
        {
            foreach (GridDataItem assetCategoryItem in rdAssetTypeGrid.Items)
            {
                GridNestedViewItem detailView = (GridNestedViewItem)assetCategoryItem.ChildItem;

                if (detailView != null)
                {
                    GridTableView tableView = detailView.NestedTableViews.First();
                    foreach (GridDataItem assetTypeItem in tableView.Items)
                    {
                        Hashtable assetTypeValues = new Hashtable();
                        assetTypeItem.ExtractValues(assetTypeValues);
                        int             assetTypeId = Convert.ToInt32(assetTypeValues["AssetTypeId"].ToString());
                        AssetTypeEntity assetType   = new AssetTypeEntity(assetTypeId);

                        TextBox      txtName = assetTypeItem.FindControl("txtName") as TextBox;
                        TextBox      txtAssetTypeDescription = assetTypeItem.FindControl("txtAssetTypeDescription") as TextBox;
                        TextBox      txtSpanishLabel         = assetTypeItem.FindControl("txtSpanishLabel") as TextBox;
                        DropDownList ddlAssetTypeCategory    = assetTypeItem.FindControl("ddlAssetTypeCategory") as DropDownList;

                        assetType.Name            = txtName.Text.Trim().Length > 0 ? txtName.Text.Trim() : "";
                        assetType.Description     = txtAssetTypeDescription.Text.Trim().Length > 0 ? txtAssetTypeDescription.Text.Trim() : "";
                        assetType.SpanishLabel    = txtSpanishLabel.Text.Trim().Length > 0 ? txtSpanishLabel.Text.Trim() : "";
                        assetType.AssetCategoryId = Convert.ToInt32(ddlAssetTypeCategory.SelectedValue);

                        assetType.Save();
                    }
                }
            }
        }
示例#2
0
        protected void btnSaveAssetType_Click(object sender, EventArgs e)
        {
            if (txtAssetTypeName.Text.Trim().Length > 0)
            {
                AssetTypeEntity ate = new AssetTypeEntity();
                ate.Name            = txtAssetTypeName.Text.Trim();
                ate.AssetCategoryId = Convert.ToInt32(ddlAssetCategory.SelectedItem.Value);
                ate.Description     = txtAssetTypeDescription.Text.Trim().Length > 0 ? txtAssetTypeDescription.Text.Trim() : null;
                ate.SpanishLabel    = txtAssetTypeSpanishLabel.Text.Trim().Length > 0 ? txtAssetTypeSpanishLabel.Text.Trim() : null;
                ate.Save();

                txtAssetTypeName.Text         = "";
                txtAssetTypeDescription.Text  = "";
                txtAssetTypeSpanishLabel.Text = "";

                txtAssetTypeName.Focus();
                rdAssetTypeGrid.Rebind();
            }
        }