Archive for Marzo, 2008

Get Next Seq Num

CodeKeep C# Feed Marzo 31st, 2008

Description: Get the next sequence number for the given sequence name

Link: http://www.codekeep.net/snippets/d6fe0074-16c8-4e56-b17c-f373ab1c8e91.aspx

    internal static int GetNextSeqNumber(String SequenceName)
    {
        String Sql;
        Sql = "declare @sequence_id INT execute nextval '" + SequenceName + "', @sequence_id output Select @sequence_id as SequenceNumber";
        return ExecuteSQl(Sql); 
    

get SQL Command

CodeKeep C# Feed Marzo 31st, 2008

Description: get a sql command from SQL String and a transaction (optional)

Link: http://www.codekeep.net/snippets/919b1d90-deaf-4513-87f8-29e58ec6adda.aspx

    private static SqlCommand getSQlCommand(String SQl, SqlTransaction trans)
    {
        SqlCommand cmd = new SqlCommand(SQl);
        if (con != null)
        {
            if (con.State != ConnectionState.Open)
            {
                OpenConnection();
            }
        }
        else
        {
            OpenConnection();
        }
        cmd.Connection = con;
        if (trans != null)
        {
            cmd.Transaction = trans;
        }
        return cmd;
    }

Start Transaction

CodeKeep C# Feed Marzo 31st, 2008

Description: Method to start a transactin

Link: http://www.codekeep.net/snippets/b6c50ee2-290c-477d-8a81-ea44c8fc251f.aspx

    public static SqlTransaction StartTransaction()
    {
        SqlTransaction trans;
        con = new SqlConnection(ConnectionString);
        con.Open();
        trans = con.BeginTransaction();
        return trans;
    }

breasts thong kissing making out booty

geiler arsch reitet grossen penis 4

Forex News Day Trading Signal - 03/31/08

maurodx webmaster@mdkis.110mb.com Marzo 31st, 2008

Great Forex calls today!

[Read More…]

Universally Related Popup Menus AJAX Edition: Part 3

WebReference News Marzo 31st, 2008

Last week we looked at an in-depth explanation of the JavaScript code. This week, we conclude the series with a line-by-line walkthrough of the JavaScript code and describe the server-side classic ASP script code. By Rob Gravelle. 0206

ExecuteCMD

CodeKeep C# Feed Marzo 30th, 2008

Description: Executes a cmd command in backgroud with cmd.exe

Link: http://www.codekeep.net/snippets/2538c13a-01bf-434a-a42b-63c87e184b31.aspx

	    ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
            Process processo = Process.Start(info);

            info.CreateNoWindow = true;
            info.RedirectStandardInput = true;
            info.RedirectStandardOutput = true;
            info.RedirectStandardError = true;
            info.UseShellExecute = false;

            processo.Start();
            processo.StandardInput.WriteLine("DIR *.*");
            processo.StandardInput.Flush();
            processo.StandardInput.Close();

TimeFormatter

CodeKeep C# Feed Marzo 28th, 2008

Description: A class that helps you to format a time string to a specific format (With meridians, AM/PM or military time)

Link: http://www.codekeep.net/snippets/411cceb9-39dd-4752-9ac7-e215b1a7dd19.aspx

public static class TimeFormatter
{

    /// <summary>
    /// Formats a time string with a meridian (:)
    /// </summary>
    /// <param name="time">The string representing the time</param>
    /// <returns>A properly formatted string that represents a time with meridians</returns>
    public static string FormatTimeMeridian(string time)
    {
        time = time.Trim();
        string value = time;

        Regex testForAMPMWithoutColon = new Regex("^\\d{0,6}[^:]( ?[aApP][mM]?)$");
        Regex testForMilitaryTime = new Regex("(\\:)");

        if (testForAMPMWithoutColon.IsMatch(value))
        {

            string sTime = NumberParser.ParseInt(value).ToString(CultureInfo.InvariantCulture); //parseInt(value,10).toString();
            if (value.Substring(0, 1) == "0")
                sTime = "0" + sTime;
            switch (sTime.Length)
            {
                case 1:	// h
                    value = value.Substring(0, 1) + ":00" + value.Substring(1);
                    break;
                case 2:	// hh
                    value = value.Substring(0, 2) + ":00" + value.Substring(2);
                    break;
                case 3:	// hmm
                    value = value.Substring(0, 1) + ":" + value.Substring(1);
                    break;
                case 4:	// hhmm
                    value = value.Substring(0, 2) + ":" + value.Substring(2);
                    break;
                case 5:	// hmmss
                    value = value.Substring(0, 1) + ":" + value.Substring(1, 2) + ":" + value.Substring(3);
                    break;
                case 6:	// hhmmss
                    value = value.Substring(0, 2) + ":" + value.Substring(2, 2) + ":" + value.Substring(4);
                    break;
                default:
                    break;
            }
        }
        else if (!testForMilitaryTime.IsMatch(value))
        {
            // Military time.
            switch (value.Length)
            {
                case 1:	// h
                    value = value.Substring(0, 1) + ":00";
                    break;
                case 2:	// hh
                    value = value.Substring(0, 2) + ":00";
                    break;
                case 3:	// hmm
                    value = value.Substring(0, 1) + ":" + value.Substring(1, 2);
                    break;
                case 4:	// hhmm
                    value = value.Substring(0, 2) + ":" + value.Substring(2, 2);
                    break;
                case 5:	// hmmss
                    value = value.Substring(0, 1) + ":" + value.Substring(1, 2) + ":" + value.Substring(3, 2);
                    break;
                case 6:	// hhmmss
                    value = value.Substring(0, 2) + ":" + value.Substring(2, 2) + ":" + value.Substring(4, 2);
                    break;
                default:
                    break;
            }
        }

        return value;
    }

    const string DefaultTimeFormat = "h:mm AM/PM";

    /// <summary>
    /// Formats a string representing a time to a specific format
    /// </summary>
    /// <param name="value">The String representing the Time</param>
    /// <param name="format">The format of the return time string</param>
    /// <returns>A time string</returns>
    public static string FormatToTimeString(string value, string format)
    {
        // Get the date format.
        // If a format was passed, use it, otherwise the default format.
        string fmt = String.Empty;

        if (String.IsNullOrEmpty(format.Trim()))
            fmt = DefaultTimeFormat;
        else
            fmt = format;
        Regex re = new Regex("^(h|hh)(:mm)(:ss)?( am\\/pm| AM\\/PM| a\\/p| A\\/P)?$");

        // Use the default format if the provided format is not valid.
        if (!re.IsMatch(fmt))
            fmt = "h:mm AM/PM";

        bool hasMeridian = false;
        string[] meridian = "am,pm".Split(',');

        Regex regExHasMeridian = new Regex("\\b(am\\/pm|AM\\/PM|a\\/p|A\\/P)\\b");

        if (regExHasMeridian.IsMatch(fmt))
        {
            int meridianLength = 0;
            hasMeridian = true;

            Regex regExHasLowerCaseMeridian = new Regex("\\bam\\/pm\\b");
            Regex regExHasUpperCaseMeridian = new Regex("\\bAM\\/PM\\b");
            Regex regExHasOneLetterLowerCaseMeridian = new Regex("a\\/p");
            Regex regExHasOneLetterUpperCaseMeridian = new Regex("\\bA\\/P\\b");

            if (regExHasLowerCaseMeridian.IsMatch(fmt))
            {
                meridian = "am,pm".Split(',');
                meridianLength = 6;
            }
            else if (regExHasUpperCaseMeridian.IsMatch(fmt))
            {
                meridian = "AM,PM".Split(',');
                meridianLength = 6;
            }
            else if (regExHasOneLetterLowerCaseMeridian.IsMatch(fmt))
            {
                meridian = "a,p".Split(',');
                meridianLength = 4;
            }
            else if (regExHasOneLetterUpperCaseMeridian.IsMatch(fmt))
            {
                meridian = "A,P".Split(',');
                meridianLength = 4;
            }

            fmt = fmt.Substring(0, fmt.Length - meridianLength);
        }

        // Initialize time variables.
        Regex regExValueHasMeridian = new Regex("[aApP][mM]?$");
        string h = "0";
        string m = "00";
        string s = "00";
        string sMeridian = "";
        bool valueHasMeridian = regExValueHasMeridian.IsMatch(value);
        string sTemp = "";
        string[] values = value.Split(':');
        string[] fmtItems = fmt.Split(':');

        // Go through each item in the value field.
        for (int i = 0; i < values.Length; i++)
        {
            if (i >= fmtItems.Length)
                break;

            switch (fmtItems[i])
            {
                case "h":
                case "hh":
                    int iTemp = NumberParser.ParseInt(values[i]);
                    // Make sure the hours are in 24 hour format.
                    if (valueHasMeridian)
                    {
                        Regex regExIsPM = new Regex("[pP][mM]?$");
                        Regex regExIsAM = new Regex("[aA][mM]?$");

                        if (regExIsPM.IsMatch(value))
                        {
                            if (iTemp < 12)
                                iTemp += 12;
                        }
                        else if (regExIsAM.IsMatch(value) && iTemp == 12)
                        {
                            iTemp = 0;
                        }
                    }

                    // Does the format string expect a Meridian?
                    // If so put the hours in 12 hour format.
                    if (hasMeridian)
                    {
                        if (iTemp > 12)
                        {			// pm
                            iTemp -= 12;
                            sMeridian = meridian[1];
                        }
                        else if (iTemp == 12)
                        {		// pm
                            sMeridian = meridian[1];
                        }
                        else if (iTemp > 0)
                        {		// am
                            sMeridian = meridian[0];
                        }
                        else if (iTemp == 0)
                        {		// am
                            iTemp = 12;
                            sMeridian = meridian[0];
                        }
                    }

                    // Format the hours.
                    if (fmtItems[i] == "h")
                    {
                        h = iTemp.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        sTemp = "0" + iTemp.ToString(CultureInfo.InvariantCulture);
                        h = sTemp.Substring(sTemp.Length - 2, sTemp.Length);
                    }

                    break;

                case "mm":
                    // Format minutes.
                    sTemp = "0" + NumberParser.ParseInt(values[i]).ToString(CultureInfo.InvariantCulture);
                    m = sTemp.Substring(sTemp.Length - 2, 2);
                    break;

                case "ss":
                    // Format seconds.
                    sTemp = "0" + NumberParser.ParseInt(values[i]).ToString(CultureInfo.InvariantCulture);
                    s = sTemp.Substring(sTemp.Length - 2, 2);
                    break;
            }
        }

        // Format time string.
        if (fmtItems.Length == 2)
            return h + ":" + m + (hasMeridian ? " " + sMeridian : "");

        return h + ":" + m + ":" + s + (hasMeridian ? " " + sMeridian : "");
    }
}

Background Worker Do Work

CodeKeep C# Feed Marzo 28th, 2008

Description: This Handler is the meat and potatoes of the whole thing, executes when the RunAsync Command is executed.

Link: http://www.codekeep.net/snippets/a254816d-7f21-4761-bc99-f0d2e4a8eb6f.aspx

        private void backgroundLogin_DoWork(object sender, DoWorkEventArgs e)
        {
            System.Threading.Thread.Sleep(5000);
            if (Sync == null)
            {
                _sync = new Synchronization();
            }

            if (Sync.Login(Username.Text, Password.Text, Anonymous.Checked))
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                _ErrorMessage = Sync.ErrorMessage;

            }

        }

Next »