Improving a Cheese Filter loading in C#
Your code is really hard to follow. It reads and modifies a lot of local fields/properties that are somewhere hidden. I tried to refactor it but it's still buggy I believe as some parameters are unclear. Nevertheless it should give you an idea how to improve it.



Using Tuple is a quick and dirty way to test something because you almost instantly forget what the properties are for as they are simply named ItemX. If you plan to use this code longer then just for experiments I'd use a real class.

You should pass all the parameters that the function needs instead reading them from the some fields or properties... unless it's a part of some class which we don't know.

In particular you could create filter criteria for passing the parameters and return a cheese filter as a result.

You don't need to check the date string for null/empty, the TryParse won't throw on null, that's what it is for.

Work on your variable names. tmp, tmp2 are not good at all. Give them real names, like dateStart or dateEnd or even tmpDateStart but just tmp isn't good enough.

Here's an example that I managed to piece together:

public class FilterCriteria
{
    public CheeseFilter? filter { get; set; }
    public string DateStart { get; set; }
    public string DateEnd { get; set; }
    public String Country { get; set; }
}

class CheeseFilter
{
    public FilterCriteria Criteria { get; set; }
    public string SPName { get; set; }
    public List&lt;SqlParameter&gt; SqlParameters { get; set; }
}

public CheeseFilter CreateCheeseFilter(FilterCriteria filterCriteria)
{
    var isValidDateFormat = false;
    var sqlParameters = new List&lt;SqlParameter&gt;();
    var SPName = "ERROR";

    var dateStart = new DateTime(); // ForChecking GoodFormating of datetimes
    var dateEnd = new DateTime();

    switch (GetMode().Value)
    {
        case CheeseFilter.DateFrom:
            isValidDateFormat = DateTime.TryParseExact(filterCriteria.DateStart, TMP_DATEFORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp);;
            if (!isValidDateFormat) retrun null;

            sqlParameters.Add(new SqlParameter() { Name =  "@DateStart", Value = tmp.ToString("yyyyMMdd")});
            SPName = "Cheese_FromDate";
            break;

        case CheeseFilter.DateStart:
            isValidDateFormat = DateTime.TryParseExact(filterCriteria.DateStart, TMP_DATEFORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None, out tmp);
            if (!isValidDateFormat) retrun null;

            sqlParameters.Add(new SqlParameter() { Name = "@DateEnd", Value = tmp.ToString("yyyyMMdd") });
            SPName = "Cheese_To_Date";
            break;

        case CheeseFilter.BetweenDates:
            isValidDateFormat = 
                DateTime.TryParse(filterCriteria.DateStart, out dateStart) &amp;&amp; 
                DateTime.TryParse(filterCriteria.DateEnd, out dateEnd);
            if (!isValidDateFormat) retrun null;

            sqlParameters.Add( new SqlParameter() { Name = "@DateStart",Value =  tmp.ToString("yyyyMMdd")}); //Converting for sqlServer
            sqlParameters.Add( new SqlParameter() { Name = "@DateEnd", Value = tmp2.ToString("yyyyMMdd")});
            SPName = "Cheese_Between_Date";
            break;

    }

    return new CheeseFilter 
    { 
        Criteria = GetMode().Value
        SPName = SPName
        SqlParameters = options
    };
}