public orders(Form hpcopy, Form dgcopy) // { dg = dgcopy as dialogcontainer; hp = hpcopy as container; InitializeComponent(); BackgroundWorker ordersload = new BackgroundWorker(); ordersload.DoWork += (o, a) => { try { adap = new MySqlDataAdapter("SELECT customer.mail,orders.* FROM lalchowk.orders inner join customer on customer.email=orders.email order by orderid desc ;", conn); dt = new DataTable(); adap.Fill(dt); obj.closeConnection(); bsource = new BindingSource(); bsource.DataSource = dt; //dr = obj.Query("select count(orderid) from orders"); //dr.Read(); //ordervar = dr[0].ToString(); //obj.closeConnection(); } catch (Exception ex) { refresh.Visible = true; refresh.Enabled = true; obj.closeConnection(); MessageBox.Show("Something happened, please try again.\n\n" + ex.Message.ToString(), "Error!"); } }; ordersload.RunWorkerCompleted += (o, b) => { if (dg != null) { dg.loadingimage.Visible = false; dg.lbl.ForeColor = SystemColors.Highlight; dg.lbl.Text = "Orders"; dg.lbl.Visible = false; formlbl.Visible = false; dg.dialogpnl.Location = new Point(1, 1); } else { loading.Visible = false; } formlbl.Visible = false; try { ordergridview.Visible = true; ordergridview.DataSource = bsource; ordergridview.DoubleBuffered(true); ordergridview.Columns["email"].Visible = false; ordergridview.Columns["in_transit"].Visible = false; ordergridview.Columns["landmark"].Visible = false; ordergridview.Columns["alternate_contact"].Visible = false; ordergridview.Columns["paymentconfirmed"].Visible = false; ordergridview.Columns["giftfrom"].Visible = false; ordergridview.Columns["giftto"].Visible = false; ordergridview.Columns["giftmsg"].Visible = false; ordergridview.Columns["giftcharges"].Visible = false; ordergridview.Columns["info"].Visible = false; panel1.Visible = true; // orlbl.Text = ordervar; orlbl.Text = ordergridview.RowCount.ToString(); odplbl.Text = ordergridview.RowCount.ToString(); refresh.Enabled = true; ordergridview.Enabled = true; delbtn.Visible = true; delbtn.Enabled = true; } catch { delbtn.Visible = false; refresh.Enabled = true; ordergridview.Visible = false; refresh.Visible = true; } Cursor = Cursors.Arrow; }; ordersload.RunWorkerAsync(); }
public loginform(Form hpcopy, Form mfcopy) { mf = mfcopy as mainform; hp = hpcopy as container; InitializeComponent(); }