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
ASdf ghjk
NA
1
1.1k
creating a method that inserting and updating at a time
Aug 8 2013 4:17 AM
I just want to have a method that when you insert a record there's a table will update. Here is my code in my inserting record.
private void InsertReceipt()
{
decimal Stub;
Stub = Math.Floor(decimal.Parse(txtAmount.Text) / 2000);
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO Ticket(CustomerID, Date, Store, Amount, NoStub)" +
"VALUES (@CustomerID, @Date, @Store, @Amount, @NoStub) ";
cmd.Parameters.AddWithValue("@CustomerID", txtCustomerID.Text);
cmd.Parameters.AddWithValue("@Date", dtpDate.Value.Date.ToString());
cmd.Parameters.AddWithValue("@Store", txtStore.Text);
decimal amount = decimal.Parse(txtAmount.Text);
cmd.Parameters.AddWithValue("@Amount", amount);
cmd.Parameters.Add("@NoStub", SqlDbType.Decimal).Value = Stub;
cmd.ExecuteNonQuery();
}
For example this data is added to the Table "Ticket", I want to have an output that would display to the Table "StubRange".
Table "Ticket"
CustomerID
Date
Store
Amount
NoStub
1
8/5/20113
Nike
5000
2
2
8/6/2013
Adidas
4000
2
3
8/7/2013
Converse
2000
1
Table "StubRange"
RangeID
CustomerID
NoStub
StubStart
StubEnd
1
1
2
0001
0002
2
2
2
0003
0004
3
3
1
0005
0005
Just Imagine the output and anyone can create me line of code to have this kind of output.
Reply
Answers (
1
)
Export to Excel in ASP .Net C#
treeview and folder