Sunday, January 20, 2008

Sun to Acquire MySQL

From MySQL website: Sun to Acquire MySQL

Sun Microsystems Announces Agreement to Acquire MySQL, Developer of the World's Most Popular Open Source Database
Sun Growth Strategy Accelerates With New Position in $15 Billion Database Market

SANTA CLARA, CA January 16, 2008 Sun Microsystems, Inc. (NASDAQ: JAVA) today announced it has entered into a definitive
agreement to acquire MySQL AB, an open source icon and developer of one of the world's fastest growing open source databases
for approximately $1 billion in total consideration. The acquisition accelerates Sun's position in enterprise IT to now include the $15
billion database market. Today's announcement reaffirms Sun's position as the leading provider of platforms for the Web economy
and its role as the largest commercial open source contributor.

...
[blah blah]
...

Seems like Sun bouncing back. Sun has a complete portfolio from hardware to software. They have server, they have Solaris. They have office, they have Java, and now they have database. Complete solution end-to-end, you can get from Sun Microsystem. Seems like a great strategy for business. Hopefully they are in the right track...

Saturday, September 22, 2007

Eclipse vs Netbeans, Where Is JBuilder? JDeveloper?

There is a hot discussion in my local Java User Group - JUG (by 'local' what I mean is Indonesia) about two open source Java IDEs: Eclipse and Netbeans. The discussion becomes a debates with each party blindly defense their favorites IDE. After programming language, now IDE becomes religions to?
One party said, the real man using Eclipse. Well, not all programmers are men. By saying that, they also said that ladies... please use Netbeans.
Another party said that Eclipse is too heavy, so many 'hidden' features till confusing their user, which I agree with that
They only debating Eclipse and Netbeans because these are the two (probably) most popular IDEs in Java community world-wide.
Where I stand?
Well, honestly I never use Eclipse and/or Netbeans in my Java projects. I already install both IDEs, do some test here and there, feeling them, try to get any chemistry... I got (almost) nothing. So as quick I install, that's also apply on how quick I uninstall them.

What IDE For Me?
My favorites IDE is Borland JBuilder. This is the IDE that I'm familiar to work with, and with this IDE, I completed several projects included my final year project in Bina Nusantara University (2002). Maybe the familiarity derived from my experience working with Borland Delphi before. I remember, during my university's year, Delphi is my main programming tools (language), and with Delphi also I finished a project in Bank Universal.
But, Borland JBuilder is not free. Yes!
In Indonesia, maybe we have GPL (Glodok Public License - means pirated software), but that's wrong.
That's why now I'm using Oracle JDeveloper as my Java IDE. It's not opensource like Eclipse and Netbeans, but it's freeware, it's legal (In fact, earlier version of JDeveloper is derived from JBuilder, that's why maybe I feel the chemistry).
So, stop talk about IDE, and start code. I'm a JDeveloper guy, I'm different, and that's fine!

Update: Maybe I should not said local JUG for JUG Indonesia. Now, local is Singapore, Indonesia is not local for my 'current' situation. But hey, I'm Indonesian, can't stop thinking that my 'locality' is Indonesia.

Tuesday, December 26, 2006

It’s not a White Christmas, it’s a Colorful Christmas

Yes it’s not white, it’s colorful, and it’s wonderful. First Christmas in a place I called ‘my 3rd home’ (1st Kudus, 2nd Jakarta).

Kudus, +/- 12 years ago
Om Agus: Ok Desson, it’s your job to find a Christmas tree for our church…
Desson: What? Christmas tree? (I think I need to snoop and steal from somebody garden)
Ko Pujo: It’s ok, you can get it in public forest, maybe in Muria (a mountain)?
Desson: Puff, I thought I need to ask one by one to ‘sacrifice’ their tree
(Finally, we get it in the forest - with the permission of forest scout)

Jakarta, a year ago
Danny:
OK, it’s already November and we need to prepare an organizer for this year Christmas celebration (for youth). I’m act as a coordinator.
Desson: And why my name in the list?
Danny: Coz Yohana want your name in the list…
Desson: And her name in the list?
Danny: Sure…
Desson: Perfect, one more thing, Can you change my section? Consumption section perhaps?
Danny: Not necessary, all ladies there.
Desson: Yes, that’s all I want for Christmas!
(Finally I still in multimedia section…)

Singapore, this year

Saturday, 23 Dec 2006
Last practice for Christmas choir and have some session of drama. Go to Burger King (Orchard, near by Borders book store), to get 2 crown for Solomon and Queen of Sheba. After that we enjoy a set of Christmas Carols in Orchard (in front of Takashimaya). Have a set of photographs, going home (almost 12pm, midnight). Some people still go to Geylang and have a Durian session there…

Sunday, 24 Dec 2006Overslept, came late to the church for last drama practice. But the show runs well -peoples laugh. Just thinking, they laughing the things I said, or laughing me. Hi all, you’re so funny (especially Lufi with her Indian’s gesture). Finally, Christmas service is over, we (whole of church) have a dinner (not lunch?) together. After that, we - the youth – spent 2 hours to discuss where to go for tomorrow (2 hours?). And play several session of 'Polar Bear' or ‘Police and Murder’ or I can say ‘Kill the Innocent'?
(Note: Yes, they kill an innocent people, and that’s me. I’m sad when they doubt my integrity, especially when I try to convince them. I said, ‘I’m innocent, look at my face.’ But they undoubtly doubt my integrity. So sad!)
After that, we (6 of us) have another dinner in Kopitiam Plaza Singapura.

