Esempio n. 1
0
 private bool action(string act)
 {
     try
     {
         if (tbDeparture.Text.Trim() != tbDestination.Text.Trim())
         {
             var check = dc.Routes.Where(i => i.RouteDeparture == Convert.ToInt32(tbDeparture.Text.Trim()) && i.RouteDestination == Convert.ToInt32(tbDestination.Text.Trim())).ToList();
             if (check.Count == 0)
             {
                 using (TransactionScope ts = new TransactionScope())
                 {
                     rt = act == "insert" ? new Route() : dc.Routes.FirstOrDefault(id => id.Id == Convert.ToInt32(lbIdValue.Text));
                     rt.RouteDeparture = Convert.ToInt32(tbDeparture.Text.Trim());
                     rt.RouteDestination = Convert.ToInt32(tbDestination.Text.Trim());
                     if (act == "insert")
                         dc.Routes.InsertOnSubmit(rt);
                     dc.SubmitChanges();
                     ts.Complete();
                     if (act != "insert")
                     {
                         lbIdValue.Text = "";
                         lbIdValue.Visible = false;
                         lbID.Visible = false;
                         bCancel.Visible = false;
                     }
                     tbDeparture.ResetText();
                     tbDepartureNameLocation.ResetText();
                     tbDestination.ResetText();
                     tbDestinationNameLocation.ResetText();
                     return true;
                 }
             }
             else
             {
                 MessageBox.Show("The route is already exists", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 return false;
             }
         }
         else
         {
             MessageBox.Show("Departure and Destination must be different", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             return false;
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return false;
     }
 }
Esempio n. 2
0
        private bool DeleteRoute()
        {
            DialogResult dr = MessageBox.Show("Are you sure to delete this Route ?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    rt = dc.Routes.Single(x => x.Id == Convert.ToInt32(dgRoute.CurrentRow.Cells[0].Value));
                    using (TransactionScope ts = new TransactionScope())
                    {
                        if (rt != null)
                        {
                            dc.Routes.DeleteOnSubmit(rt);
                            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;
            }
        }
Esempio n. 3
0
		private void detach_Routes1(Route entity)
		{
			this.SendPropertyChanging();
			entity.Venue1 = null;
		}
Esempio n. 4
0
		private void attach_Routes1(Route entity)
		{
			this.SendPropertyChanging();
			entity.Venue1 = this;
		}
Esempio n. 5
0
 partial void DeleteRoute(Route instance);
Esempio n. 6
0
 partial void UpdateRoute(Route instance);
Esempio n. 7
0
 partial void InsertRoute(Route instance);