예제 #1
0
        private bool action(string act)
        {
            try
            {
                string busnumber = null;
                using (TransactionScope ts = new TransactionScope())
                {
                    string[] split = lbIdValue.Text.Split('-');
                    bus = act == "insert" ? new Bus() : dc.Bus.Single(id => id.Id == Convert.ToInt32(split[0]));
                    if (act == "insert")
                        bus.Active = 1;
                    bus.IdOtobus = Convert.ToInt32(tbOtobus.Text.Trim());
                    bus.IdTicketType = Convert.ToInt32(tbTicketType.Text.Trim());
                    bus.BusModel = tbBusModel.Text.Trim();
                    bus.TotalSeat = Convert.ToInt32(nudSeats.Value.ToString().Trim());
                    if (act == "insert")
                        dc.Bus.InsertOnSubmit(bus);
                    dc.SubmitChanges();
                    if (act == "insert")
                        busnumber = bus.BusNumber;
                    ts.Complete();
                    if (act != "insert")
                    {
                        lbIdValue.Text = "";
                        lbIdValue.Visible = false;
                        lbID.Visible = false;
                        bCancel.Visible = false;
                    }

                    if(act == "insert")
                        MessageBox.Show("Bus Number " + busnumber + " successfully inserted.", Application.ProductName);
                    tbOtobus.ResetText();
                    tbOtobusName.ResetText();
                    tbTicketType.ResetText();
                    tbTicketTypeName.ResetText();
                    tbBusModel.ResetText();
                    nudSeats.Value = Convert.ToDecimal("0");
                    return true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return false;
            }
        }
예제 #2
0
        private bool DeleteBus()
        {
            DialogResult dr = MessageBox.Show("Are you sure to delete this Bus ?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    bus = dc.Bus.Single(x => x.Id == Convert.ToInt32(dgBus.CurrentRow.Cells[0].Value));
                    using (TransactionScope ts = new TransactionScope())
                    {
                        if (bus != null)
                        {
                            using (BMTDataContext proc = new BMTDataContext())
                            {

                                proc.DeleteBus(Convert.ToInt32(dgBus.CurrentRow.Cells[0].Value));
                                ts.Complete();
                                return true;
                            }
                        }
                        else
                        {
                            return false;
                        }

                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
예제 #3
0
		private void attach_Bus(Bus entity)
		{
			this.SendPropertyChanging();
			entity.TicketType = this;
		}
예제 #4
0
		private void detach_Bus(Bus entity)
		{
			this.SendPropertyChanging();
			entity.TicketType = null;
		}
예제 #5
0
 partial void DeleteBus(Bus instance);
예제 #6
0
 partial void UpdateBus(Bus instance);
예제 #7
0
 partial void InsertBus(Bus instance);
예제 #8
0
		private void detach_Bus(Bus entity)
		{
			this.SendPropertyChanging();
			entity.Otobus = null;
		}
예제 #9
0
		private void attach_Bus(Bus entity)
		{
			this.SendPropertyChanging();
			entity.Otobus = this;
		}