Exemplo n.º 1
0
        private bool action(string act)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    ottp = act == "insert" ? new OtobusTicketTypeRoute() : dc.OtobusTicketTypeRoutes.FirstOrDefault(id => id.Id == Convert.ToInt32(lbIdValue.Text));

                    ottp.IdOtobus = Convert.ToInt32(tbOtobus.Text.Trim());
                    ottp.IdTicketType = Convert.ToInt32(tbTicketType.Text.Trim());
                    ottp.IdRoute = Convert.ToInt32(tbRoute.Text.Trim());
                    string formatprice = tbPrice.Text.Trim().Replace(".", "");
                    ottp.Price = Convert.ToDecimal(formatprice);
                    if (act == "insert")
                        dc.OtobusTicketTypeRoutes.InsertOnSubmit(ottp);
                    dc.SubmitChanges();
                    ts.Complete();
                    if (act != "insert")
                    {
                        lbIdValue.Text = "";
                        lbIdValue.Visible = false;
                        lbID.Visible = false;
                        bCancel.Visible = false;
                    }
                    tbOtobus.ResetText();
                    tbOtobusName.ResetText();
                    tbTicketType.ResetText();
                    tbTicketTypeName.ResetText();
                    tbRoute.ResetText();
                    tbRouteDeparture.ResetText();
                    tbRouteDestination.ResetText();
                    tbPrice.ResetText();
                    return true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return false;
            }
        }
Exemplo n.º 2
0
		private void detach_OtobusTicketTypeRoutes(OtobusTicketTypeRoute entity)
		{
			this.SendPropertyChanging();
			entity.Route = null;
		}
Exemplo n.º 3
0
 partial void DeleteOtobusTicketTypeRoute(OtobusTicketTypeRoute instance);
Exemplo n.º 4
0
 partial void UpdateOtobusTicketTypeRoute(OtobusTicketTypeRoute instance);
Exemplo n.º 5
0
 partial void InsertOtobusTicketTypeRoute(OtobusTicketTypeRoute instance);
Exemplo n.º 6
0
		private void attach_OtobusTicketTypeRoutes(OtobusTicketTypeRoute entity)
		{
			this.SendPropertyChanging();
			entity.TicketType = this;
		}
Exemplo n.º 7
0
        private bool DeletePricing()
        {
            DialogResult dr = MessageBox.Show("Are you sure to delete this Ticket Type ?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    ottp = dc.OtobusTicketTypeRoutes.FirstOrDefault(x => x.Id == Convert.ToInt32(dgPrice.CurrentRow.Cells[0].Value));
                    using (TransactionScope ts = new TransactionScope())
                    {
                        if (ottp != null)
                        {
                            dc.OtobusTicketTypeRoutes.DeleteOnSubmit(ottp);
                            dc.SubmitChanges();
                            ts.Complete();
                            return true;
                        }
                        else
                        {
                            return false;
                        }

                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return false;
                }
            }
            else
            {
                return false;
            }
        }