private void btnBook_Click(object sender, EventArgs e) { try { for (int i = 0; i < cbTable.Items.Count; i++) { bool st = cbTable.GetItemChecked(i); if (st) { string name = cbTable.Items[i].ToString(); Console.WriteLine(name); FSRESTAURANT.EVENT_BOOKINGRow dr = MainForm.FS.EVENT_BOOKING.NewEVENT_BOOKINGRow(); dr.BOOKING_START = date.Value + timeStart.Value.TimeOfDay; dr.BOOKING_STOP = date.Value + timeStop.Value.TimeOfDay; dr.EVENT_PENJUALAN_ID = eprow.EVENT_PENJUALAN_ID; dr.TABLE_ID = source[name]; MainForm.FS.EVENT_BOOKING.AddEVENT_BOOKINGRow(dr); uppayment += dttable.FindByTABLE_ID(source[name]).TABLE_PRICE; } } syncToDatabase(); MessageBox.Show("Booking sukses"); Event.Report.Book p = new Report.Book(); Report.PrintPreview pp = new Report.PrintPreview(p, MainForm.FS); pp.setParam("PENJUALAN_ID", eprow.EVENT_PENJUALAN_ID); pp.setReport(); pp.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnInsert_Click(object sender, EventArgs e) { MySqlTransaction trans = MainForm.c.BeginTransaction(); try { MainForm.adapterMgr.EVENT_PENJUALANTableAdapter.Transaction = trans; MainForm.adapterMgr.EVENT_PENJUALAN_DETAILTableAdapter.Transaction = trans; if (eprow == null) { eprow = dataep.NewEVENT_PENJUALANRow(); } eprow.EVENT_ID = Convert.ToInt64(cbEvent.SelectedValue.ToString()); eprow.TOTAL = Convert.ToDecimal(data.Compute("SUM(SUBTOTAL)", "")); eprow.EVENT_PENJUALAN_ID = MainForm.adapterMgr.EVENT_PENJUALANTableAdapter.autogen().ToString(); eprow.USER_ID = MainForm.peg.USER_ID; eprow.PELANGGAN_ID = cbCustomer.SelectedValue.ToString(); dataep.AddEVENT_PENJUALANRow(eprow); MainForm.adapterMgr.EVENT_PENJUALANTableAdapter.Update(dataep); //trans.Commit(); foreach (FSRESTAURANT.EVENT_PENJUALAN_DETAILRow item in data) { item.EVENT_PENJUALAN_ID = eprow.EVENT_PENJUALAN_ID; } MainForm.adapterMgr.EVENT_PENJUALAN_DETAILTableAdapter.Update(data); MessageBox.Show("insert sukses"); trans.Commit(); syncToDatabase(); Event.Report.EventJual p = new Report.EventJual(); Report.PrintPreview pp = new Report.PrintPreview(p, MainForm.FS); pp.setParam("PENJUALAN_ID", eprow.EVENT_PENJUALAN_ID); pp.setReport(); pp.ShowDialog(); reverseState(); } catch (Exception ex) { trans.Rollback(); dataep.Clear(); MessageBox.Show(ex.Message); } finally { trans.Dispose(); } }