Example #1
0
        public ClientM GetClient(string tlf)
        {
            ClientM c = new ClientM();

            _command.CommandText = "SELECT * FROM Client WHERE TlfNo = @tlf";
            _command.Parameters.Clear();

            _command.Parameters.Add(new SqlParameter("@tlf", tlf));
            PrepareSql();
            SqlDataReader reader = null;

            reader = _command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    c.Id        = reader["ID"] != DBNull.Value ? Convert.ToInt32(reader["ID"]) : default(int);
                    c.CprNo     = reader["CprNo"] != DBNull.Value ? reader["CprNo"].ToString() : string.Empty;
                    c.FirstName = reader["FirstName"] != DBNull.Value ? reader["FirstName"].ToString() : string.Empty;
                    c.LastName  = reader["LastName"] != DBNull.Value ? reader["LastName"].ToString() : string.Empty;
                    c.Address   = reader["Address"] != DBNull.Value ? reader["Address"].ToString() : string.Empty;
                    c.PostNo    = reader["PostNo"] != DBNull.Value ? Convert.ToInt32(reader["PostNo"]) : default(int);
                    c.Email     = reader["Email"] != DBNull.Value ? reader["Email"].ToString() : string.Empty;
                    c.TlfNo     = reader["TlfNo"] != DBNull.Value ? reader["TlfNo"].ToString() : string.Empty;
                }
            }
            _connection.Close();
            return(c);
        }
Example #2
0
        public ClientM GetClient(string tlf)
        {
            ClientM client = new ClientM();

            client.TlfNo = tlf;
            return(client);
        }
Example #3
0
 public bool Insert(ClientM client)
 {
     using (var context = new DataEntities())
     {
         context.ClientMs.Add(client);
         return(context.SaveChanges() > 0);
     }
 }
Example #4
0
        public void TestNewClientReturnOne()
        {
            ClientCrud _sut     = new ClientCrud();
            int        expected = 1;
            ClientM    client   = new ClientM();
            int        actual   = _sut.NewClient("123456", "Peter", "Nielsen", "Solvej 4", 8600, "*****@*****.**", "22222");

            Assert.AreEqual(expected, actual);
        }
Example #5
0
        // Show calendar window
        private void ShowDateScreen()
        {
            if (ShowDateScreenAction != null)
            {
                ShowDateScreenAction.Invoke();
            }

            _selectedClient = null;
        }
