示例#1
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (nameTextBox.Text == String.Empty || ageTextBox.Text == String.Empty || ratingTextBox.Text == "")
     {
         outputlabel.Text = "Please enter all the input";
     }
     else
     {
         Sailor sailor = new Sailor();
         sailor.Name   = nameTextBox.Text;
         sailor.Age    = Convert.ToInt32(ageTextBox.Text);
         sailor.Rating = Convert.ToInt32(ratingTextBox.Text);
         if (IsNameExist(sailor.Name))
         {
             outputlabel.Text = "Name already Exist. Try another!";
         }
         else
         {
             int rowEffect = Save(sailor);
             if (rowEffect >= 1)
             {
                 outputlabel.Text   = "Save Successful.";
                 nameTextBox.Text   = "";
                 ageTextBox.Text    = "";
                 ratingTextBox.Text = "";
             }
             else
             {
                 outputlabel.Text = "Save Failed!";
             }
         }
     }
     sailorGridView.DataSource = GetSailorList();
 }
示例#2
0
        public List <Sailor> FindSailors(Sailor ss)
        {
            AbstractGenericOperation ado = new FindSailors();
            List <Sailor>            s   = (List <Sailor>)ado.ExecuteSO(ss);

            return(s);
        }
示例#3
0
        public bool UpdateSailor(Sailor s)
        {
            AbstractGenericOperation ado = new UpdateSailor();
            bool success = (bool)ado.ExecuteSO(s);

            return(success);
        }
示例#4
0
 public List<Pirate> GetCrew()
 {
     var sailor = new Sailor();
     var crew = new List<Pirate>();
     crew.AddRange(sailor.Clone(10));
     return crew;
 }
示例#5
0
        internal string UpdateSailor(Sailor s)
        {
            SendRequest(s, Operation.UpdateSailor);
            Response r = (Response)formatter.Deserialize(stream);

            return(r.Message);
        }
示例#6
0
 private Response LoginSailor(Sailor s)
 {
     if (Controller.Controller.Instance.LoginSailor(s))
     {
         return(CreateResponse(Signal.Ok, "Upsjesno ste se prijavili.", s));
     }
     return(CreateResponse(Signal.Error, "Greska prilikom prijavljivanja!", s));
 }
示例#7
0
 private Response UpdateSailor(Sailor s)
 {
     if (Controller.Controller.Instance.UpdateSailor(s))
     {
         return(CreateResponse(Signal.Ok, "Uspjesno azuriranje pomorca!", s));
     }
     return(CreateResponse(Signal.Error, "Greska prilikom azuriranja !", s));
 }
示例#8
0
 private Response AddSailor(Sailor s)
 {
     if (Controller.Controller.Instance.AddSailor(s))
     {
         return(CreateResponse(Signal.Ok, "Uspjesno ste unijeli pomorca!", s));
     }
     return(CreateResponse(Signal.Error, "Greska prilikom unosa pomorca!", s));
 }
示例#9
0
        internal List <Sailor> FindSailors(Sailor s)
        {
            SendRequest(s, Operation.FindSailors);
            Response r = (Response)formatter.Deserialize(stream);

            MessageBox.Show(r.Message);
            return((List <Sailor>)r.Object);
        }
示例#10
0
 public ActionResult RegisterSailor(Sailor SM)
 {
     ViewBag.ErrorMessage  = cn.SailorAdd(SM);
     ViewBag.MaritialList  = JKLModel.getMaritialStatus();
     ViewBag.BloodTypeList = JKLModel.getBloodType();
     ViewBag.JobStatusList = JKLModel.getJobStatus();
     return(View());
 }
示例#11
0
    private void OnTriggerExit(Collider other)
    {
        Sailor sailor = other.GetComponent <Sailor>();

        if (sailor != null)
        {
            NotifyBoat(sailor, false);
        }
    }
示例#12
0
        internal bool LoginSailor(Sailor s)
        {
            SendRequest(s, Operation.LoginSailor);
            Response r = (Response)formatter.Deserialize(stream);

            if (r.Signal.Equals(Signal.Ok))
            {
                return(true);
            }
            return(false);
        }
        public void Finally_method_should_call_promise_finally_exactly_once()
        {
            int call = 0;

            Sailor d = new Sailor();

            d.Promise.Finally(delegate() { call++; });
            d.Finally();

            //Finally method should call promise finally exactly once
            Assert.Equal(1, call);
        }
        public void Notify_method_should_call_promise_notify_exactly_once()
        {
            string val  = "iyhbiyhb";
            int    call = 0;

            Sailor d = new Sailor();

            d.Promise.Notify(delegate(object obj) { call++; });
            d.Notify(val);

            //Notify method should call promise notify exactly once
            Assert.Equal(1, call);
        }
示例#15
0
 public void SailorBoatStateChanged(Sailor sailor, bool isInBoat)
 {
     if (isInBoat)
     {
         crew.Add(sailor);
         sailor.setNewBoat(this);
     }
     else
     {
         crew.Remove(sailor);
         sailor.setNewBoat(null);
     }
 }
        public void Resolve_method_should_call_promise_fulfill_exactly_once()
        {
            string val = "iyhbiyhb";

            var promiseMock          = new PromiseMock();
            var abortablePromiseMock = new AbortablePromiseMock();

            Sailor d = new Sailor(promiseMock, abortablePromiseMock);

            d.Resolve(val);

            Assert.Equal(1, promiseMock.FulfillCalls);
            Assert.Equal(1, abortablePromiseMock.FulfillCalls);
        }
示例#17
0
        public int Save(Sailor sailor)
        {
            string     query   = "INSERT INTO Sailors(sname, rating, age) VALUES(@sname, @rating, @age)";
            SqlCommand command = new SqlCommand(query, connection);

            command.Parameters.AddWithValue("@sname", sailor.Name);
            command.Parameters.AddWithValue("@rating", sailor.Rating);
            command.Parameters.AddWithValue("@age", sailor.Age);
            connection.Open();
            int rowAffect = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffect);
        }
        public void Reject_method_should_call_promise_reject_exactly_once()
        {
            Exception exc = new Exception();

            var promiseMock          = new PromiseMock();
            var abortablePromiseMock = new AbortablePromiseMock();

            Sailor d = new Sailor(promiseMock, abortablePromiseMock);

            d.Reject(exc);

            Assert.Equal(1, promiseMock.RejectCalls);
            Assert.Equal(1, abortablePromiseMock.RejectCalls);
        }
示例#19
0
        protected override object Execute(IDomainObject entity)
        {
            Sailor s = (Sailor)entity;

            foreach (Sailor sa in broker.Select(entity))
            {
                if (sa.Username == s.Username && sa.Password == s.Password)
                {
                    Result = sa;
                    return(true);
                }
            }
            return(false);
        }
示例#20
0
        private Response FindSailors(Sailor s)
        {
            List <Sailor> ss = new List <Sailor>();

            ss = Controller.Controller.Instance.FindSailors(s);
            if (ss is null)
            {
                return(CreateResponse(Signal.Error, "Greska prilikom pronalazenja pomoraca sa zadatim kriterijumom", ss));
            }
            if (ss.Count == 0)
            {
                return(CreateResponse(Signal.Ok, "Ne postoje pomorci sa zadatim kriterijumima", ss));
            }
            return(CreateResponse(Signal.Ok, "Uspjesno pronalazenje pomoraca po kriterijumu", ss));
        }
        public void When_method_should_run_the_Action_and_all_others_methods_async_on_another_thread()
        {
            string currentThreadName = Thread.CurrentThread.Name;

            Sailor d = new Sailor();

            //When method should be executed on a thread other than the calling one
            d.When(delegate() { Assert.NotEqual(Thread.CurrentThread.Name, currentThreadName); })
            //Then method should be executed on a thread other than the calling one
            .Then(delegate(object obj) { Assert.NotEqual(Thread.CurrentThread.Name, currentThreadName); })
            //Finally method should be executed on a thread other than the calling one
            .Finally(delegate() { Assert.NotEqual(Thread.CurrentThread.Name, currentThreadName); })
            //Let the test fail if there is an exception
            .OnError(delegate(Exception exc) { Assert.False(true); });
        }
示例#22
0
        public ActionResult StatusSailor(Sailor SM)
        {
            int historyId = Convert.ToInt32(Request["historyId"]);

            ViewBag.ErrorMessage = cn.SailorUpdate(SM) + "\n";
            if (SM.JobStatus == 3)
            {
                DateTime now          = DateTime.Now;
                DateTime vacationDate = now.AddMonths(SM.VacationMonth);
                ViewBag.ErrorMessage += cn.ServiceUpdate(historyId, vacationDate);
            }
            else
            {
                ViewBag.ErrorMessage += cn.ServiceUpdate(historyId);
            }
            return(RedirectToAction("Notifications"));
        }
        public void When_method_should_call_Finally_action_when_the_Action_passed_to_it_comlpetes_without_errors()
        {
            int callNr  = 0;
            int callNr1 = 0;

            Sailor d = new Sailor();

            d.When(delegate() { Thread.Sleep(500); })
            .Finally(delegate() { callNr++; })
            .OnError(delegate(Exception exc) { callNr1++; });

            Thread.Sleep(1000);

            //When method should call Finally action when the Action passed to it comlpetes without errors
            Assert.Equal(1, callNr);
            Assert.Equal(0, callNr1);
        }
        public void Then_action_should_be_called_on_the_same_current_thread_if_when_method_is_used_with_a_synch_context()
        {
            SynchronizationContext sc = new SynchronizationContext();

            SynchronizationContext.SetSynchronizationContext(sc);

            string currentThreadName = Thread.CurrentThread.Name;

            Sailor d = new Sailor();

            //When method should be executed on the same calling thread if a synchronization context is set
            d.When(delegate() { Assert.Equal(Thread.CurrentThread.Name, currentThreadName); })
            //Then method should be executed on the same calling thread if a synchronization context is set
            .Then(delegate(object obj) { Assert.Equal(Thread.CurrentThread.Name, currentThreadName); })
            //Finally method should be executed on the same calling thread if a synchronization context is set
            .Finally(delegate() { Assert.Equal(Thread.CurrentThread.Name, currentThreadName); })
            //Let the test fail if there is an exception
            .OnError(delegate(Exception exc) { Assert.False(true); });

            SynchronizationContext.SetSynchronizationContext(null);
        }
示例#25
0
        public List <Sailor> GetSailorList()
        {
            string query = "SELECT * FROM Sailors";

            command = new SqlCommand(query, connection);
            connection.Open();
            reader = command.ExecuteReader();
            List <Sailor> sailorList = new List <Sailor>();

            while (reader.Read())
            {
                Sailor sailor = new Sailor();
                sailor.Id     = Convert.ToInt32(reader["sid"]);
                sailor.Name   = reader["sname"].ToString();
                sailor.Age    = Convert.ToInt32(reader["age"]);
                sailor.Rating = Convert.ToInt32(reader["rating"]);
                sailorList.Add(sailor);
            }
            connection.Close();
            return(sailorList);
        }
示例#26
0
        public string SailorAdd(Sailor SM)
        {
            string        dsn  = (string)ConfigurationManager.AppSettings["dsn"];
            SqlConnection conn = new SqlConnection(dsn);
            //Коммандын төрлийг сонгох тохиолдолд дараах байдлаар үүсгэнэ.
            SqlCommand cmd = new SqlCommand("AddSailor", conn);

            //Коммандын төрөл профедур болохыг зааж байна
            cmd.CommandType = CommandType.StoredProcedure;
            //Уг процедурыг дуудахад дараах параметрүүдийг дамжуулна
            cmd.Parameters.AddWithValue("@SailorName ", SM.SailorName);
            cmd.Parameters.AddWithValue("@DateOfBirth ", SM.BirthDate);
            cmd.Parameters.AddWithValue("@MaritialStatus ", SM.MaritialStatus);
            cmd.Parameters.AddWithValue("@Address ", SM.Address);
            cmd.Parameters.AddWithValue("@Height ", SM.Height);
            cmd.Parameters.AddWithValue("@Weight ", SM.Weight);
            cmd.Parameters.AddWithValue("@BloodType ", SM.BloodType);
            cmd.Parameters.AddWithValue("@ShoeSize ", SM.ShoeSize);
            cmd.Parameters.AddWithValue("@JobStatus ", SM.JobStatus);
            //Процедурын гаралтын параметрийг дараахь байдлаар үүсгэн холбож өгнө
            SqlParameter idParam = new SqlParameter("@SailorId ", SqlDbType.Int);

            idParam.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(idParam);

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                return(ex.ToString());
            }
            finally
            {
                conn.Dispose();
            }
            return("Далайчин амжилттай нэмэгдлээ");
        }
示例#27
0
        public string SailorUpdate(Sailor CM)
        {
            string        dsn  = (string)ConfigurationManager.AppSettings["dsn"];
            SqlConnection conn = new SqlConnection(dsn);
            //Коммандын төрлийг сонгох тохиолдолд дараах байдлаар үүсгэнэ.
            SqlCommand cmd = new SqlCommand("UpdateSailor", conn);

            //Коммандын төрөл профедур болохыг зааж байна
            cmd.CommandType = CommandType.StoredProcedure;
            //Уг процедурыг дуудахад дараах параметрүүдийг дамжуулна
            cmd.Parameters.AddWithValue("@SailorName  ", CM.SailorName);
            cmd.Parameters.AddWithValue("@DateOfBirth  ", CM.BirthDate);
            cmd.Parameters.AddWithValue("@MaritialStatus  ", CM.MaritialStatus);
            cmd.Parameters.AddWithValue("@Address  ", CM.Address);
            cmd.Parameters.AddWithValue("@Height  ", CM.Height);
            cmd.Parameters.AddWithValue("@Weight  ", CM.Weight);
            cmd.Parameters.AddWithValue("@BloodType  ", CM.BloodType);
            cmd.Parameters.AddWithValue("@ShoeSize   ", CM.ShoeSize);
            cmd.Parameters.AddWithValue("@JobStatus  ", CM.JobStatus);
            cmd.Parameters.AddWithValue("@Password   ", CM.Password);
            cmd.Parameters.AddWithValue("@UserId ", CM.SailorId);
            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                return(ex.ToString());
            }
            finally
            {
                conn.Dispose();
            }
            return("Далайчин амжилттай Засагдлаа");
        }
示例#28
0
        public IActionResult ActionWithJsonBody([FromBody] Sailor sailor)
        {
            var infoString = FormatSailorInfo(sailor.FirstName, sailor.SurName, sailor.NickName, sailor.Legs, sailor.Age, sailor.IsCaptain, false);

            return(Content(infoString));
        }
示例#29
0
 public void PassengerStateChangedOnSteering(Sailor sailor, bool isInArea)
 {
     sailor.IsInSteeringAreaChange(isInArea);
 }
示例#30
0
 public void PassengerStateChangedOnSettingSails(Sailor sailor, bool isInArea)
 {
     sailor.IsInSettingSailAreaChanged(isInArea);
 }