با تشکر این کد ثبت و محاسبه هست. البته من یکسری تغییرات هم دادم ولی مشکل حل نشد.
SqlCommand com1 = new SqlCommand("insert into faktor (code,name,codekala,namkala,tedadkala,gheymatkala, gheymatkol,sum,date)"
+ " values ('" + Convert.ToInt32(textBox1.Text) + "' , '" + textBox2.Text + "' , '" + Convert.ToInt32(textBox3.Text) + "' ,"
+ " '" + textBox4.Text + "' , '" + Convert.ToInt32(textBox5.Text) + "', '" + Convert.ToInt32(textBox6.Text) + "',"
+ " '" + Convert.ToInt32(textBox14.Text) + "','" + textBox13.Text + "','" + textBox7.Text + "') ", con);
com1.Connection.Open();
com1.ExecuteNonQuery();
com1.Connection.Close();
MessageBox.Show("اطلاعات ثبت شد");
SqlDataAdapter sda = new SqlDataAdapter("select codekala 'کد كالا',namkala 'نام',tedadkala 'تعداد ',gheymatkala ' قیمت کالا' ,"
+ " gheymatkol'قیمت کل ',sum'جمع فاکتور' from faktor where code='" + Convert.ToInt32(textBox1.Text) + "' and date='" + textBox7.Text + "' ", con);
ds.Clear();
sda.Fill(ds, "faktor");
int sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[4].Value);
}
textBox8.Text = sum.ToString();
double div;
div = 0.05;
textBox13.Text = Convert.ToString((Convert.ToInt32(textBox8.Text) - (Convert.ToInt32(textBox8.Text) * div)));
}