sorry im bad at coding but i need this,
well..
in my table called
Products
got 2 column there is
Product and
Price
in
Price column contains a decimal value
1000
can i get that value(1000) to be a variable so i can use it into arithmetic function?
and it seems to connect the database to my form is incorrect as well,
pls modify all my source! and what i need to add! thanks
I would appreciate any help!
What I have tried:
This's the DataAccessLayer
DataAccess.cs
namespace CS_Sistem_Managemen_Restoran
{
class DataAccess
{
public SqlConnection con;
public void Connection(string spName = null)
{
string strConnect = "Server=PC\\SQLEXPRESS;Database=MyLoginApp;Trusted_Connection=True;";
SqlConnection conn = new SqlConnection();
SqlConnection dt = new SqlConnection();
try
{
conn = new SqlConnection(strConnect);
conn.Open();
SqlCommand cmd = new SqlCommand(spName, conn);
SqlCommand command = conn.CreateCommand();
SqlDataReader dr = cmd.ExecuteReader();
}
catch (Exception ex)
{
throw ex;
}
}
}
}
Form1.cs BtnHitung
private void btnHitung_Click(object sender, EventArgs e)
{
DataAccess conss = new DataAccess();
conss.Connection();
DataTable dt = new DataTable("Products");
Double BasoSUCost = Convert.ToInt32(dt.Rows[1]["price"].ToString());
Double ItemBasoSU;
Double TotalBasoSU;
if (int.TryParse(txtBasoSU.Text, out NumberofOrder))
{
ItemBasoSU = Double.Parse(txtBasoSU.Text);
TotalBasoSU = BasoSUCost * ItemBasoSU;
txtTotal.Text = String.Format("Rp. {0:N} ", TotalBasoSU);
}
}