9/05/2013

Payment Form

C# Payment Form
Payment Form


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Billing
{
    public partial class frm_PrintBill : Form
    {
        public double balance=0,billamount=0,cashtendered=0;
        public frm_PrintBill()
        {
            InitializeComponent();
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        private void txt_CashTendered_KeyUp(object sender, KeyEventArgs e)
        {
            if(e.KeyCode==Keys.Enter)
            {
                if (txt_CashTendered.TextLength > 0)
                {
                    billamount = Convert.ToDouble(txt_Amount.Text);
                    cashtendered = Convert.ToDouble(txt_CashTendered.Text);
                    balance = cashtendered - billamount;
                    

                    txt_CashTendered.Text = string.Format("{0:0.00}", cashtendered);
                    txt_Balance.Text = string.Format("{0:0.00}", balance);
                    this.SelectNextControl(txt_CashTendered, true, true, true, true);
                }
                else
                {
                    return;
                }
               
            }
        }

        private void btn_Print_Click(object sender, EventArgs e)
        {
            if (txt_CashTendered.TextLength <= 0)
            {
                return;
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
    }
}

9/01/2013

Steps To Install Visual Basic PowerPack For Visual Studio 2013

If Visual Studio is running close it and click on Retry
Check "I agree to the License Terms and Privacy Policy" and click on INSTALL
Click on "Close" to finish the installation.
Open Visual Studio Windows Form Application and right click on toolbox and click on "Add Tab"


Download Visual Basic PowerPack

6/08/2013

C# - Hide the row selection arrow in DataGridView

C# Hide the row selection arrow in DataGridView
C# Hide the row selection arrow in DataGridView

 private void DataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)  
     {  
       //this.DataGridView.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex+1).ToString();   
     }  
     private void DataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)  
     {  
       if (e.ColumnIndex == -1 && e.RowIndex > -1)  
       {  
         e.PaintBackground(e.CellBounds, true);  
         using (SolidBrush br = new SolidBrush(Color.Black))  
         {  
           StringFormat sf = new StringFormat();  
           sf.Alignment = StringAlignment.Center;  
           sf.LineAlignment = StringAlignment.Center;  
           e.Graphics.DrawString((e.RowIndex+1).ToString(),  
             e.CellStyle.Font, br, e.CellBounds, sf);  
         }  
         e.Handled = true;  
       }  
     }  

3/07/2013

Compile Time Polymorphism / Overloading



In method overloading we can define many methods with the same name but different signatures. A method signature is the combination of the method's name along with the number, type and order of the parameters. When we call overloaded methods, a compiler automatically determines which method should be used to perform similar task but with different input parameters.

1/20/2013

Barcode design in C#

Barcode design in C#
Barcode design in C#

  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;
  using System.IO;
  using System.Drawing.Imaging;
  private void txt_Barcode_TextChanged(object sender, EventArgs e)  
     {  
       if (txt_Barcode.TextLength > 0)  
       {  
         Barcodepreview(txt_Barcode.Text.ToString());  
       }  
       else  
       {  
         pic_Barcodepreview.Image = null;  
       }  
     }  
     private void Barcodepreview(string barcodeno)  
     {  
       string barcode = barcodeno;  
       Bitmap bmp = new Bitmap(450, 450);  
       using (Graphics g = Graphics.FromImage(bmp))  
       {  
         Font f = new System.Drawing.Font("IDAutomationHC39M", 14);  
         PointF point = new PointF(2f, 2f);  
         SolidBrush black = new SolidBrush(Color.Black);  
         SolidBrush white = new SolidBrush(Color.White);  
         g.FillRectangle(white, 0, 0, bmp.Width, bmp.Height);  
         g.DrawString(barccode.ToString(), f, black, point);  
       }  
       using (MemoryStream ms = new MemoryStream())  
       {  
         pic_Barcodepreview.Image = bmp;  
         pic_Barcodepreview.Height = bmp.Height;  
         pic_Barcodepreview.Width = bmp.Width;  
       }  
     }  

Download Font