Example #6
0
 public bool Insert(ClientM client)
 {
     try
     {
         return(clientproxy.Insert(client));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #7
0
 public bool Update(ClientM client)
 {
     try
     {
         return(clientproxy.Update(client));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #8
0
        internal int NewClient(string cpr, string fName, string lName, string address, int postNo, string eMail, string tlf)
        {
            ClientM client = new ClientM();

            client.CprNo     = cpr;
            client.FirstName = fName;
            client.LastName  = lName;
            client.Address   = address;
            client.PostNo    = postNo;
            client.Email     = eMail;
            client.TlfNo     = tlf;
            return(_dbClient.NewClient(client));
        }
Example #9
0
        public int UpdateClient(ClientM client)
        {
            _command.CommandText = "UPDATE Client SET CprNo = @cpr, Address = @Address, PostNo = @PostNo," +
                                   " Email = @Email,  TlfNo = @TlfNo WHERE ID = @id";

            _command.Parameters.Clear();
            _command.Parameters.Add(new SqlParameter("@id", client.Id));
            _command.Parameters.Add(new SqlParameter("@cpr", client.CprNo));
            _command.Parameters.Add(new SqlParameter("@Address", client.Address));
            _command.Parameters.Add(new SqlParameter("@PostNo", client.PostNo));
            _command.Parameters.Add(new SqlParameter("@Email", client.Email));
            _command.Parameters.Add(new SqlParameter("@TlfNo", client.TlfNo));
            return(ExecuteNonQuery());
        }
Example #10
0
        public bool Update(ClientM client)
        {
            using (var context = new DataEntities())
            {
                var clientUpdate = context.ClientMs.SingleOrDefault(x => x.IdClient == client.IdClient);
                clientUpdate.IdClient    = client.IdClient;
                clientUpdate.Id          = client.Id;
                clientUpdate.Name        = client.Name;
                clientUpdate.Age         = client.Age;
                clientUpdate.Nationality = client.Nationality;
                clientUpdate.Active      = Convert.ToBoolean(client.Active);
                clientUpdate.UserCreate  = client.UserCreate;
                clientUpdate.DateCreate  = client.DateCreate;

                return(context.SaveChanges() > 0);
            }
        }
Example #11
0
        public int NewClient(ClientM client)
        {
            string sqlString = "INSERT INTO Client (CprNo, FirstName, LastName, Address, PostNo, Email, TlfNo) " +
                               "VALUES (@CprNo, @FirstName, @LastName, @Address, @PostNo, @Email, @TlfNo)";

            _command.CommandText = sqlString;
            _command.Parameters.Clear();
            _command.Parameters.Add(new SqlParameter("@CprNo", client.CprNo));
            _command.Parameters.Add(new SqlParameter("@FirstName", client.FirstName));
            _command.Parameters.Add(new SqlParameter("@LastName", client.LastName));
            _command.Parameters.Add(new SqlParameter("@Address", client.Address));
            _command.Parameters.Add(new SqlParameter("@PostNo", client.PostNo));
            _command.Parameters.Add(new SqlParameter("@Email", client.Email));
            _command.Parameters.Add(new SqlParameter("@TlfNo", client.TlfNo));

            return(ExecuteNonQuerySqlReturnId());
        }
Example #12
0
        public ActionResult Update(ClientM client)
        {
            HttpClient clientHttp = new HttpClient();

            clientHttp.BaseAddress = new Uri("https://localhost:44324/");
            var request = clientHttp.PutAsync("api/Client", client, new JsonMediaTypeFormatter()).Result;

            if (request.IsSuccessStatusCode)
            {
                var resulstring = request.Content.ReadAsStringAsync().Result;
                var result      = JsonConvert.DeserializeObject <bool>(resulstring);


                if (result)
                {
                    return(RedirectToAction("Index"));
                }
                return(View(client));
            }
            return(View(client));
        }
Example #13
0
        public List <ClientM> GetClients(bool active)
        {
            List <ClientM> clients = new List <ClientM>();

            if (active == true)
            {
                _command.CommandText = "SELECT * FROM Client WHERE CprNo IS NOT NULL";
            }
            else
            {
                _command.CommandText = "SELECT * FROM Client WHERE CprNo IS NULL";
            }
            _command.Parameters.Clear();
            PrepareSql();
            SqlDataReader reader = null;

            reader = _command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    ClientM c = new ClientM();
                    c.Id        = reader["ID"] != DBNull.Value ? Convert.ToInt32(reader["ID"]) : default(int);
                    c.CprNo     = reader["CprNo"] != DBNull.Value ? reader["CprNo"].ToString() : string.Empty;
                    c.FirstName = reader["FirstName"] != DBNull.Value ? reader["FirstName"].ToString() : string.Empty;
                    c.LastName  = reader["LastName"] != DBNull.Value ? reader["LastName"].ToString() : string.Empty;
                    c.Address   = reader["Address"] != DBNull.Value ? reader["Address"].ToString() : string.Empty;
                    c.PostNo    = reader["PostNo"] != DBNull.Value ? Convert.ToInt32(reader["PostNo"]) : default(int);
                    c.Email     = reader["Email"] != DBNull.Value ? reader["Email"].ToString() : string.Empty;
                    c.TlfNo     = reader["TlfNo"] != DBNull.Value ? reader["TlfNo"].ToString() : string.Empty;
                    clients.Add(c);
                }
            }
            _connection.Close();
            return(clients);
        }
Example #14
0
 //Lisa
 public int NewClient(ClientM client)
 {
     return(1);
 }
Example #15
0
 public int UpdateClient(ClientM client)
 {
     return(1);
 }
Example #16
0
        public bool Put(ClientM client)
        {
            var list = clientProxy.Update(client);

            return(list);
        }
Example #17
0
        public bool Post(ClientM client)
        {
            var list = clientProxy.Insert(client);

            return(list);
        }
Example #18
0
        //ajax
        public ActionResult getClient(string term)
        {
            ClientM clM = new ClientM();

            return(Json(clM.getClient(term), JsonRequestBehavior.AllowGet));
        }