private void SaveCdContentsToDb(CdDetail cdDetails, List <FileDetail> fileDetails) { string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); var conn = new SqlConnection(connString); conn.Open(); SqlCommand sqlCmd = new SqlCommand(CD_DETAILS_INSERT, conn); sqlCmd.Parameters.AddWithValue("@CdId", cdDetails.CdId); sqlCmd.Parameters.AddWithValue("@ScannedBy", cdDetails.ScannedBy); sqlCmd.Parameters.AddWithValue("@ScannedDate", cdDetails.ScannedDate); sqlCmd.Parameters.AddWithValue("@Notes", cdDetails.Notes); sqlCmd.ExecuteNonQuery(); sqlCmd = new SqlCommand(FILE_DETAILS_INSERT, conn); foreach (var file in fileDetails) { sqlCmd.Parameters.Clear(); sqlCmd.Parameters.AddWithValue("@CdId", cdDetails.CdId); sqlCmd.Parameters.AddWithValue("@FileName", file.Name); sqlCmd.Parameters.AddWithValue("@FullPath", file.FullPath); sqlCmd.Parameters.AddWithValue("@FileSize", file.Size); sqlCmd.Parameters.AddWithValue("@CreateDate", file.CreateDate); sqlCmd.ExecuteNonQuery(); } conn.Close(); }
private CdDetail GetCdDetails() { CdDetail result = new CdDetail(); result.ScannedBy = txtScannedBy.Text; result.CdId = txtCDId.Text; result.Notes = txtNotes.Text; return(result); }