Monday, 25 Dec 2006
First of all, Merry Christmas everyone, God bless you. OK, still overslept (again?), and I visit Fifi and Lufi house in Paya Lebar (Yes, after 2 hours of discussion; east coast, bowling, etc finally we decided to go to Lim Sister’s house…). We eat (thanks Tante Rita), we watch (Open Season), and we play (‘Watch your Hand’, ‘Big Fish-Small Fish’, and 'Kill the Innocent'). From Lim’s house we go to Pang’s house in YCK. In Pang’s house, we have (another) Christmas celebration and Thanksgiving. The last but not least; dinner and sing together (I like it). The 4 jomblo (Me, Samuel, Yanadi, and Bayu), the ladies, Javanese Sinden (uhmmm, I mean Pak Herry), Jazz music (Tante Annete - and Om Paul?), and the grand finale : Ahmad Dhani and Ratu… (uhhhm, it’s should be Yanadi and Pang’s Sisters). Everyone happy, everyone full, and everyone going home.

Thanks everyone for a wonderful Christmas, and thanks for Yanti, Grace, Ade, Lukie, Ali, David, Yohana, Hendra, Aries, and Johan for the SMS. Merry Christmas for you all.

I still waiting for a white Christmas.
(Now I'm stuck in the office)

Wednesday, November 22, 2006

Where is My Service Pack?

I read somewhere around Nov/Dec last year (now I forgot where, but still remember when) that service pack for Visual Studio (.NET) 2005 is on the way. But now, we are already in the mid November, and still no news.
If you are a VS 2005 user, you maybe aware that changing a control's id will trigger the refactoring job in the solution. After some times (and it's a long time I can say), and a high CPU committed, it's end with... crash. I'm sick about this, it's already too long.
One year already gone, but the 'problem' is still there...where is the service pack?

Update:
The service pack finally released.
After one year, now I consciously authorized Redmond's product to eat my HD's spaces. Hope it's worth...

Tuesday, November 14, 2006

Have Great Trips, Rich!

Today, my friend Richard Stubbington will start his 8 months journey around the world. We were part of IT team in Baker & McKenzie (my last company). I’m resigned on June, he resigned on October. The reason of resignation is different; I want to earn more money, so I decided to find a job in Singapore. But he earns too much money, so he decided to leave the firm and to go traveling. What a contradiction!

Desson: when u start the journey?
Rich: 15th november going to: Australia, NZ, Singapore, Thailand, China, Sri Lanka, Hong Kong, New York, Chicago, Jamaica, Chile, Argentina, maybe Brazil, Bolivia and Ecuador.
Desson: so many? great...
Rich: yep, going for 8 mths
Desson: and after that 8 mths? back to work to collect your deposits and go again for another trip? :P
Rich: dunno yet, i'lll et you know in 8 months ;)

The fact is he will leaving today. So have good trips my friend, and see you on Feb. Ex-Manila team (Jovie, Rhea, Mike?, Ruben?, Rommel?, etc) already prepare some special welcome to Rich. As the only ex Jakarta team, I must be there (inviting myself :p ).

(Psssst, I just want to know how much money Rich spend for the trips, coz maybe someday I can have my own journey…)

Monday, August 21, 2006

Form DateCalculator

Sometimes I need to calculate date, this form can help
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DateCalculator
{
    public partial class FrmDateCalculator : Form
    {
        public FrmDateCalculator()
        {
            InitializeComponent();
        }

        private void btnIncrease_Click(object sender, EventArgs e)
        {
            txtResult.Text = dtpDate.Value.AddDays((double)nddDays.Value).ToShortDateString();
        }

        private void btnDecrease_Click(object sender, EventArgs e)
        {
            txtResult.Text = dtpDate.Value.AddDays(-(double)nddDays.Value).ToShortDateString();
        }

        private void btnTryFeb_Click(object sender, EventArgs e)
        {
            DateTime dtm = new DateTime(DateTime.Today.Year, 2, 30);
            txtResult.Text = dtm.ToShortDateString();
        }

        private void btnGetPrevMonday_Click(object sender, EventArgs e)
        {
            DateTime dtmStart = DateTime.Today;
            DateTime dtmValue = dtpDate.Value;
            int intDayOfWeek = Convert.ToInt32(dtmValue.DayOfWeek);

            if (intDayOfWeek == 0)
            {
                dtmValue = dtmValue.AddDays(-1);
                intDayOfWeek = 6;
            }
            dtmStart = dtmValue.AddDays(-((intDayOfWeek+6)-7));
            
            DateTime dtmEnd = dtmStart.AddDays(6);
            MessageBox.Show(dtmStart.ToString("dd/MM/yyyy") + " - " + dtmEnd.ToString("dd/MM/yyyy"));
        }

        private void btnMinValue_Click(object sender, EventArgs e)
        {
            DateTime dtm1 = DateTime.MinValue;
            DateTime dtm2 = new DateTime(1900, 1, 1);
            bool blnEqual = dtm1 == dtm2;
            MessageBox.Show(dtm1.ToString("dd/MM/yyyy") + " == " + dtm2.ToString("dd/MM/yyyy") + " -> " + blnEqual.ToString());
        }
    }
    
}
As you can see, this form already using "partial" keyword. With "partial", the definition of a class, struct or interface can be splitted into multiple files.

Saturday, August 12, 2006

CVS and His Tortoise

So far, for source code repository or simply called "source control", I only using Visual Sourcesafe. My new employer is not only using Microsoft Technologies, in fact our main product is written in Borland Delphi. How we manage the source code? If you guess that we copy to another folder, backup it or zip-it, you guess it correctly. Now, this is not KISS (Keep it simple, stupid) anymore, this is really-really-really stupid. We are in urgency to look for a source control. And we stumbled upon CVS and it's Windows client; Tortoise CVS.
If you're a Windows user using CVS, and you're currently not using Tortoise CVS, I suggest you better to look into it. It integrates nicely with your Windows Explorer, ease your job significantly. Currently they are in a 1.9.x release, but I'm using the 1.8.x version (as in x.y.z, if y is an even number, it's considered stable release). Check their website for more information (and download)

