public ActionResult InsertDetails(RegisterProperty obj) { /*foreach (HttpPostedFileBase file in obj.files) * { * //Checking file is available to save. * if (file != null) * { * var InputFileName = Path.GetFileName(file.FileName); * var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + InputFileName); * //Save file to server folder * file.SaveAs(ServerSavePath); * //assigning file uploaded status to ViewBag for showing message to user. * ViewBag.UploadStatus = obj.files.Count().ToString() + " files uploaded successfully."; * } * * }*/ RegisterProperty objreg = new RegisterProperty(); string result = objreg.InsertRegDetails(obj); ViewData["result"] = result; ModelState.Clear(); return(View()); }
/// <summary> /// Добавление свойства регистра. /// Применение изменений схемы данных регистра производится сразу, /// так как при добавлении нового свойства должны быть добавлены /// соответствующие свойства различных служебных документов /// (например, документа, хранящего данные регистра и документа, хранящего рассчитанные итоги) /// </summary> private void AddPropertyButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(PropertyNameTextEdit.Text)) { MessageBox.Show("Specify property name"); return; } if (string.IsNullOrEmpty(DataTypeComboBoxEdit.Text)) { MessageBox.Show("Specify property data type"); return; } if (string.IsNullOrEmpty(PropertyTypeComboBoxEdit.Text)) { MessageBox.Show("Specify property type"); return; } var newProperty = new RegisterProperty( PropertyNameTextEdit.Text, DataTypeComboBoxEdit.Text, PropertyTypeComboBoxEdit.Text); PropertiesListBoxControl.Items.Add(newProperty); if (_register.Properties == null) { _register.Properties = new List <dynamic>(); } dynamic newRegisterProperty = new DynamicWrapper(); newRegisterProperty.Property = newProperty.Name; newRegisterProperty.Type = newProperty.Type; _register.Properties.Add(newRegisterProperty); // Обновляем схему документа, связанного с регистром if (_documentSchema == null) { _documentSchema = ViewModelExtension.GetRegisterDocumentSchema(Version(), ConfigId(), _register.Name); } if (_documentSchema == null) { var proc = new StatusProcess(); proc.StartOperation( delegate { _register.DocumentId = ViewModelExtension.CreateRegisterDocuments(Version(), ConfigId(), _register.Name); }); proc.EndOperation(); _documentSchema = ViewModelExtension.GetRegisterDocumentSchema(Version(), ConfigId(), _register.Name); } _documentSchema.Properties[newProperty.Name] = new { Type = DataTypeComboBoxEdit.Text }.ToDynamic(); var process = new StatusProcess(); process.StartOperation( () => ViewModelExtension.UpdateRegisterDocumentSchema(Version(), ConfigId(), _register.Name, _documentSchema)); process.EndOperation(); // Обновляем схему документа, рассчитываеющего промежуточные итоги по регистру // (поля реквизиты добавлять в схему итогов не нужно) if (newProperty.Type != RegisterPropertyType.Info) { if (_documentTotalSchema == null) { _documentTotalSchema = ViewModelExtension.GetRegisterDocumentTotalSchema(Version(), ConfigId(), _register.Name); } _documentTotalSchema.Properties[newProperty.Name] = new { Type = DataTypeComboBoxEdit.Text }.ToDynamic(); process = new StatusProcess(); process.StartOperation( () => ViewModelExtension.UpdateRegisterDocumentTotalSchema(Version(), ConfigId(), _register.Name, _documentTotalSchema)); process.EndOperation(); } if (OnValueChanged != null) { OnValueChanged(_register, new EventArgs()); } PropertyNameTextEdit.Text = string.Empty; }