winforms - Retrieve the data from another form datagridview c# -



winforms - Retrieve the data from another form datagridview c# -

i have 2 forms, database , payment, , database form have datagridview , within datagridview have quantity, show tooltip whenever quantity less 5 , shows every 15 seconds. now, wanted show same thing did on database form in payment form , of course of study modifier on datagridview in database form have public in order access it. done , initialize database form in payment form. 1 time run payment form, should show tooltip every 15 seconds similar database form, while quantity on datagridview in database form less 5, not showing. not figure out why , how prepare that.

anyone solve me?

here image of tooltip in database form (notice quantity less 5, of them):

here code using:

database form:

public partial class database : form { uint timeleft = 15; timer _timer = new timer(); rectangle _screen; public database() { initializecomponent(); _timer.interval = 1000; _timer.tick += timer_tick; } void database_load(object sender, eventargs e) { _timer.start(); } void database_formclosed(object sender, formclosedeventargs e) { _timer.stop(); } void timer_tick(object sender, eventargs e) { timeleft--; if (timeleft == 0) { _timer.stop(); checkquantity(); } } void checkquantity() { string message = string.empty; if (customdatagridview1.rows.count != 0) { foreach (datagridviewrow row in customdatagridview1.rows) { string productcode = row.cells[0].value.tostring(); decimal quantity = convert.todecimal(row.cells[1].value); if (quantity < 5) { message += "- product code: " + productcode + "\n- quantity: " + quantity + "\n\n"; timeleft = 15; _timer.start(); } else if (quantity >= 5) { timeleft = 15; _timer.start(); } } if (message != string.empty) { systemmanager.soundeffect("c:/windows/media/speech off.wav"); customtooltip1.show("the scheme has detected following: \n\n" + message + "have quantity less 5.\nplease update them immediately.", this, _screen.right, _screen.bottom, 5000); } } else { _timer.start(); } }

and here code payment form:

public partial class payment : form { uint timeleft = 15; database _database = new database(); timer _timer = new timer(); rectangle _screen; public payment() { initializecomponent(); _timer.interval = 1000; _timer.tick += timer_tick; } void payment_load(object sender, eventargs e) { _timer.start(); } void payment_formclosed(object sender, formclosedeventargs e) { _timer.stop(); } void timer_tick(object sender, eventargs e) { timeleft--; if (timeleft == 0) { _timer.stop(); checkquantity(); } } void checkquantity() { string message = string.empty; if (_database.customdatagridview1.rows.count != 0) { foreach (datagridviewrow row in _database.customdatagridview1.rows) { string productcode = row.cells[0].value.tostring(); decimal quantity = convert.todecimal(row.cells[1].value); if (quantity < 5) { message += "- product code: " + productcode + "\n- quantity: " + quantity + "\n\n"; timeleft = 15; _timer.start(); } else if (quantity >= 5) { timeleft = 15; _timer.start(); } } if (message != string.empty) { systemmanager.soundeffect("c:/windows/media/speech off.wav"); customtooltip1.show("the scheme has detected following: \n\n" + message + "have quantity less 5.\nplease update them immediately.", this, _screen.right, _screen.bottom, 5000); } } else { _timer.start(); } }

your reply much appreciated!

thank much guys.

solved, retrieve info database (access database) instead of info grid view:

i post code if people wondering how done it:

public static void getquantity() { using (oledbconnection connection = new oledbconnection(connectionstring)) { string query = "select [quantity] [database]"; connection.open(); using (oledbcommand command = new oledbcommand(query, connection)) { using (oledbdatareader reader = command.executereader()) { while (reader.read()) { int quantity = (int)reader["quantity"]; userinformation.quantity = convert.todecimal(quantity); } reader.close(); } } connection.close(); } } public static void checkquantity(customtooltip _customtooltip, iwin32window _window, int _x, int _y, int _duration) { getquantity(); string message = string.empty; string productcode = string.empty; using (oledbconnection connection = new oledbconnection(connectionstring)) { string query = "select [productcode] [database] [quantity] = @quantity"; connection.open(); using (oledbcommand command = new oledbcommand(query, connection)) { command.parameters.add("@quantity", oledbtype.decimal); command.parameters["@quantity"].value = userinformation.quantity; using (oledbdatareader reader = command.executereader()) { while (reader.read()) { productcode = (string)reader["productcode"]; if (userinformation.quantity < 5) { message += "- product code: " + productcode + "\n- quantity: " + userinformation.quantity + "\n\n"; } } if (message != string.empty) { systemmanager.soundeffect("c:/windows/media/speech off.wav"); _customtooltip.show("the scheme has detected following: \n\n" + message + "have quantity less 5.\nplease update them immediately.", _window, _x, _y, _duration); } reader.close(); } } connection.close(); } } void timer_tick(object sender, eventargs e) { this.textbox4.text = datetime.now.tostring("dd - mmm - yyyy hh:mm:ss tt"); timeleft--; if (timeleft == 0) { _timer.stop(); if (userinformation.quantity < 5) { systemmanager.checkquantity(customtooltip1, this, _screen.right, _screen.bottom, 5000); timeleft = 15; _timer.start(); } else if (userinformation.quantity >= 5) { timeleft = 15; _timer.start(); } } }

anyway, give thanks guys read question in first place.

c# winforms datagridview

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -