public List<ParameterValues> GetSectionParameterValues(string pConString, string pVkn, int pModulId, int? pParameterID = null)
        {
            using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(pConString))
            {
                List<ParameterValues> PartnerParametersList = new List<ParameterValues>();
                using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                {
                    cmd.CommandText = @" SELECT TypeID,ParameterID,TopParameterID,VKN,ModulId ,DataType,
                                         ApplicationType,Value,Description,Secured,Required,FL_ACTIVE,Versiyon
                                         FROM ParameterValues
                                         WHERE VKN = @VKN AND ModulId = @ModulId";

                    if (pParameterID != null)
                    {
                        cmd.CommandText += " AND ParameterID = @ParameterID ";
                        cmd.Parameters.AddWithValue("@ParameterID", pParameterID);
                    }

                    cmd.Parameters.AddWithValue("@VKN", pVkn);
                    cmd.Parameters.AddWithValue("@ModulID", pModulId);
                    cmd.CommandText += " ORDER BY TypeID";

                    using (DataTable dt = DB_Gateway.ExecuteDataTable(cmd, connection))
                    {
                        if (dt != null)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                ParameterValues objPartnerParameters = new ParameterValues();
                                objPartnerParameters.TransferToClass(dr);
                                PartnerParametersList.Add(objPartnerParameters);
                            }
                        }
                    }
                }

                if (connection != null)
                    connection.Close();

                return PartnerParametersList;
            }
        }
        public List<ParameterValues> GetAllParameterValuesForEledger(string connection, GlobalEnum.Modul pModulID, string pVKN, string pDataType = "")
        {
            var ParameterValueList = new List<ParameterValues>();

            using (var con = new SqlConnection(connection))
            {
                if (con.State != System.Data.ConnectionState.Open)
                    con.Open();
                using (var cmd = con.CreateCommand())
                {
                    cmd.CommandText = @"SELECT TypeID, ParameterID, TopParameterID, VKN, ModulId, DataType, ApplicationType
                                              ,Value, Description, Secured, Required, FL_ACTIVE, Versiyon
                                        FROM ParameterValues
                                        WHERE ModulID = @ModulID AND VKN = @VKN";

                    if (!string.IsNullOrEmpty(pDataType))
                    {
                        cmd.CommandText += @" AND DataType = @DataType";
                        cmd.Parameters.AddWithValue("@DataType", pDataType);
                    }

                    cmd.Parameters.AddWithValue("@VKN", pVKN);
                    cmd.Parameters.AddWithValue("@ModulID", (int)pModulID);
                    cmd.CommandText += @" ORDER BY TypeID";

                    using (DataTable dt = DB_Gateway.ExecuteDataTable(cmd, con))
                    {
                        if (dt != null)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                ParameterValues parameterValue = new ParameterValues();
                                parameterValue.TransferToClass(dr);
                                      ParameterValueList.Add(parameterValue);

                            }
                        }
                    }
                }
            }
            return ParameterValueList;
        }
        public List<ParameterValues> GetParametersByTopID(string connectionString, string pVKN, int pModulID, int pTopParameterID)
        {
            using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
            {
                List<ParameterValues> PartnerParametersList = new List<ParameterValues>();
                using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
                {
                    cmd.CommandText = @"SELECT TypeID, Value,TopParameterID ,ModulId ,Description,VKN,Secured
                                        FROM ParameterValues
                                        where TopParameterID = @TopParameterID and ModulID = @ModulID and  VKN = @VKN AND FL_ACTIVE = 1
                                        order by TypeID";
                    cmd.Parameters.AddWithValue("@TopParameterID", pTopParameterID);
                    cmd.Parameters.AddWithValue("@ModulID", pModulID);
                    cmd.Parameters.AddWithValue("@VKN", pVKN);

                    using (DataTable dt = DB_Gateway.ExecuteDataTable(cmd, connection))
                    {
                        if (dt != null)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                ParameterValues objPartnerParameters = new ParameterValues();
                                objPartnerParameters.TopParameterID = DataHelper.ReadInt(dr, "TopParameterID");
                                objPartnerParameters.TypeID = DataHelper.ReadInt(dr, "TypeID");
                                objPartnerParameters.Value = DataHelper.ReadString(dr, "Value");
                                objPartnerParameters.Description = DataHelper.ReadString(dr, "Description");
                                objPartnerParameters.Secured = DataHelper.ReadBool(dr, "Secured");
                                PartnerParametersList.Add(objPartnerParameters);
                            }
                        }
                    }
                }
                if (connection != null) connection.Close();
                return PartnerParametersList;
            }
        }
        public List<ParameterValues> GetAllByModulIDTypeID(GlobalEnum.Modul ModulID, GlobalEnum.PARTNER_PARAMETERS TypeID)
        {
            var list = new List<ParameterValues>();
            using (var con = new SqlConnection(GlobalSettings.OrganizationConnectionString))
            {
                if (con.State != System.Data.ConnectionState.Open)
                    con.Open();
                using (var cmd = con.CreateCommand())
                {
                    cmd.CommandText = @"SELECT ParameterValues.Value,Partner.VKN ,ParameterValues.Secured
                                        FROM ParameterValues
                                            INNER JOIN Partner ON Partner.VKN = ParameterValues.VKN
                                        WHERE Partner.FL_ACTIVE = 1 AND Partner.Active = 1
                                            AND ParameterValues.TypeID = @TypeID
                                            AND ParameterValues.ModulID = @ModulID
                                            AND ParameterValues.FL_ACTIVE = 1";

                    cmd.Parameters.AddWithValue("@TypeID", (int)TypeID);
                    cmd.Parameters.AddWithValue("@ModulID", (int)ModulID);

                    using (DataTable dt = DB_Gateway.ExecuteDataTable(cmd, con))
                    {
                        if (dt != null)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                ParameterValues value = new ParameterValues();
                                value.TransferToClass(dr);
                                       list.Add(value);

                            }
                        }
                    }
                }
            }
            return list;
        }