Monday, June 26, 2006

New Job, New Country...

I'm hired for a job as a System Analyst in a software house in Singapore. The company is specialized in HR solutions. It's a new job, new country, new life. Hopefully I can adapt quickly (new home, new environment, different food), new colleagues, new TV Channels :D

Update (1/7/2006): The company, Timesoftware Pte Ltd currently has 5 developers (included me). My boss, Mr Raymond. Then Siong, Seng, and Vanessa. All of them are Malaysian. The shocking news: they are using Delphi, and (worse) Delphi CGI. We are in the progress to build new ASP.NET product

Sunday, October 2, 2005

Oh, Glassfish

When peoples declared that mainstream Java application server is Tomcat, honestly I can say that until now, I never use this cat. App server installed in my PC is Resin from Caucho. Previously I also use Websphere from IBM, now uninstalled to free some space in my HD. Resin is my testing server (or learning server) I used when learning Java, Servlet and JSP during my university time (and now). But now, I am interested in Sun application server. Why? Because, it’s the first commercial Java EE application server that change its license from proprietary-commercial to an Open Source license.

Sun change the license of its application server and release it as GlassFish Project Long live Sun!

Now, excuse me, I need to download and play with this aquarium…


Edited: Add picture

Monday, June 27, 2005

A Poem of Purpose Driven Life

In a book titled "Purpose Driven Life", Rick Warren included a Russel Kelfer's poem like below:

You are who you are for a reason
You're part of an intricate plan
You're a precious and perfect unique design,
Called God's special woman or man

You look like you look for a reason
Our God made no mistake
He knit you together within the womb
You're just what he wanted to make

The parents you had were the ones he chose,
And no matter how you may feel,
They were custom-designed with God's plan in mind,
And they bear the Master's seal

No, that trauma you faced was not easy
And God wept that it hurt you so;
But it was allowed to shape your heart
So that into his likeness you'd grow

You are who you are for a reason,
You've been formed by the Master's rod
You are who you are, beloved,
Because there is a GOD!

Then, I'll translated it into Indonesian:
Kau ada sebagaimana kau ada karena suatu alasan
Kau adalah bagian dari suatu rencana yang rumit
Kau adalah suatu rancangan unik yang berharga dan sempurna
Disebut pria atau wanita khusus kepunyaan Allah

Kau terlihat seperti kau sekarang karena suatu alasan
Allah kita tidak pernah membuat kesalahan
Dia merajutmu menyatu dalam kandungan
Kau tepat seperti apa yang ingin Dia ciptakan

Orang tua yang kau miliki adalah pilihanNya,
Dan tidak peduli bagaimana perasaanmu,
Mereka secara khusus dibuat dengan pertimbangan rencana Allah
Dan mereka memikul meterai Tuhan

Tidak, trauma yang kau hadapi tidaklah mudah
Dan Allah menangis atas semua yang begitu menyakitimu
Tapi hal itu ditujukan untuk membentuk hatimu
Supaya kau bertumbuh menjadi serupa denganNya

Kau ada sebagaimana kau ada karena suatu alasan,
Kau telah dibentuk dengan tongkat Tuhan
Kau adalah kau sekarang, saudara kekasih,
Karena ada Allah!

Friday, June 3, 2005

Excel Report with Aspose.Excel

Another way to get reports done beside using Crystal Reports Disclaimer: I'm not putting all my codes here, such as querying database and return the result as DataSet

The engine: ExcelReport.cs
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Aspose.Excel;

namespace Dallanube.HumanCapital.Report
{
 /// 
 /// Summary description for ExcelReport.
 /// 
 public class ExcelReport
 {
  public Excel CreateExcel(String fileName)
  {
   String strDir=Directory.GetParent(Application.ExecutablePath).ToString();
   /// If you have purchased a License, set license like this: 
   String strLicense =  strDir + "\\Aspose.Excel.lic";    
   Excel.SetLicense(strLicense);

   Excel objExcel = new Excel();
   
   string strDesignerFile = strDir + "\\" + fileName + ".xls";
   objExcel.Open(strDesignerFile);
   
   SetStyles(objExcel);
   return objExcel;
  }

  public void SaveExcel(Excel excel)
  {
   using (SaveFileDialog objFile = new SaveFileDialog())
   {
    objFile.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
    objFile.DefaultExt = "xls";

    if (objFile.ShowDialog() == DialogResult.OK)
    {
     try
     {
      excel.Save(objFile.FileName, FileFormatType.Default);
      ProcessStartInfo psi = new ProcessStartInfo(objFile.FileName); 
      Process.Start(psi); 
     }
     catch(Exception ex)
     {
      MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
    }
   }
  }

  private void SetStyles(Excel excel)
  {
   int intStyleIndex = excel.Styles.Add();
   Style objStyle = excel.Styles[intStyleIndex];
   objStyle.Font.IsBold = true;
   objStyle.Font.Size = 10;
   objStyle.HorizontalAlignment = TextAlignmentType.Left;
   objStyle.Name = "Bold";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Font.IsBold = true;
   objStyle.Font.Size = 10;
   objStyle.HorizontalAlignment = TextAlignmentType.Left;
   objStyle.ForegroundColor = Color.LightGray;
   objStyle.Name = "Header";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Font.IsBold = false;
   objStyle.Font.Size = 10;
   objStyle.HorizontalAlignment = TextAlignmentType.Right;
   objStyle.ForegroundColor = Color.LightGray;
   objStyle.Name = "Gray";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.TopBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.BottomBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "Box";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.TopBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.BottomBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "TopBottomLeftBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.TopBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.BottomBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "TopBottomRightBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.TopBorder].LineStyle=CellBorderType.Thin;
   objStyle.HorizontalAlignment = TextAlignmentType.Center;
   objStyle.Name = "TopLeftBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.BottomBorder].LineStyle=CellBorderType.Thin;
   objStyle.HorizontalAlignment = TextAlignmentType.Center;
   objStyle.Name = "BottomLeftBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.TopBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "TopRightBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.BottomBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "BottomRightBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.TopBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "TopBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.TopBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.BottomBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "TopBottomBorder";

   intStyleIndex = excel.Styles.Add();
   objStyle = excel.Styles[intStyleIndex];
   objStyle.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
   objStyle.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;
   objStyle.Name = "LeftRightBorder";
  }
 }
}


One example: FrmRepPayPerMonth.cs (yeah, it's a windows form)
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

using Aspose.Excel;
using Dallanube.HumanCapital.Impl;

namespace Dallanube.HumanCapital.Report
{
 public class FrmRepPayPerMonth : Dallanube.HumanCapital.Report.FrmBasePerMonth
 {
  private System.ComponentModel.IContainer components = null;

  public FrmRepPayPerMonth()
  {
   // This call is required by the Windows Form Designer.
   InitializeComponent();

   // TODO: Add any initialization after the InitializeComponent call
  }

  /// 
  /// Clean up any resources being used.
  /// 
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null) 
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Designer generated code
  /// 
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// 
  private void InitializeComponent()
  {
   // 
   // FrmRepPayPerMonth
   // 
   this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
   this.ClientSize = new System.Drawing.Size(342, 143);
   this.Name = "FrmRepPayPerMonth";
   this.Load += new System.EventHandler(this.FrmRepPayPerMonth_Load);

  }
  #endregion

  private void FrmRepPayPerMonth_Load(object sender, System.EventArgs e)
  {
   if (!DesignMode)
   {
    this.Text   = GetString("rep.paypermonth");
   }
  }

  private void CreateReport(byte bytMonth, int intYear, ReportParameter parameter)
  {
   ushort intCurrentRow = parameter.FirstRow;
   byte intCurrentColumn = 0;
   
   String strName, strDept;
   DateTime dtmJoined;
   int intJobStatus;
   double dblSalary, dblAllowance, dblOtherAllowance;
   //double dblTotal;
   //double dblSumSalary=0;
   //double dblSumAllowance=0;
   //double dblSumOtherAllowance=0;
   //double dblSumTotal=0;

   String strCellSalaryStart="", strCellSalaryEnd="";
   String strCellOtherAllowanceStart="", strCellOtherAllowanceEnd="";
   String strCellAllowanceStart="", strCellAllowanceEnd="";
   String strCellTotalStart="", strCellTotalEnd="";

   Worksheet objSheet = parameter.ExcelFile.Worksheets["Sheet1"];
   objSheet.Name = parameter.ReportName;
   Cells objCells = objSheet.Cells;

   // set Month/Year
   DateTime dtmPeriod=new DateTime(intYear, bytMonth, 1);
   String strPeriod="PER: " + dtmPeriod.ToString("MMMM yyyy").ToUpper();

   Style objStyleBold = parameter.ExcelFile.Styles["Bold"];
   objCells[intCurrentRow-4, intCurrentColumn].Style=objStyleBold;
   objCells[intCurrentRow-4, intCurrentColumn].PutValue(strPeriod);
   //

   for(int i = 0; i < parameter.Table.Rows.Count; i ++)
   {
    strName    = parameter.Table.Rows[i]["realName"].ToString();
    strDept    = parameter.Table.Rows[i]["deptName"].ToString();
    dtmJoined   = Convert.ToDateTime(parameter.Table.Rows[i]["startDate"]);
    intJobStatus  = Convert.ToInt32(parameter.Table.Rows[i]["jobStatus"]);
    if (intJobStatus==1)
     dblSalary  = Convert.ToDouble(parameter.Table.Rows[i]["salary"]);
    else
     dblSalary  = Convert.ToDouble(parameter.Table.Rows[i]["dailyWages"]);
    dblOtherAllowance = Convert.ToDouble(parameter.Table.Rows[i]["otherAllowance"]);
    dblAllowance  = Convert.ToDouble(parameter.Table.Rows[i]["allowance"]);
    //dblTotal   = dblSalary + dblAllowance + dblOtherAllowance;
    
    //dblSumSalary+= dblSalary;
    //dblSumOtherAllowance+= dblOtherAllowance;
    //dblSumAllowance+= dblAllowance;
    //dblSumTotal += dblTotal;

    objCells[intCurrentRow, intCurrentColumn].PutValue(i+1);
    objCells[intCurrentRow, intCurrentColumn].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, intCurrentColumn].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;

    objCells[intCurrentRow, (byte)(intCurrentColumn + 1)].PutValue(strName);
    objCells[intCurrentRow, (byte)(intCurrentColumn + 1)].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, (byte)(intCurrentColumn + 1)].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;

    objCells[intCurrentRow, (byte)(intCurrentColumn + 2)].PutValue(strDept);
    objCells[intCurrentRow, (byte)(intCurrentColumn + 2)].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, (byte)(intCurrentColumn + 2)].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;

    objCells[intCurrentRow, (byte)(intCurrentColumn + 3)].PutValue(dtmJoined);
    objCells[intCurrentRow, (byte)(intCurrentColumn + 3)].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, (byte)(intCurrentColumn + 3)].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;

    if (i==0)
    {
     strCellSalaryStart=objCells[intCurrentRow, (byte)(intCurrentColumn + 4)].Name;
     strCellOtherAllowanceStart=objCells[intCurrentRow, (byte)(intCurrentColumn + 5)].Name;
     strCellAllowanceStart=objCells[intCurrentRow, (byte)(intCurrentColumn + 6)].Name;
    }
    if (i==(parameter.Table.Rows.Count-1))
    {
     strCellSalaryEnd=objCells[intCurrentRow, (byte)(intCurrentColumn + 4)].Name;
     strCellOtherAllowanceEnd=objCells[intCurrentRow, (byte)(intCurrentColumn + 5)].Name;
     strCellAllowanceEnd=objCells[intCurrentRow, (byte)(intCurrentColumn + 6)].Name;
    }

    objCells[intCurrentRow, (byte)(intCurrentColumn + 4)].PutValue(dblSalary);
    objCells[intCurrentRow, (byte)(intCurrentColumn + 4)].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, (byte)(intCurrentColumn + 4)].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;
    strCellTotalStart = objCells[intCurrentRow, (byte)(intCurrentColumn + 4)].Name;
    
    if (dblOtherAllowance>0)
     objCells[intCurrentRow, (byte)(intCurrentColumn + 5)].PutValue(dblOtherAllowance);
    objCells[intCurrentRow, (byte)(intCurrentColumn + 5)].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, (byte)(intCurrentColumn + 5)].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;

    objCells[intCurrentRow, (byte)(intCurrentColumn + 6)].PutValue(dblAllowance);
    objCells[intCurrentRow, (byte)(intCurrentColumn + 6)].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, (byte)(intCurrentColumn + 6)].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;
    strCellTotalEnd = objCells[intCurrentRow, (byte)(intCurrentColumn + 6)].Name;

    //objCells[intCurrentRow, (byte)(intCurrentColumn + 7)].PutValue(dblTotal);
    objCells[intCurrentRow, (byte)(intCurrentColumn + 7)].Formula="=SUM("+ strCellTotalStart +":" + strCellTotalEnd +")";
    objCells[intCurrentRow, (byte)(intCurrentColumn + 7)].Style.Borders[BorderType.LeftBorder].LineStyle=CellBorderType.Thin;
    objCells[intCurrentRow, (byte)(intCurrentColumn + 7)].Style.Borders[BorderType.RightBorder].LineStyle=CellBorderType.Thin;

    intCurrentRow++;
   }

   Style objStyle = parameter.ExcelFile.Styles["TopBottomLeftBorder"];
   objCells[intCurrentRow, intCurrentColumn].Style = objStyle;
   
   objStyle = parameter.ExcelFile.Styles["TopBottomBorder"];
   Range objRange = objCells.CreateRange(intCurrentRow, 1, 1, 3);
   objRange.Style = objStyle;
   objCells[intCurrentRow, (byte)(intCurrentColumn+1)].PutValue("Total");
   
   objStyle = parameter.ExcelFile.Styles["Box"];
   objStyle.Custom="#,##0";
   //objCells[intCurrentRow, (byte)(intCurrentColumn+4)].PutValue(dblSumSalary);
   objCells[intCurrentRow, (byte)(intCurrentColumn+4)].Formula="=SUM("+ strCellSalaryStart +":" + strCellSalaryEnd +")";
   objCells[intCurrentRow, (byte)(intCurrentColumn+4)].Style = objStyle;
   strCellTotalStart = objCells[intCurrentRow, (byte)(intCurrentColumn+4)].Name;

   //objCells[intCurrentRow, (byte)(intCurrentColumn+5)].PutValue(dblSumOtherAllowance);
   objCells[intCurrentRow, (byte)(intCurrentColumn+5)].Formula="=SUM("+ strCellOtherAllowanceStart +":" + strCellOtherAllowanceEnd +")";
   objCells[intCurrentRow, (byte)(intCurrentColumn+5)].Style = objStyle;

   //objCells[intCurrentRow, (byte)(intCurrentColumn+6)].PutValue(dblSumAllowance);
   objCells[intCurrentRow, (byte)(intCurrentColumn+6)].Formula="=SUM("+ strCellAllowanceStart +":" + strCellAllowanceEnd +")";
   objCells[intCurrentRow, (byte)(intCurrentColumn+6)].Style = objStyle;
   strCellTotalEnd = objCells[intCurrentRow, (byte)(intCurrentColumn+6)].Name;

   //objCells[intCurrentRow, (byte)(intCurrentColumn+7)].PutValue(dblSumTotal);
   objCells[intCurrentRow, (byte)(intCurrentColumn+7)].Formula="=SUM("+ strCellTotalStart +":" + strCellTotalEnd +")";
   objCells[intCurrentRow, (byte)(intCurrentColumn+7)].Style = objStyle;
  }

  protected override void Print()
  {
   ExcelReport objReport = new ExcelReport();
   int intYear    = Convert.ToInt32(txtYear.Text);
   byte bytMonth   = Convert.ToByte(cboMonth.SelectedValue);
   DataSet ds    = Global.ReportProxy.CreateReportPayPerMonth(bytMonth, intYear);
    
   ReportParameter objParam= new ReportParameter();
   objParam.ExcelFile  = objReport.CreateExcel("RptDallanube01");
   objParam.Table   = ds.Tables[0];
   objParam.ReportName  = GetString("rep.paypermonth");
   objParam.FirstRow  = 7;

   CreateReport(bytMonth, intYear, objParam);
   for(int i = 0; i < objParam.ExcelFile.Worksheets.Count ; i ++)
   {
    Worksheet objSheet = objParam.ExcelFile.Worksheets[i];
    if(objSheet.Name != objParam.ReportName)
    {
     objParam.ExcelFile.Worksheets.RemoveAt(i);
     i --;
    }
   }

   objReport.SaveExcel(objParam.ExcelFile);
   objReport=null;
  }
 }
}

