public static ArrayList GetSalesInfo(string id) { SqlConnection conn = new SqlConnection(); SqlCommand comm = new SqlCommand(); ArrayList products = new ArrayList(); try { conn.ConnectionString = GSM_CONN_STR; conn.Open(); comm.Connection = conn; comm.CommandText = "SELECT * from Sales WHERE guestid=@guestid "; comm.Parameters.AddWithValue("@guestid", id); SqlDataReader dr = comm.ExecuteReader(); while (dr.Read()) { sales l = new sales(dr["guestid"].ToString(), dr["productID"].ToString(), dr["productName"].ToString(), dr["prices"].ToString(), dr["quantity"].ToString(), dr["total"].ToString(), dr["remarks"].ToString()); products.Add(l); } dr.Close(); } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(products); }
private void button5_Click(object sender, EventArgs e) { string id = textBox1.Text; sales m = DataBase.Getsalesinfo(id); billing n = DataBase.Getallbillinfobyid(id); double total = 0; string H = "<html><h2 align='center'>Invoice Information</h2><body>" + "<div>CusotmerID:" + id + "</div>"; H += "<div>productID: " + m.Productid + "</div>" + "<div>product Name: " + m.Productname + "</div>" + "<div>prices: " + m.Price + "</div>" + "<div>quantity: " + m.Quan + "</div>" + "<div>total: " + m.Total + "</div>"; H += "<br>"; H += "<div>bill ID: " + n.Extrabillid + "</div>" + "<div>description: " + n.Desc + "</div>" + "<div>fees: " + n.Fees + "</div>" + "<div>quantity: " + n.Qan + "</div>" + "<div>total: " + n.Total + "</div>"; H += "<br>"; total = Convert.ToDouble(m.Total) + Convert.ToDouble(n.Total); H += "<div>Overall Total: " + total.ToString() + "</div>"; H += "</body></html>"; webBrowser1.DocumentText = H; }
public static sales Getsalesinfo(string guestid) { SqlConnection conn = new SqlConnection(); SqlCommand comm = new SqlCommand(); sales u = new sales(); try { conn.ConnectionString = GSM_CONN_STR; conn.Open(); comm.Connection = conn; comm.CommandText = "SELECT * FROM Sales WHERE guestid=@guestid "; comm.Parameters.AddWithValue("@guestid", guestid); SqlDataReader dr = comm.ExecuteReader(); if (dr.Read()) { u.Guestid = (string)dr["guestid"]; u.Productid = (string)dr["productID"]; u.Productname = (string)dr["productName"]; u.Price = (string)dr["prices"]; u.Quan = (string)dr["quantity"]; u.Total = (string)dr["total"]; } } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(u); }