TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Henry Nyoike
NA
96
573
Generating bulk barcode and inserting to db
Mar 18 2018 11:52 PM
I have a form that receives and inserts into a database input of a product in this case a batch of booklet from a supplier. The product fields are batch number, supplier name, Serial Numbers, Quantity of booklets Received(PCs inside a batch).
I am able to insert the input into table booklets but I also want to generate Barcodes based on the number of quantity of booklets received and store it in a second table called Barcode table that captures the details of a single booklet. e.g If I received 10 booklets, I want to generate 10 Barcodes and store in a second table. I am able to generate Barcode for a single booklet but in this case I want to generate multiple number of Barcodes based on the number of Quantity of booklets Received. How do I loop through the quantity received number generate these multiple Barcodes and store in table Barcode ?
My create function inside a Controller to insert data into both tables at the same time.
[HttpPost]
[ValidateAntiForgeryToken]
public
ActionResult Create(bts_receivebookletfromsupplier bts_receivebookletfromsupplier)
{
//Barcodes
Barcodecs objbar =
new
Barcodecs();
Barcode barcode =
new
Barcode();
barcode.Barcode1 = objbar.generateBarcode();
barcode.Name = bts_receivebookletfromsupplier.BatchNo +
"-"
+ DateTime.Now.ToString();
barcode.Description = DateTime.Now.ToString();
barcode.BarcodeImage = objbar.getBarcodeImage(objbar.generateBarcode(), barcode.Name);
if
(ModelState.IsValid) {
db.bts_receivebookletfromsupplier.Add(bts_receivebookletfromsupplier);
//Generate barcodes based on the number of quantity received
db.Barcodes.Add(barcode);
db.SaveChanges();
TempData[
"Success"
] = bts_receivebookletfromsupplier.QtyReceived +
" Booklets successfully recieved"
;
return
RedirectToAction(
"Index"
);
}
else
{
ModelState.AddModelError(
""
,
"Error submiting. Submission Aborted"
);
}
return
View(bts_receivebookletfromsupplier);
}
}
Reply
Answers (
0
)
code conversion from mvc to asp.net C#
COnvert json and retrive value