private void button1_Click(object sender, EventArgs e) { PrintPreview print = new PrintPreview(idd1); DialogResult dr = print.ShowDialog(this); if (dr == DialogResult.Cancel) { print.Close(); } else if (dr == DialogResult.OK) { print.Close(); } }
private void button2_Click(object sender, EventArgs e) { con = new Connect(); DataTable dt = new DataTable(); dt = con.laybang("Select rdf.FoodID,rdf.Quantity as 'QuantityFood',rbd.Quantity as 'QuantityDish',(Select Warehousing from R_Foods where ID=rdf.FoodID) as 'Warehousing' from R_BillDish rbd , R_DishFood rdf where rbd.BillID='" + idd1 + "' and rbd.DishID=rdf.DishID"); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Connect _con = new Connect(); DataTable _dt = new DataTable(); int foodid = Convert.ToInt32(dt.Rows[i]["FoodID"].ToString()); Decimal quantityfood = Convert.ToDecimal(dt.Rows[i]["QuantityFood"].ToString(), CultureInfo.InvariantCulture); Decimal quantitydish = Convert.ToDecimal(dt.Rows[i]["QuantityDish"].ToString(), CultureInfo.InvariantCulture); _dt = _con.laybang("Select Warehousing from R_Foods where ID='" + foodid + "'"); Decimal Warehousing = Convert.ToDecimal(_dt.Rows[0]["Warehousing"].ToString(), CultureInfo.InvariantCulture); string WarehousingNew = (Warehousing - quantitydish * quantityfood).ToString(); int kq = con.xulydulieu("Update R_Foods set Warehousing='" + WarehousingNew + "' where ID='" + foodid + "'"); } } int kq1 = con.xulydulieu("Update R_Bill set Status=0,Note=N'" + txtNote.Text + "' where ID ='" + idd1 + "'"); int kq2 = con.xulydulieu("Update R_Tables set Status=0 where ID in (Select TableID from R_BillTable where BillID ='" + idd1 + "')"); con.Ghilog("In hóa đơn số:'" + idd1 + "'", userid); PrintPreview print = new PrintPreview(idd1); DialogResult dr = print.ShowDialog(this); if (dr == DialogResult.Cancel) { print.Close(); } else if (dr == DialogResult.OK) { print.Close(); } if (passControl != null) { passControl(); } this.Hide(); }