콤마찍기

string.Format("{0:#,0}", 값)
string.Format("{0,9:N0}", row["field"]) + "원"; 



콤마제거

string[] itemAmount = null;  //금액(Split처리용)
string itemAmount2 = null;   //금액(,제거한 값)

itemAmount = ItemChild.ChildNodes[4].InnerText.Split(new Char[] { ',' });

for (int j = 0; j < itemAmount.Length; j++)
{
 itemAmount2 += itemAmount[j];
}


Posted by 뭉치냐옹
:

/// <summary>
  /// 반올림 함수
  /// </summary>
  /// <param name="obj">반올림하고자 하는 값</param>
  /// <param name="dgt">표시하고자 하는 소숫점 자리수</param>
  /// <returns></returns>
  public static string GetFormattedString( object obj, int dgt )
  {
   double cv = 0;
   string dumStr = string.Empty;
   int totLen = 2 + dgt;

   for( int i = 0; i < dgt; i ++ )
    dumStr += "0";

   if( obj == null )
    return "0." + dumStr;

   if( obj is string )
   {
    if(Convert.ToString(obj as string).Trim() == string.Empty )
    {
     return "0." + dumStr;
    }
    cv = double.Parse(Convert.ToString(obj as string).Trim());
   }
   else if( obj is double )
   {
    cv = (double)obj;
   }
   else if( obj is int )
   {
    cv = (int)obj;
   }
   else if ( obj is float )
   {
    cv = (float)obj;
   }

   // Gets a NumberFormatInfo associated with the en-US culture.
   System.Globalization.NumberFormatInfo nfi = new System.Globalization.CultureInfo( "en-US", false ).NumberFormat;
   // Displays the same value with four decimal digits.
   nfi.NumberDecimalDigits = dgt;

   return cv.ToString( "N", nfi );
  }


Posted by 뭉치냐옹
:

.aspx.cs

strEvtComID = "0x0000000000000034";

Biz.매서드(int.Parse( strEvtComID.Replace( "0x", "" ), NumberStyles.HexNumber ))  // int.Parse로 형변환

 

.Biz.cs

public int put_WB_Consult_Product(int _TY_EventCompany_ID)
  {
   SqlParameter[] p = new SqlParameter[0];

   try
   {
    p[0] = new SqlParameter( "@TY_WB_Customer_Consult_Id" , SqlDbType.BigInt);
    p[0].Value = _PK;

    return this.DbAccess.RunSPNonQuery( "SP_WB_Event_Consult_INSERT", Site.GetReplace(p) );
   }
   catch ( Exception ex )
   {
    this.TraceWrite( System.Diagnostics.TraceLevel.Error, ex.Message ); // 에러를 로그파일에 입력

    return 0;
   }
  }

 

 

SP

CREATE  PROCEDURE SP_WB_Event_Consult_INSERT
    @TY_WB_Customer_Consult_Id BINARY(8)

 

 

Table

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TY_WB_Customer_Consult]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TY_WB_Customer_Consult]
GO

CREATE TABLE [dbo].[TY_WB_Customer_Consult] (
 [Contact_Id] [binary] (8) NULL ,
 [C_idx] [int] NULL ,
 [Product_Id] [binary] (8) NULL ,
 [Product_Name] [varchar] (100) COLLATE Korean_Wansung_CI_AS NULL ,
 ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


Posted by 뭉치냐옹
:

변수명.PadLeft(2, '0');


Posted by 뭉치냐옹
:
using System;

 using System.Globalization;

 

public class MainClass {

    public static void Main(string[] args)  {

        DateTime dt = DateTime.Now;

        String[] format = {

            "d", "D",

            "f", "F",

            "g", "G",

            "m",

            "r",

            "s",

            "t", "T",

            "u", "U",

            "y",

            "dddd, MMMM dd yyyy",

            "ddd, MMM d \"'\"yy",

            "dddd, MMMM dd",

            "M/yy",

            "dd-MM-yy",

        };

        String date;

        for (int i = 0; i < format.Length; i++) {

            date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);

            Console.WriteLine(String.Concat(format[i], " :" , date));

        }

 

   /** Output.

    *

    * d :08/17/2000

    * D :Thursday, August 17, 2000

    * f :Thursday, August 17, 2000 16:32

    * F :Thursday, August 17, 2000 16:32:32

    * g :08/17/2000 16:32

    * G :08/17/2000 16:32:32

    * m :August 17

    * r :Thu, 17 Aug 2000 23:32:32 GMT

    * s :2000-08-17T16:32:32

    * t :16:32

    * T :16:32:32

    * u :2000-08-17 23:32:32Z

    * U :Thursday, August 17, 2000 23:32:32

    * y :August, 2000

    * dddd, MMMM dd yyyy :Thursday, August 17 2000

    * ddd, MMM d "'"yy :Thu, Aug 17 '00

    * dddd, MMMM dd :Thursday, August 17

    * M/yy :8/00

    * dd-MM-yy :17-08-00

    */

    }

}


Posted by 뭉치냐옹
:

l         .NET 날짜와 시간 표시 부분만을 정리 것입니다.

 

Item

Description

Format

Year

4 digit Year with century (1998 or 2003)

yyyy

2 digit Year without century (98 or 03)

yy

1,3 digit Year (3 for 2003)

y

Era (BC/AD)

gg

Month

Month as a decimal (02)

MM

Month without leading zero (2)

M

Abbreviated month name (Feb)

MMM

Full month name (February)

MMMM

Week

Abbreviated day name (Fri)

ddd

Weekday Name (Friday)

dddd

Day

Day of the month (03)

dd

Day without leading zero (3)

d

Time

Hour in 24 hour format (24)

H,HH

Hour in 12 hour format (03)

h,hh

Minute of hour as an integer (01)

m,mm

Second in minute (55)

ss

Second in minute with no leading zero (5)

s

 

l         아래는 Format 문자열을 이용한 예제 코드입니다.

 

using System;

 

class Program

{

  static void Main(string[] args)

  {

      Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd"));

      Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:ss"));

      Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:ss.fff"));

      Console.WriteLine(DateTime.Now.ToString("(tt) yyyy-MM-dd hh:ss.fff"));

      Console.WriteLine(DateTime.Now.ToString("(tt) yyyy-MM-dd hh:ss.fffzz"));

}

}

 

l         아래는 예제 코드를 실행 결과입니다.

 2006-03-21

2006-03-21 11:35

2006-03-21 11:35.206

(오전) 2006-03-21 11:35.206

(오전) 2006-03-21 11:35.206+09

Posted by 뭉치냐옹
: