private void RefreshMe(bool reEntry = false)
        {
            if (reEntry)
            {
                nsgBusId = 0;
            }

            nsgBus = null;

            txtRegistrationNumber.Text = string.Empty;
            txtMaxSeatingAllowed.Text  = string.Empty;
            txtTotalSeatCount.Text     = string.Empty;
            txtKMRun.Text                 = string.Empty;
            txtDriverName.Text            = string.Empty;
            txtDriverMobileNumber.Text    = string.Empty;
            txtCoDriverName.Text          = string.Empty;
            txtCoDriverMobileNumber.Text  = string.Empty;
            cmbRouteNumbers.SelectedIndex = -1;

            if (nsgBusId > 0)
            {
                this.Text = "Bus Route Detail [EDIT] - ";
                LoadData();
                btnDelete.Visible = true;
            }
            else
            {
                this.Text         = "Bus Route Detail [ADD]";
                btnDelete.Visible = false;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!ValidateMainControls())
            {
                return;
            }

            try
            {
                if (nsgBus == null)
                {
                    nsgBus             = new CoreBus();
                    nsgBus.EntryDate   = DateTime.Now;
                    nsgBus.EntryUserID = GlobalClass.LoggedInUserID;
                }
                else
                {
                    nsgBus.UpdateDate   = DateTime.Now;
                    nsgBus.UpdateUserID = GlobalClass.LoggedInUserID;
                }

                nsgBus.RegistrationNumber    = txtRegistrationNumber.Text;
                nsgBus.MaxPassengerAllowed   = int.Parse(txtMaxSeatingAllowed.Text);
                nsgBus.TotalSeatCount        = int.Parse(txtTotalSeatCount.Text);
                nsgBus.KilometerRun          = int.Parse(txtKMRun.Text);
                nsgBus.DriverName            = txtDriverName.Text;
                nsgBus.DriverContactNumber   = txtDriverMobileNumber.Text;
                nsgBus.CoDriverName          = txtCoDriverName.Text;
                nsgBus.CoDriverContactNumber = txtCoDriverMobileNumber.Text;
                nsgBus.BusRouteID            = long.Parse(cmbRouteNumbers.SelectedValue.ToString());

                if (nsgBus.BusID == 0)
                {
                    DB.CoreBus.Add(nsgBus);
                }

                DB.SaveChanges();

                var msgResponse = MessageBox.Show("Bus details saved successfully. Do you want to continue with bus entry?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);

                if (msgResponse == DialogResult.Yes)
                {
                    RefreshMe(true);
                }
                else
                {
                    btnClose_Click(null, null);
                }
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(ex.Message, this.Text + " : btnSave_Click : " + ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        protected BusSpecificationBase()
        {
            bus = new CoreBus(messageChannel, messageChannel);

            var objectFactory = new DefaultObjectFactory();

            objectFactory.Initialize();

            host = objectFactory.GetInstance <IHost>();
            host.Start();

            LogManager.SetLogLevel(LogLevel.Verbose);
        }
        private void LoadData()
        {
            nsgBus = DB.CoreBus.Where(b => b.BusID == nsgBusId).FirstOrDefault();

            txtRegistrationNumber.Text = nsgBus.RegistrationNumber;
            txtMaxSeatingAllowed.Text  = nsgBus.MaxPassengerAllowed.ToString();
            txtTotalSeatCount.Text     = nsgBus.TotalSeatCount.ToString();
            txtKMRun.Text                 = nsgBus.KilometerRun.ToString();
            txtDriverName.Text            = nsgBus.DriverName;
            txtDriverMobileNumber.Text    = nsgBus.DriverContactNumber;
            txtCoDriverName.Text          = nsgBus.CoDriverName;
            txtCoDriverMobileNumber.Text  = nsgBus.CoDriverContactNumber;
            cmbRouteNumbers.SelectedValue = nsgBus.BusRouteID;
            this.Text += nsgBus.RegistrationNumber;
        }
示例#5
0
 protected override void Given()
 {
     messageChannel = new InMemoryMessageChannel();
     bus = new CoreBus(messageChannel, messageChannel, messageRouting);
 }