8
Answers

How to Store In Database This type Records In Windows C#

Jyoti Jodha

Jyoti Jodha

7y
237
1
How to Store In Database This type Records In Windows Application  C#
 
 

Sno

Product name

dec

QTY

Unit Price

Tax

Total-Amount

 

1

mobile

no

2

5000

10

11000

 

2

ABC

no

1

500

10

550

 
               
               

Gridview Records

Database save Records

sno

Product name

dec

QTY

Unit_Price

Tax

Total_Amount

Tax_Amount

Grand_Total_Amount

 

1

mobile

no

2

5000

10

10000

1000

11000

 

2

ABC

no

1

500

10

500

50

550

 

0

0

0

0

0

0

10500

1050

11550

 

private void addbutton_Click(object sender, EventArgs e)

{

if (producttxt.Text != "" && dectxt.Text != "" && qtytxtprice.Text != "" && txtqty.Text != "" && txttax.Text != "")

{

int Qty = Convert.ToInt32(txtqty.Text);

decimal Unit_Price = Convert.ToDecimal(qtytxtprice.Text);

decimal Tax = Convert.ToDecimal(txttax.Text);

decimal Amount = (Qty * Unit_Price);

decimal PercentageAmount = ((Amount * Tax) / 100);

decimal TotalAmount = Amount + PercentageAmount;

int Sno = dataGridView.Rows.Count ;

dataGridView.Rows.Add(Sno, producttxt.Text, dectxt.Text, txtqty.Text, qtytxtprice.Text, txttax.Text, TotalAmount);

btnclr_Click(sender, e);

CalculateTotalAmount();

ClearData();

}

}

public void CalculateTotalAmount()

{

decimal taxtotal=0;

decimal totalamount=0;

for(int i=0;i<dataGridView.Rows.Count-1;i++)

{

decimal TotalAmount = (Convert.ToDecimal(dataGridView.Rows[i].Cells[3].Value) * Convert.ToDecimal(dataGridView.Rows[i].Cells[4].Value));

taxtotal=taxtotal+((Convert.ToDecimal(dataGridView.Rows[i].Cells[5].Value)*TotalAmount)/100);

totalamount=totalamount+Convert.ToDecimal(dataGridView.Rows[i].Cells[6].Value);

}

TotalTaxtxt.Text=taxtotal.ToString(); //tax total amount text box field value setting

totalamounttxt.Text=totalamount.ToString(); //total amount text box field value setting

}

 

Attachment: databaseRecords.zip

Answers (8)