コード例 #1
0
        private void CollectValues(DucValueDto ducValue, NameValueCollection formData, DucTypes ducType, ReferenceInfoDto reference)
        {
            switch (ducType)
            {
            case DucTypes.SubTitle:
            case DucTypes.Text:
            case DucTypes.TextArea:
                ducValue.ValueText = formData[DucHelper.GetClientId(ducValue.DucId)];
                break;

            case DucTypes.Html:
            case DucTypes.HtmlArea:
                ducValue.ValueHtml = formData[DucHelper.GetClientId(ducValue.DucId)];
                break;

            case DucTypes.Image:
                string fileId   = string.Format(UIConst.FileKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string colTitle = string.Format(UIConst.ImageTitleKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string title    = formData[colTitle];
                // Deal with image upload
                HttpPostedFileBase file = Request.Files[fileId];
                if (null != file && file.ContentLength > 0)
                {
                    // Save file and get result
                    FileSaveResult fileResult = FileHelper.SaveFile(title, file);
                    if (fileResult.IsSuccessful)
                    {
                        ducValue.ValueUrl  = fileResult.FileUri;
                        ducValue.ValueText = fileResult.Title;
                        // Save image as Document
                        DocumentDto document = new DocumentDto();
                        document.Title        = fileResult.Title;
                        document.ContentUri   = fileResult.FileUri;
                        document.OriginFile   = file.FileName;
                        document.OriginSource = "Reference";
                        document.IssuedDate   = DateTime.Now;
                        IDocumentService service = ServiceLocator.Current.GetInstance <IDocumentService>();
                        IFacadeUpdateResult <DocumentData> result = service.SaveDocument(document);
                    }
                    else
                    {
                    }
                }
                else
                {
                    string col1Name = string.Format(UIConst.ValueUrlKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                    string col2Name = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                    ducValue.ValueUrl  = formData[col1Name];
                    ducValue.ValueText = formData[col2Name];
                }
                break;

            case DucTypes.Integer:
                int valueInteger;
                if (int.TryParse(formData[DucHelper.GetClientId(ducValue.DucId)], out valueInteger))
                {
                    ducValue.ValueInt = valueInteger;
                }
                break;

            case DucTypes.Hyperlink:
                string col3Name = string.Format(UIConst.ValueUrlKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string col4Name = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                ducValue.ValueUrl  = formData[col3Name];
                ducValue.ValueText = formData[col4Name];
                break;

            case DucTypes.Datetime:
                break;

            case DucTypes.ReferenceList:
                string col21Name = string.Format(UIConst.ValueIntKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                string col22Name = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                int    valueInt;
                if (int.TryParse(formData[col21Name], out valueInt))
                {
                    ducValue.ValueInt = valueInt;
                }
                ducValue.ValueText = formData[col22Name];
                break;

            case DucTypes.ReferenceCollection:
                string col5Name = string.Format(UIConst.ValueIntKeyFormatString, DucHelper.GetClientId(ducValue.DucId));
                int    value5Int;
                if (int.TryParse(formData[col5Name], out value5Int))
                {
                    ducValue.ValueInt = value5Int;
                }
                break;

            default:
                break;
            }
        }
コード例 #2
0
 public static string GetClientId(this HtmlHelper htmlHelper, object id)
 {
     return(DucHelper.GetClientId(id));
 }
コード例 #3
0
        private void CreateColumns(GridDto gridData)
        {
            JQGridColumn keyColumn = new JQGridColumn();

            GridInstance.Columns.Add(keyColumn);
            keyColumn.DataField  = BaseDto.FLD_Id;
            keyColumn.PrimaryKey = true;
            keyColumn.Width      = 40;
            keyColumn.Editable   = false;
            keyColumn.Visible    = true;

            foreach (GridColumnDto item in gridData.Columns)
            {
                switch (item.ColumnType)
                {
                case DucTypes.SubTitle:
                case DucTypes.Integer:
                case DucTypes.Text:
                case DucTypes.Html:
                    JQGridColumn textColumn = new JQGridColumn();
                    GridInstance.Columns.Add(textColumn);
                    textColumn.HeaderText = item.ColumnName;
                    textColumn.DataField  = DucHelper.GetClientId(item.Id);
                    textColumn.Editable   = true;
                    textColumn.EditType   = EditType.TextBox;
                    textColumn.Width      = item.ColumnWidth;
                    break;

                case DucTypes.TextArea:
                case DucTypes.HtmlArea:
                    JQGridColumn column = new JQGridColumn();
                    GridInstance.Columns.Add(column);
                    column.HeaderText = item.ColumnName;
                    column.DataField  = DucHelper.GetClientId(item.Id);
                    column.Editable   = true;
                    column.EditType   = EditType.TextArea;
                    column.Width      = item.ColumnWidth;
                    break;

                case DucTypes.Image:
                    JQGridColumn imageColumn1 = new JQGridColumn();
                    GridInstance.Columns.Add(imageColumn1);
                    imageColumn1.HeaderText = string.Format(UIConst.ValueUrlKeyFormatString, item.ColumnName);
                    imageColumn1.DataField  = string.Format(UIConst.ValueUrlKeyFormatString, DucHelper.GetClientId(item.Id));
                    imageColumn1.Editable   = true;
                    imageColumn1.EditType   = EditType.TextArea;
                    imageColumn1.Resizable  = true;
                    imageColumn1.DataType   = typeof(string);
                    imageColumn1.Width      = item.ColumnWidth;

                    JQGridColumn imageColumn2 = new JQGridColumn();
                    GridInstance.Columns.Add(imageColumn2);
                    imageColumn2.HeaderText = string.Format(UIConst.ValueTextKeyFormatString, item.ColumnName);
                    imageColumn2.DataField  = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(item.Id));
                    imageColumn2.Editable   = true;
                    imageColumn2.EditType   = EditType.TextBox;
                    imageColumn2.Resizable  = true;
                    imageColumn2.DataType   = typeof(string);
                    imageColumn2.Width      = item.ColumnWidth;

                    break;

                case DucTypes.Hyperlink:
                    JQGridColumn linkColumn1 = new JQGridColumn();
                    GridInstance.Columns.Add(linkColumn1);
                    linkColumn1.HeaderText = string.Format(UIConst.ValueUrlKeyFormatString, item.ColumnName);
                    linkColumn1.DataField  = string.Format(UIConst.ValueUrlKeyFormatString, DucHelper.GetClientId(item.Id));
                    linkColumn1.Editable   = true;
                    linkColumn1.EditType   = EditType.TextBox;
                    linkColumn1.Width      = item.ColumnWidth;

                    JQGridColumn linkColumn2 = new JQGridColumn();
                    GridInstance.Columns.Add(linkColumn2);
                    linkColumn2.HeaderText = string.Format(UIConst.ValueTextKeyFormatString, item.ColumnName);
                    linkColumn2.DataField  = string.Format(UIConst.ValueTextKeyFormatString, DucHelper.GetClientId(item.Id));
                    linkColumn2.Editable   = true;
                    linkColumn2.EditType   = EditType.TextBox;
                    linkColumn2.Width      = item.ColumnWidth;
                    break;

                case DucTypes.Datetime:
                    break;

                default:
                    break;
                }
            }
        }