How to insert data into database based on textbox validations in angularjs?
If the textbox is empty and submit button is entered, the data must not be inserted, it also should throw an error message.
If the textbox contain some value and then submit button is pressed, the data should be inserted.
[HttpPost]
[ActionName("AddIssueDetails")]
public int insertIssueDetails(IssueDetails id)
{
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["ERPConnectionString"].ConnectionString;
SqlCommand sqlCmd = new SqlCommand();
DateTime now = DateTime.Now;
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "INSERT_WAREHOUSE_DETAILS";
sqlCmd.Connection = myConnection;
sqlCmd.Parameters.AddWithValue("@InvoiceId", id.InvoiceId);
sqlCmd.Parameters.AddWithValue("@IssueDate", now);
sqlCmd.Parameters.AddWithValue("@PackingListNo", id.PackingListNo);
sqlCmd.Parameters.AddWithValue("@DispatchId", id.DispatchId);
sqlCmd.Parameters.AddWithValue("@IssueQty", id.IssueQty);
sqlCmd.Parameters.AddWithValue("@CreatedBy", id.CreatedBy);
myConnection.Open();
int rowInserted = sqlCmd.ExecuteNonQuery();
myConnection.Close();
return 1;
}