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
Amrul Hakim
NA
19
4k
How to display the messagebox if Qty "Stock It Out" c #
May 22 2017 1:31 PM
this my database Sql Server mines Qty
this my code C#
private
void
btn_proses_Click(
object
sender, EventArgs e)
{
conn = Koneksi.Conn;
try
{
conn.Open();
cmd =
new
SqlCommand(
"INSERT INTO Tb_Transaksi VALUES ('"
+ txt_KodeTransaksi.Text +
"', '"
+ cm_pilihBarang.SelectedItem.ToString() +
"', '"
+ txt_jumlah.Text +
"', '"
+ Datepicker1.Value.Date.ToString(
"M/d/yyyy"
) +
"', '"
+ cm_select.SelectedItem.ToString() +
"', '"
+ txt_mengetahui.Text +
"', '"
+ txt_diketahui.Text +
"', '"
+ txt_keterangan.Text +
"', '"
+ cm_status.SelectedItem.ToString() +
"' )"
, conn);
cmd.ExecuteNonQuery();
if
(cm_status.SelectedItem.ToString() ==
"Keluar"
)
{
cmd =
new
SqlCommand(
"UPDATE Tb_Barang SET Qty=Qty - '"
+txt_jumlah.Text +
"' WHERE Nama_Barang= '"
+ cm_pilihBarang.SelectedItem.ToString() +
"'"
, conn);
cmd.ExecuteNonQuery();
}
if
(cm_status.SelectedItem.ToString() ==
"Masuk"
)
{
cmd =
new
SqlCommand(
"UPDATE Tb_Barang SET Qty=Qty + '"
+ txt_jumlah.Text +
"' WHERE Nama_Barang= '"
+ cm_pilihBarang.SelectedItem.ToString() +
"'"
, conn);
cmd.ExecuteNonQuery();
}
MessageBox.Show(
"Data Telah Masuk"
);
}
catch
(Exception ex)
{
MessageBox.Show(
"Erorr"
, ex.Message);
}
finally
{
autokode_transaksi();
conn.Close();
Datagrid_Transaksi();
}
}
Reply
Answers (
3
)
1
Nilesh Shah
13
54.3k
1.3m
May 22 2017 8:01 PM
you have posted all your code, but you did not tell us what problem you want to solve? what is not working in this code?
if you want to show some message based on some database value, then fetch its value using select query and show message.
what's special here you are asking?
0
Amrul Hakim
0
19
4k
May 23 2017 2:01 AM
[SOLVE}
0
Karthi Keyan
1k
755
239.8k
May 23 2017 12:12 AM
@Amrul,
1st Your Database, 2nd Your Code. But Where is your 3rd one. I mean your need. you didn't ask what you want. then how we can give suggesstion.
By your Keynote, you want to show messagebox if the stock is in minus or there is no stock. use condition to while load the item if there is no stock show the messagebox.
ComboBox item will open a web link
class/textbox/loop