EBRAHIMIEKOKDARAGHI
دوشنبه 18 اسفند 1393, 10:40 صبح
با سلام خدمت اساتید محترم
من در لایه مدل یک کلاس دارم به شکل زیر
using System.Data.Entity;using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
namespace Maintenance_Pm.Models
{
public class Mashin
{
[Required]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption .Identity)]
public int number { get; set; }
[Required]
[Display(Name="کد ماشین")]
[StringLength(50,MinimumLength=1)]
public string MashinID { get; set; }
[Required]
[Display(Name = "نام ماشین")]
[StringLength(50, MinimumLength = 1)]
public string MashinName { get; set; }
[Display(Name = "نام شرکت سازنده ")]
[StringLength(100, MinimumLength = 1)]
public string MashinCoName { get; set; }
[Display(Name = "آدرس شرکت سازنده ")]
[StringLength(150, MinimumLength = 1)]
public string AddressCo { get; set; }
[Display(Name = "مشخصات سیستم برق")]
[StringLength(150, MinimumLength = 1)]
public string Bargh { get; set; }
[Display(Name = "مشخصات سیستم مکانیک")]
[StringLength(150, MinimumLength = 1)]
public string Mekanik { get; set; }
[Display(Name = "تاریخ ساخت")]
[StringLength(10, MinimumLength = 1)]
public string DateMake { get; set; }
[Display(Name = "تاریخ نصب")]
[StringLength(10, MinimumLength = 1)]
public string DateInstalltion { get; set; }
[Display(Name = "عکس ماشین")]
[Column(TypeName="Image")]
public byte[] Img { get; set; }
}
}
در داخل لایه view برای فیلد img چه کدی روباید بنویسیم لطفا" راهنمایی کنید ضروریه !!!
@model Maintenance_Pm.Models.Person
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Person</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Id)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Id)
@Html.ValidationMessageFor(model => model.number)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Family)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Family)
@Html.ValidationMessageFor(model => model.Family)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
من در لایه مدل یک کلاس دارم به شکل زیر
using System.Data.Entity;using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
namespace Maintenance_Pm.Models
{
public class Mashin
{
[Required]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption .Identity)]
public int number { get; set; }
[Required]
[Display(Name="کد ماشین")]
[StringLength(50,MinimumLength=1)]
public string MashinID { get; set; }
[Required]
[Display(Name = "نام ماشین")]
[StringLength(50, MinimumLength = 1)]
public string MashinName { get; set; }
[Display(Name = "نام شرکت سازنده ")]
[StringLength(100, MinimumLength = 1)]
public string MashinCoName { get; set; }
[Display(Name = "آدرس شرکت سازنده ")]
[StringLength(150, MinimumLength = 1)]
public string AddressCo { get; set; }
[Display(Name = "مشخصات سیستم برق")]
[StringLength(150, MinimumLength = 1)]
public string Bargh { get; set; }
[Display(Name = "مشخصات سیستم مکانیک")]
[StringLength(150, MinimumLength = 1)]
public string Mekanik { get; set; }
[Display(Name = "تاریخ ساخت")]
[StringLength(10, MinimumLength = 1)]
public string DateMake { get; set; }
[Display(Name = "تاریخ نصب")]
[StringLength(10, MinimumLength = 1)]
public string DateInstalltion { get; set; }
[Display(Name = "عکس ماشین")]
[Column(TypeName="Image")]
public byte[] Img { get; set; }
}
}
در داخل لایه view برای فیلد img چه کدی روباید بنویسیم لطفا" راهنمایی کنید ضروریه !!!
@model Maintenance_Pm.Models.Person
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Person</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Id)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Id)
@Html.ValidationMessageFor(model => model.number)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Family)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Family)
@Html.ValidationMessageFor(model => model.Family)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}