Below is my code in which i am trying to insert decimal value to database but having error.
Arguement 3 Can not convert from Decimal to int
ResultValue += this.InsertRows(i_id, qty, rate);
DataTable dt = (DataTable)ViewState["dt"];
string codeitem, qty, ResultValue = 0;
decimal rate;
foreach (DataRow row in dt.Rows)
{
rate = decimal.Parse(row["I_Rate"].ToString());
qty = decimal.Parse(row["QTY"].ToString());
codeitem = int.Parse(row["I_ID"].ToString());
ResultValue += this.InsertRows(codeitem, qty, rate);
}
if (ResultValue == dt.Rows.Count)
{
// Response.Redirect("BalePack.aspx");
Response.Redirect("Packrpt.aspx?PID=" + lbid.Text + "");
}
else
{
Response.Write("<script>alert('Not Save'</script>");
}
}
}
private void InsertRows(string codeitem, string qty, string rate)
{
using (SqlCommand cmd = new SqlCommand("[SP_insert_Sales]", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "Detail");
cmd.Parameters.AddWithValue("@S_ID", lbid.Text);
cmd.Parameters.AddWithValue("@I_ID", codeitem);
cmd.Parameters.AddWithValue("@I_Rate", Decimal.Parse(rate));
cmd.Parameters.AddWithValue("@E_Date", DateTime.Now.ToString());
cmd.Parameters.AddWithValue("@E_Time", DateTime.Now.ToString("HH:mm:ss"));
con.Open();
int ResultValue = cmd.ExecuteNonQuery();
con.Close();
return ResultValue;
}
dt.Columns.Add("rate", typeof(decimal));
dt.Columns.Add("qty", typeof(string));
dt.Columns.Add("codeitem", typeof(string));
ViewState["dt"] = dt;