And ReportParameter.cs
using System;
using System.Data;
using Aspose.Excel;

namespace Dallanube.HumanCapital.Report
{
 /// 
 /// Summary description for ReportParameter.
 /// 
 public class ReportParameter
 {
  private Excel m_objExcelFile;
  private DataTable m_dtbTable;
  //private String m_strSourceSheet;
  private String m_strReportName;
  private ushort m_ushFirstRow;

  public Excel ExcelFile
  {
   get
   {
    return m_objExcelFile;
   }
   set
   {
    m_objExcelFile = value;
   }
  }
  public DataTable Table
  {
   get
   {
    return m_dtbTable;
   }
   set
   {
    m_dtbTable = value;
   }
  }
//  public String SourceSheet
//  {
//   get
//   {
//    return m_strSourceSheet;
//   }
//   set
//   {
//    m_strSourceSheet = value;
//   }
//  }
  public String ReportName
  {
   get
   {
    return m_strReportName;
   }
   set
   {
    m_strReportName = value;
   }
  }
  public ushort FirstRow
  {
   get
   {
    return m_ushFirstRow;
   }
   set
   {
    m_ushFirstRow = value;
   }
  }
 }
}
And for sure Aspose.Excel.dll is needed :D

Edited, reason: formatting codes

Saturday, April 23, 2005

PropertyGenerator

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace PropertyGenerator
{
 /// <summary>
 /// Summary description for Form1.
 /// </summary>
 public class FrmMain : System.Windows.Forms.Form
 {
  private System.Windows.Forms.TextBox txtSource;
  private System.Windows.Forms.Button btnGenerate;
  private System.Windows.Forms.TextBox txtResult;
  private System.Windows.Forms.TextBox txtMember;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.Windows.Forms.Label label3;
  private System.Windows.Forms.Label label4;
  private System.Windows.Forms.ComboBox cboLanguageFrom;
  private System.Windows.Forms.TextBox txtStartingCharPos;
  private System.Windows.Forms.Label label5;
  private System.Windows.Forms.ComboBox cboLanguageTo;
  private System.Windows.Forms.CheckBox cbxProperty;
  private System.Windows.Forms.CheckBox chkCreateRegion;
                private CheckBox chkEquals;
  /// <summary>
  /// Required designer variable.
  /// </summary>
  private System.ComponentModel.Container components = null;

  public FrmMain()
  {
   //
   // Required for Windows Form Designer support
   //
   InitializeComponent();

   //
   // TODO: Add any constructor code after InitializeComponent call
   //
  }

  /// <summary>
  /// Clean up any resources being used.
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null) 
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows Form Designer generated code
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {
   this.txtResult = new System.Windows.Forms.TextBox();
   this.txtSource = new System.Windows.Forms.TextBox();
   this.btnGenerate = new System.Windows.Forms.Button();
   this.txtMember = new System.Windows.Forms.TextBox();
   this.label1 = new System.Windows.Forms.Label();
   this.label2 = new System.Windows.Forms.Label();
   this.label3 = new System.Windows.Forms.Label();
   this.cboLanguageFrom = new System.Windows.Forms.ComboBox();
   this.label4 = new System.Windows.Forms.Label();
   this.txtStartingCharPos = new System.Windows.Forms.TextBox();
   this.label5 = new System.Windows.Forms.Label();
   this.cboLanguageTo = new System.Windows.Forms.ComboBox();
   this.cbxProperty = new System.Windows.Forms.CheckBox();
   this.chkCreateRegion = new System.Windows.Forms.CheckBox();
   this.chkEquals = new System.Windows.Forms.CheckBox();
   this.SuspendLayout();
   // 
   // txtResult
   // 
   this.txtResult.Location = new System.Drawing.Point(301, 0);
   this.txtResult.Multiline = true;
   this.txtResult.Name = "txtResult";
   this.txtResult.Size = new System.Drawing.Size(300, 300);
   this.txtResult.TabIndex = 1;
   // 
   // txtSource
   // 
   this.txtSource.Location = new System.Drawing.Point(-1, 0);
   this.txtSource.Multiline = true;
   this.txtSource.Name = "txtSource";
   this.txtSource.Size = new System.Drawing.Size(300, 300);
   this.txtSource.TabIndex = 0;
   // 
   // btnGenerate
   // 
   this.btnGenerate.Location = new System.Drawing.Point(510, 341);
   this.btnGenerate.Name = "btnGenerate";
   this.btnGenerate.Size = new System.Drawing.Size(75, 23);
   this.btnGenerate.TabIndex = 2;
   this.btnGenerate.Text = "Generate";
   this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click);
   // 
   // txtMember
   // 
   this.txtMember.Location = new System.Drawing.Point(72, 344);
   this.txtMember.Name = "txtMember";
   this.txtMember.Size = new System.Drawing.Size(136, 20);
   this.txtMember.TabIndex = 3;
   // 
   // label1
   // 
   this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.label1.Location = new System.Drawing.Point(8, 347);
   this.label1.Name = "label1";
   this.label1.Size = new System.Drawing.Size(64, 23);
   this.label1.TabIndex = 4;
   this.label1.Text = "Member";
   // 
   // label2
   // 
   this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.label2.Location = new System.Drawing.Point(216, 347);
   this.label2.Name = "label2";
   this.label2.Size = new System.Drawing.Size(120, 23);
   this.label2.TabIndex = 5;
   this.label2.Text = "dont forget . (Dot)";
   // 
   // label3
   // 
   this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.label3.Location = new System.Drawing.Point(8, 318);
   this.label3.Name = "label3";
   this.label3.Size = new System.Drawing.Size(64, 23);
   this.label3.TabIndex = 6;
   this.label3.Text = "Language";
   // 
   // cboLanguageFrom
   // 
   this.cboLanguageFrom.Items.AddRange(new object[] {
   "VB.NET",
   "C#",
   "Java"});
   this.cboLanguageFrom.Location = new System.Drawing.Point(72, 318);
   this.cboLanguageFrom.Name = "cboLanguageFrom";
   this.cboLanguageFrom.Size = new System.Drawing.Size(136, 21);
   this.cboLanguageFrom.TabIndex = 7;
   // 
   // label4
   // 
   this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.label4.Location = new System.Drawing.Point(347, 347);
   this.label4.Name = "label4";
   this.label4.Size = new System.Drawing.Size(118, 23);
   this.label4.TabIndex = 8;
   this.label4.Text = "Starting char position";
   // 
   // txtStartingCharPos
   // 
   this.txtStartingCharPos.Location = new System.Drawing.Point(472, 344);
   this.txtStartingCharPos.Name = "txtStartingCharPos";
   this.txtStartingCharPos.Size = new System.Drawing.Size(32, 20);
   this.txtStartingCharPos.TabIndex = 9;
   this.txtStartingCharPos.Text = "0";
   // 
   // label5
   // 
   this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.label5.Location = new System.Drawing.Point(219, 318);
   this.label5.Name = "label5";
   this.label5.Size = new System.Drawing.Size(32, 23);
   this.label5.TabIndex = 10;
   this.label5.Text = "To";
   // 
   // cboLanguageTo
   // 
   this.cboLanguageTo.Items.AddRange(new object[] {
   "VB.NET",
   "C#",
   "Java"});
   this.cboLanguageTo.Location = new System.Drawing.Point(251, 318);
   this.cboLanguageTo.Name = "cboLanguageTo";
   this.cboLanguageTo.Size = new System.Drawing.Size(136, 21);
   this.cboLanguageTo.TabIndex = 11;
   // 
   // cbxProperty
   // 
   this.cbxProperty.Checked = true;
   this.cbxProperty.CheckState = System.Windows.Forms.CheckState.Checked;
   this.cbxProperty.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.cbxProperty.Location = new System.Drawing.Point(408, 304);
   this.cbxProperty.Name = "cbxProperty";
   this.cbxProperty.Size = new System.Drawing.Size(104, 24);
   this.cbxProperty.TabIndex = 12;
   this.cbxProperty.Text = "Property";
   // 
   // chkCreateRegion
   // 
   this.chkCreateRegion.Checked = true;
   this.chkCreateRegion.CheckState = System.Windows.Forms.CheckState.Checked;
   this.chkCreateRegion.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.chkCreateRegion.Location = new System.Drawing.Point(408, 322);
   this.chkCreateRegion.Name = "chkCreateRegion";
   this.chkCreateRegion.Size = new System.Drawing.Size(104, 24);
   this.chkCreateRegion.TabIndex = 13;
   this.chkCreateRegion.Text = "Create Region";
   // 
   // chkEquals
   // 
   this.chkEquals.Checked = true;
   this.chkEquals.CheckState = System.Windows.Forms.CheckState.Checked;
   this.chkEquals.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
   this.chkEquals.Location = new System.Drawing.Point(510, 306);
   this.chkEquals.Name = "chkEquals";
   this.chkEquals.Size = new System.Drawing.Size(73, 24);
   this.chkEquals.TabIndex = 14;
   this.chkEquals.Text = "Equals";
   // 
   // FrmMain
   // 
   this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
   this.ClientSize = new System.Drawing.Size(592, 373);
   this.Controls.Add(this.chkEquals);
   this.Controls.Add(this.txtStartingCharPos);
   this.Controls.Add(this.chkCreateRegion);
   this.Controls.Add(this.cbxProperty);
   this.Controls.Add(this.cboLanguageTo);
   this.Controls.Add(this.label5);
   this.Controls.Add(this.label4);
   this.Controls.Add(this.cboLanguageFrom);
   this.Controls.Add(this.label3);
   this.Controls.Add(this.label2);
   this.Controls.Add(this.label1);
   this.Controls.Add(this.txtMember);
   this.Controls.Add(this.btnGenerate);
   this.Controls.Add(this.txtResult);
   this.Controls.Add(this.txtSource);
   this.Name = "FrmMain";
   this.Text = "Generator";
   this.Load += new System.EventHandler(this.FrmMain_Load);
   this.ResumeLayout(false);
   this.PerformLayout();

  }
  #endregion

  /// <summary>
  /// The main entry point for the application.
  /// </summary>
  [STAThread]
  static void Main() 
  {
   Application.Run(new FrmMain());
  }

  private void btnGenerate_Click(object sender, System.EventArgs e)
  {
   int pos=Convert.ToInt32(txtStartingCharPos.Text.Trim());
   String[] sCodes;
   
   sCodes = txtSource.Text.Split('\n');
   String sResult="";
            String sEquals = "";
   foreach (String sCode in sCodes)
   {
    String[] sToken;
    sToken=sCode.Trim().Split(' ');
    switch (cboLanguageFrom.SelectedIndex)
    {
     case 0:
      if (cbxProperty.Checked)
      {
       switch (cboLanguageTo.SelectedIndex)
       {
        case 0: sResult+=
           "Public Property "+ sToken[1].Substring(pos) + "() As " + sToken[3] + "\n"+
           " Get\n"+
           "  Return Me."+ txtMember.Text + sToken[1] +"\n"+
           " End Get\n"+
           " Set(ByVal Value As "+ sToken[3] + ")\n"+
           "  Me."+ txtMember.Text + sToken[1] + " = Value\n"+
           " End Set\n"+
           "End Property\n\n";
         break;
        case 1: sResult+=
           "public "+sToken[3]+" "+sToken[1].Substring(pos)+"\n"+
           "{\n"+
           " get\n"+
           " {\n"+
           "  return "+ txtMember.Text + sToken[1] +";\n"+
           " }\n"+
           " set\n"+
           " {\n"+
           "  "+ txtMember.Text + sToken[1]+ " = value;\n"+
           " }\n"+
           "}\n";
         break;
        case 2: sResult+=
           "public "+ sToken[3] +" get"+ sToken[1].Substring(pos) +"() {\n"+
           " return "+ txtMember.Text + sToken[1] +";\n"+
           "}\n"+
           "public void set"+ sToken[1].Substring(pos) +"("+ sToken[3] +" "+ sToken[1].ToLower()[2] + sToken[1].Substring(3)+") {\n"+
           " "+ txtMember.Text + sToken[1] +" = "+ sToken[1].ToLower()[pos] + sToken[1].Substring(pos+1) +";\n"+
           "}\n\n";
         break;
       }
      }
      else
      {
       switch (cboLanguageTo.SelectedIndex)
       {
        case 0: sResult+=
           "Public Property "+ sToken[1].Substring(pos) + "() As " + sToken[3] + "\n"+
           " Get\n"+
           "  Return Me."+ txtMember.Text + sToken[1] +"\n"+
           " End Get\n"+
           " Set(ByVal Value As "+ sToken[3] + ")\n"+
           "  Me."+ txtMember.Text + sToken[1] + " = Value\n"+
           " End Set\n"+
           "End Property\n\n";
         break;
        case 1: 
        case 2: sResult+=
           "protected "+sToken[3]+" "+sToken[1]+";\n";
         break;
          
       }
      }
      break;
     case 1: 
      if (cbxProperty.Checked || chkEquals.Checked)
      {
       switch (cboLanguageTo.SelectedIndex)
       {
        case 0: sResult+=
           "Public Property "+ sToken[1].Substring(pos) + "() As " + sToken[3] + "\n"+
           " Get\n"+
           "  Return Me."+ txtMember.Text + sToken[1] +"\n"+
           " End Get\n"+
           " Set(ByVal Value As "+ sToken[3] + ")\n"+
           "  Me."+ txtMember.Text + sToken[1] + " = Value\n"+
           " End Set\n"+
           "End Property\n\n";
         break;
        case 1:
                                    string sTemp = sToken[2].Substring(pos, sToken[2].Length - (pos + 1));
                                    string s1stChar = sTemp[0].ToString().ToUpper();
                                    sTemp = s1stChar + sTemp.Substring(1);
                                    sResult+=
                                            "public "+sToken[1]+" "+ sTemp +"\n"+
           "{\n"+
           " get\n"+
           " {\n"+
           "  return "+ txtMember.Text + sToken[2] +"\n"+
           " }\n"+
           " set\n"+
           " {\n"+
           "  "+ txtMember.Text + sToken[2].Substring(0,sToken[2].Length-1)+ " = value;\n"+
           " }\n"+
           "}\n";

                                    string sCheckMember = sToken[2].Replace(";", "");
                                    sEquals +=
                                        "if (" + sCheckMember + " == null ? item." + sCheckMember + "  != null : !" + sCheckMember + ".Equals(item." + sCheckMember + " ))\n" +
                                        "    return false;\n";

         break;
        case 2: sResult+=
           "public "+ sToken[1] +" get"+ sToken[2].Substring(pos, sToken[2].Length-(pos+1)) +"() {\n"+
           " return "+ txtMember.Text + sToken[2] +"\n"+
           "}\n"+
           "public void set"+ sToken[2].Substring(pos, sToken[2].Length-(pos+1)) +"("+ sToken[1] +" "+ sToken[2].ToLower()[3] + sToken[2].Substring(4, sToken[2].Length-5)+") {\n"+
           " "+ txtMember.Text + sToken[2].Substring(0, sToken[2].Length-1) +" = "+ sToken[2].ToLower()[3] + sToken[2].Substring(4, sToken[2].Length-5) +";\n"+
           "}\n\n";
         break;
       }
      }
      else
      {
       switch (cboLanguageTo.SelectedIndex)
       {
        case 0: sResult+=
           "Public Property "+ sToken[1].Substring(pos) + "() As " + sToken[3] + "\n"+
           " Get\n"+
           "  Return Me."+ txtMember.Text + sToken[1] +"\n"+
           " End Get\n"+
           " Set(ByVal Value As "+ sToken[3] + ")\n"+
           "  Me."+ txtMember.Text + sToken[1] + " = Value\n"+
           " End Set\n"+
           "End Property\n\n";
         break;
        case 1: 
        case 2: sResult+=
           "protected "+sToken[3]+" "+sToken[1]+";\n";
         break;
          
       }
      }
      break;
    }

   }
            if (!cbxProperty.Checked)
            {
                sResult = "";
            }
   if (chkCreateRegion.Checked)
   {
    switch(cboLanguageTo.SelectedIndex)
    {
     case 0:
     case 1:
      sResult= "#region C#-Style\n\n" + sResult +
       "\n#endregion C#-Style";
      break;
     case 2:
      sResult= "#region Java-Style\n\n" + sResult +
       "\n#endregion Java-Style";
      break;
    }
   }
            if (chkEquals.Checked)
            {
                sEquals =
                     "public Boolean Equals(Object item)\n" +
                     "{\n" +
                     "  if (this == item)\n" +
                     "  return true;\n" + sEquals +
                     "  return true;\n" +
                     "}\n";

                switch (cboLanguageTo.SelectedIndex)
                {
                    case 0:
                    case 1:
                        sResult = sResult + sEquals;
                        break;
                    case 2:
                        break;
                }
            }
   txtResult.Text=sResult;
  }

  private void FrmMain_Load(object sender, System.EventArgs e)
  {
   cboLanguageFrom.SelectedIndex=1;
   cboLanguageTo.SelectedIndex=1;
  }
 }
}

PS: There are free refactoring tools comes with VS 2005+, but not for VS 2002/2003, check http://msdn.microsoft.com/en-us/library/ms379618(v=vs.80).aspx

Monday, January 10, 2005