Sunday, 22 August 2010

how to use tags property in c#


//source code how to use tags property in c#
//try to devevlop the sme form it would be better
//it could also be used to develop cash system
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsProject
{
public partial class Form6 : Form
{
int count = 0;
public Form6()
{
InitializeComponent();
}
private void checkBox_CheckedChanged(object sender, EventArgs e)
{
int amt = int.Parse(txtAmount.Text);
CheckBox cb = sender as CheckBox;
if (cb.Checked)
{
count += 1;
amt += Convert.ToInt32(cb.Tag);
}
else
{
count -= 1;
amt -= Convert.ToInt32(cb.Tag);
}
txtAmount.Text = amt.ToString();
if (count == 0)
radioButton1.Checked = true;
}
private void radioButton_CheckedChanged(object sender, EventArgs e)
{
int amt = int.Parse(txtAmount.Text);
if (amt > 0)
{
RadioButton rb = sender as RadioButton;
if (rb.Checked)
amt += Convert.ToInt32(rb.Tag);
else
amt -= Convert.ToInt32(rb.Tag);
txtAmount.Text = amt.ToString();
}
else
radioButton1.Checked = true;
}
}
}