public void BindSummary() { this.Invoke((MethodInvoker) delegate() { lbBuy.Text = SumBuy.ToString(); lbSell.Text = SumSell.ToString(); lbGoodTrans.Text = SumGoodTras.ToString(); lbBadTrans.Text = SumBadTrans.ToString(); lbMissTrans.Text = SumMissTrans.ToString(); }); }
private void loadHistory(string start, string stop, int status) { dgvProduct.Rows.Clear(); DataTable sell = new DataTable(); DataTable buy = new DataTable(); string sql = ""; sql = "SELECT rd.pid, rd.qty, rd.price "; sql += "FROM receipt r, receipt_detail rd "; sql += "WHERE r.receipt_id = rd.rid "; sql += "AND r.receipt_date BETWEEN \'" + start + "\' "; sql += "AND \'" + stop + "\' "; sql += "+ INTERVAL 1 DAY"; sell = selectData(sql); foreach (DataRow row in sell.Rows) { float temp = Int32.Parse(row[1].ToString()) * Int32.Parse(row[2].ToString()); SumSell += temp; dgvProduct.Rows.Add(dgvProduct.Rows.Count + 1, "ขาย " + row[0].ToString(), temp, 0); } sql = "SELECT pid, qty, price "; sql += "FROM invoice "; sql += "WHERE order_date BETWEEN \'" + start + "\' "; sql += "AND \'" + stop + "\' "; sql += "+ INTERVAL 1 DAY"; buy = selectData(sql); foreach (DataRow row in buy.Rows) { float temp = Int32.Parse(row[1].ToString()) * Int32.Parse(row[2].ToString()); SumBuy += temp; dgvProduct.Rows.Add(dgvProduct.Rows.Count + 1, "ซื้อ " + row[0].ToString(), 0, temp); } txtIncome.Text = SumSell.ToString("F"); txtIncome.ForeColor = Color.Green; txtOutcome.Text = SumBuy.ToString("F"); txtOutcome.ForeColor = Color.Red; txtRealIncome.Text = (SumSell - SumBuy).ToString("F"); txtRealIncome.ForeColor = (SumSell - SumBuy > 0) ? Color.Green : Color.Red; }