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
Weeman Osekre
NA
56
3.9k
Data repository
Nov 1 2020 4:15 AM
I am using my repository layer to add items from a datagridview into my database. Some of the data are product ordered, the orders are table number, user, date, total expenditure. But with the code I have, I don’t get all the product that are the datagridview. The data gridview contains 6 of 9 parameters that is to complete the columns in the database table . The 6 are products and its corresponding details. In this case multiple orders are placed into the datagridview but it only saves one items for the table regardless of the number of items in the datagridviewHow do I go about it ?
private
void
btnsend_Click(
object
sender, EventArgs e) {
var iscorrect = kk.isvaliduser(Int32.Parse(libtabsno.Text));
if
(!iscorrect) {
foreach
(DataGridViewRow dr
in
dataGridView2.Rows) {
ck.category = dr.Cells[4].Value.ToString();
ck.productname = dr.Cells[2].Value.ToString();
string
price = (dr.Cells[3].Value.ToString());
ck.productprice =
double
.Parse(price);
string
ip = (dr.Cells[6].Value.ToString());
ck.tprice =
double
.Parse(ip);
ck.productid = Int32.Parse(dr.Cells[1].Value.ToString());
ck.quantity = Int32.Parse(dr.Cells[5].Value.ToString());
}
ck.tabel_sno_ = Int32.Parse(libtabsno.Text);
ck.tabel_no_ = Int32.Parse(libtno.Text.ToString());
ck.total = Int32.Parse(libt2.Text);
ck.date = DateTime.Now;
ck.user = libuser.Text;
kk.addunpaid(ck);
}
}
Reply
Answers (
1
)
Changing from Webforms to Dot net Core ? Help Post !!
How to read sql data to runtime added combobox in c# winforms