Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 03, 2011 10:31 PM by MadhuriM
Member
93 Points
41 Posts
Jul 03, 2011 02:56 PM|LINK
I created field in database and Entity data model. Manually I
can input them in Create.cshtml View:
...
<div class="editor-field"> @Html.EditorFor(model => model.InvoiceNumber, ) @Html.ValidationMessageFor(model => model.InvoiceNumber) </div>
I wish that user don't have to worry about next invoice number. What should I change and where? I suppose that in controller
Create method I need to count number of rows and send to View.
I know that is a rocky question, but I can't find anything about ui adjustment in MVC 3 applications.
All-Star
135204 Points
21687 Posts
Moderator
MVP
Jul 03, 2011 03:57 PM|LINK
MarioZupan I wish that user don't have to worry about next invoice number
Let the database figure it. Make in SqlServer the field
identity
and do not display it in the create view.
Jul 03, 2011 04:32 PM|LINK
I did, but if you delete the row, identity field keep going to add the next number. You can't use ID column for document numbering, in my opinion.
Jul 03, 2011 08:35 PM|LINK
MarioZupan I did, but if you delete the row, identity field keep going to add the next number. You can't use ID column for document numbering,
Oh, this is another problem. One is the PK - and another is the document numbering.
You can use either
a. add a column named "order" and populate via a trigger
b. do it the Oracle way and use a table from which you pick numbers
703 Points
151 Posts
Jul 03, 2011 10:31 PM|LINK
Another option is write a static function with your own algorithm for creating invoice numbers and put it in the Property Setter block.
You could do something similar in the database also, write a function for creating invoice numbers and call the function as the column value.
MarioZupan
Member
93 Points
41 Posts
Invoice number as default value in EditorFor
Jul 03, 2011 02:56 PM|LINK
ignatandrei
All-Star
135204 Points
21687 Posts
Moderator
MVP
Re: Invoice number as default value in EditorFor
Jul 03, 2011 03:57 PM|LINK
Let the database figure it. Make in SqlServer the field
identity
and do not display it in the create view.
MarioZupan
Member
93 Points
41 Posts
Re: Invoice number as default value in EditorFor
Jul 03, 2011 04:32 PM|LINK
I did, but if you delete the row, identity field keep going to add the next number. You can't use ID column for document numbering, in my opinion.
ignatandrei
All-Star
135204 Points
21687 Posts
Moderator
MVP
Re: Invoice number as default value in EditorFor
Jul 03, 2011 08:35 PM|LINK
Oh, this is another problem. One is the PK - and another is the document numbering.
You can use either
a. add a column named "order" and populate via a trigger
b. do it the Oracle way and use a table from which you pick numbers
MadhuriM
Member
703 Points
151 Posts
Re: Invoice number as default value in EditorFor
Jul 03, 2011 10:31 PM|LINK
Another option is write a static function with your own algorithm for creating invoice numbers and put it in the Property Setter block.
You could do something similar in the database also, write a function for creating invoice numbers and call the function as the column value.