Example #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;
            }
        }
		private void detach_OtobusTicketTypeRoutes(OtobusTicketTypeRoute entity)
		{
			this.SendPropertyChanging();
			entity.Route = null;
		}
 partial void DeleteOtobusTicketTypeRoute(OtobusTicketTypeRoute instance);
 partial void UpdateOtobusTicketTypeRoute(OtobusTicketTypeRoute instance);
 partial void InsertOtobusTicketTypeRoute(OtobusTicketTypeRoute instance);
		private void attach_OtobusTicketTypeRoutes(OtobusTicketTypeRoute entity)
		{
			this.SendPropertyChanging();
			entity.TicketType = this;
		}
Example #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;
            }
        }