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
Jes Sie
663
1.2k
282k
Inserting Header and Detail Values using c#
Mar 2 2018 2:58 AM
Hi all,
I've been developing a system for only 2 years. In other words, I'm still learning until now. One of the applications that I developed involves inserting header and details. My way of doing it is not the best one but I was able to do the task. However, there are times that the header fails to insert to DB but the details succeeded and vice versa. Below are my code snippet and I wish someone can share their ideas on how to make it in such a way that if the header fails, then the details value should not insert to DB and vice versa.
try
{
//for enrollment header
header.SchoolYear = ddlSchoolYear.SelectedItem.Text;
header.EnrollmentID = lblEnrollmentID.Text;
header.StudentID = lblStudentID.Text;
header.GradeLvl = ddlGradeLvl.SelectedItem.Text;
header.EnrollmentFees = Convert.ToDouble(lblTotalFees.Text);
header.Discount = Convert.ToDouble(txtDiscount.Text);
header.PaymentTerms = Convert.ToInt32(ddlTermPayment.SelectedValue);
header.SchoolCode = lblSchoolCode.Text;
header.UserLogs = lblUsername.Text;
insert.InsertEnrollmentHeader(header);
//for enrollment charges
#region ----charges
foreach
(GridViewRow row
in
gvCharges.Rows)
{
if
(row.RowType == DataControlRowType.DataRow)
{
CheckBox Charges = (CheckBox)row.FindControl(
"cbCharges"
);
if
(Charges !=
null
&& Charges.Checked)
{
Label lblChargesID = (Label)row.FindControl(
"lblChargesID"
);
charges.ChargesID = Convert.ToInt32(lblChargesID.Text);
charges.EnrollmentID = lblEnrollmentID.Text;
count = insert.InsertEnrollmentCharges(charges);
}
}
}
Thanks in advance.
Reply
Answers (
2
)
How to convert decimal value to striing type
by one clicking send data to Email and database