public List<Pelayaran> GetPelayaran()
        {
            List<Pelayaran> listPelayaran = null;

            try
            {
                using (SqlConnection con = new SqlConnection(VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString))
                {
                    Constant.VisitaJayaPerkasaApplication.anyConnection = false;
                    con.Open();
                    Constant.VisitaJayaPerkasaApplication.anyConnection = true;

                    using (SqlCommand command = new SqlCommand(
                        "SELECT pelayaran_id, pelayaran.supplier_id, supplier.supplier_name as name FROM [Pelayaran], [supplier] " + 
                        "WHERE (pelayaran.deleted is null OR pelayaran.deleted = '0') " +
                        "and ([supplier].deleted is null OR [supplier].deleted = '0') " +
                        "and [supplier].supplier_id = pelayaran.supplier_id " + 
                        "ORDER BY name ASC"
                        , con))
                    {
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            Pelayaran pelayaran = new Pelayaran();
                            pelayaran.ID = Utility.Utility.ConvertToUUID(reader.GetValue(0).ToString());
                            pelayaran.supplierID = Utility.Utility.ConvertToUUID(reader.GetValue(1).ToString());
                            pelayaran.supplierName = reader.GetString(2);

                            if (listPelayaran == null)
                                listPelayaran = new List<Pelayaran>();

                            listPelayaran.Add(pelayaran);
                            pelayaran = null;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logging.Error("SqlPelayaranRepository.cs - GetPelayaran() " + e.Message);
            }

            return listPelayaran;
        }
        public Pelayaran GetPelayaranBySupplierID(string supplierId)
        {
            Pelayaran pelayaran = null;

            try
            {
                using (SqlConnection con = new SqlConnection(VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString))
                {
                    Constant.VisitaJayaPerkasaApplication.anyConnection = false;
                    con.Open();
                    Constant.VisitaJayaPerkasaApplication.anyConnection = true;

                    using (SqlCommand command = new SqlCommand(
                    "Select pelayaran_id, p.supplier_id, supplier_name From Pelayaran p, Supplier s " +
                    "where p.supplier_id = s.supplier_id and (p.deleted is null or p.deleted = '0') and " + 
                    "p.supplier_id = '" + supplierId+ "'" 
                    , con))
                    {
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            pelayaran = new Pelayaran();
                            pelayaran.ID = Utility.Utility.ConvertToUUID(reader.GetValue(0).ToString());
                            pelayaran.supplierID = Utility.Utility.ConvertToUUID(reader.GetValue(1).ToString());
                            pelayaran.supplierName = reader.GetString(2);
                        }
                    }
                }
            }
            catch (Exception e)
            {

                Logging.Error("SqlPelayaranRepository.cs - GetPelayaranBySupplierID() " + e.Message);
            }

            return pelayaran;
        }
        public Pelayaran CheckPelayaranForEdit(SqlParameter[] sqlParam)
        {
            Pelayaran pelayaran = null;

            try
            {
                using (SqlConnection con = new SqlConnection(VisitaJayaPerkasa.Constant.VisitaJayaPerkasaApplication.connectionString))
                {
                    Constant.VisitaJayaPerkasaApplication.anyConnection = false;
                    con.Open();
                    Constant.VisitaJayaPerkasaApplication.anyConnection = true;

                    using (SqlCommand command = new SqlCommand(
                        "SELECT TOP 1 pelayaran_id, pelayaran.supplier_id, supplier.supplier_name FROM [Pelayaran], [supplier] " + 
                        "WHERE pelayaran.supplier_id = supplier.supplier_id and supplier.supplier_name = " + sqlParam[0].ParameterName, con))
                    {
                        foreach (SqlParameter tempSqlParam in sqlParam)
                            command.Parameters.Add(tempSqlParam);

                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            pelayaran = new Pelayaran();
                            pelayaran.ID = Utility.Utility.ConvertToUUID(reader.GetValue(0).ToString());
                            pelayaran.supplierID = Utility.Utility.ConvertToUUID(reader.GetValue(1).ToString());
                            pelayaran.supplierName = reader.GetString(2);
                        }
                    }
                }
            }
            catch (Exception e)
            {

                Logging.Error("SqlPelayaranRepository.cs - CheckPelayaranForEdit() " + e.Message);
            }

            return pelayaran;
        }