示例#1
0
        private bool action(String act)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    vn = act == "insert" ? new Venue() : dc.Venues.Single(id => id.Id == Convert.ToInt16(lbIdValue.Text));

                    vn.VenueName = tbBusStation.Text.Trim();
                    vn.VenueLocation = tbLocation.Text.Trim();
                    if (act == "insert")
                        dc.Venues.InsertOnSubmit(vn);
                    dc.SubmitChanges();
                    ts.Complete();
                    if (act != "insert")
                    {
                        lbIdValue.Text = "";
                        lbIdValue.Visible = false;
                        lbID.Visible = false;
                        bCancel.Visible = false;
                    }
                    tbBusStation.ResetText();
                    tbLocation.ResetText();
                    this.tbSearch.CustomButton.Enabled = true;
                    this.cbLoadItem.Enabled = true;
                    return true;
                }
            }
            catch(Exception e)
            {
                MessageBox.Show(e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return false;
            }
        }
示例#2
0
 private bool DeleteBusStation()
 {
     DialogResult dr = MessageBox.Show("Are you sure to delete this Bus Station ?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
     if (dr == DialogResult.Yes)
     {
         try
         {
             vn = dc.Venues.Single(i => i.Id == Convert.ToInt16(this.dgBusStation.CurrentRow.Cells[0].Value));
             using (TransactionScope ts = new TransactionScope())
             {
                 if (vn != null)
                 {
                     dc.Venues.DeleteOnSubmit(vn);
                     dc.SubmitChanges();
                     ts.Complete();
                     return true;
                 }
                 else
                 {
                     MessageBox.Show("Somthing error with delete proccess", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return false;
                 }
             }
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK);
             return false;
         }
     }
     else
     {
         return false;
     }
 }
示例#3
0
 partial void UpdateVenue(Venue instance);
示例#4
0
 partial void DeleteVenue(Venue instance);
示例#5
0
 partial void InsertVenue(Venue instance);