Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
v6.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrum committed Nov 14, 2019
1 parent ec2dced commit c905765
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 46 deletions.
17 changes: 3 additions & 14 deletions Extensions/csv/CSVAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using CsvHelper;
using System.IO;
using System.Linq;
using Extensions.Models;

namespace Extensions.CSV
{
public static class CSVAdapter
{
public static string ExMessage { get; set; }
public static void LoadFileToDb(string pathToFile, string ConnectionString, string countryCode, string clientId, string year, string setId, string setIndex)
{
List<SampleInfo> samples = null;
using (var reader = new StreamReader(pathToFile))
using (var csv = new CsvReader(reader))
{
//csv.Configuration.PrepareHeaderForMatch = (string header, int index) => header.ToLower();
csv.Configuration.ShouldSkipRecord = row => row[0].StartsWith("0");
csv.Configuration.ShouldSkipRecord = row => row.Length < 5;
csv.Configuration.Delimiter = "\t";
try
{
samples = new List<SampleInfo>(csv.GetRecords<SampleInfo>());

samples.ForEach(s => { s.F_Country_Code = countryCode; s.F_Client_Id = clientId; s.F_Year = year; s.F_Sample_Set_Id = setId; s.F_Sample_Set_Index = setIndex; s.A_Sample_ID = s.Number.ToString("d2"); });
Expand All @@ -29,13 +25,6 @@ public static void LoadFileToDb(string pathToFile, string ConnectionString, stri
ic.Samples.AddRange(samples);
ic.SaveChanges();
}


}
catch (Exception ex)
{
;
}
}

}
Expand Down
51 changes: 25 additions & 26 deletions Forms/Form_LLI_Irradiation_Log.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Imports Renci.SshNet
Imports System.IO


Public Class Form_LLI_Irradiation_Log

Public ContNum As Integer() = {1, 2, 3, 4, 5, 6, 7, 8, 9}
Expand Down Expand Up @@ -1360,31 +1359,31 @@ Public Class Form_LLI_Irradiation_Log
DataGridView_LLI_Irradiation_Log.Rows.RemoveAt(row.Index)
Next

Using sqlConnection1 As New SqlConnection(Form_Main.MyConnectionString)
sqlConnection1.Open()
Using cmd As New System.Data.SqlClient.SqlCommand($"DELETE FROM dbo.table_LLI_Irradiation_Log WHERE
Country_Code='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(0).Value}'
and Client_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(1).Value}'
and Year='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(2).Value}'
and Sample_Set_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(3).Value}'
and Sample_Set_Index='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(4).Value}'
and Sample_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(5).Value}'
and Date_Start=convert(datetime, '{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(6).Value}', 104);
UPDATE dbo.table_Sample SET I_LLI_Date_Start=NULL where
F_Country_Code='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(0).Value}' and
F_Client_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(1).Value}' and
F_Year='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(2).Value}' and
F_Sample_Set_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(3).Value}' and
F_Sample_Set_Index='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(4).Value}' and
A_Sample_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(5).Value}' and
I_LLI_Date_Start=convert(datetime, '{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(6).Value}', 104);",
sqlConnection1)
Debug.WriteLine($"Delete and update query is:{vbCrLf}{cmd.CommandText}")
cmd.ExecuteNonQuery()
End Using
sqlConnection1.Close()
End Using
'Using sqlConnection1 As New SqlConnection(Form_Main.MyConnectionString)
' sqlConnection1.Open()
' Using cmd As New System.Data.SqlClient.SqlCommand($"DELETE FROM dbo.table_LLI_Irradiation_Log WHERE
' Country_Code='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(0).Value}'
' and Client_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(1).Value}'
' and Year='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(2).Value}'
' and Sample_Set_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(3).Value}'
' and Sample_Set_Index='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(4).Value}'
' and Sample_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(5).Value}'

' and Date_Start=convert(datetime, '{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(6).Value}', 104);
' UPDATE dbo.table_Sample SET I_LLI_Date_Start=NULL where
' F_Country_Code='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(0).Value}' and
' F_Client_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(1).Value}' and
' F_Year='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(2).Value}' and
' F_Sample_Set_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(3).Value}' and
' F_Sample_Set_Index='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(4).Value}' and
' A_Sample_ID='{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(5).Value}' and
' I_LLI_Date_Start=convert(datetime, '{DataGridView_LLI_Irradiation_Log.SelectedCells.Item(6).Value}', 104);",
' sqlConnection1)
' Debug.WriteLine($"Delete and update query is:{vbCrLf}{cmd.CommandText}")
' cmd.ExecuteNonQuery()
' End Using
' sqlConnection1.Close()
'End Using
Save_And_Update_LLI_Click(sender, e)
Catch ex As Exception
If Form_Main.language = "Русский" Then
Expand Down
1 change: 0 additions & 1 deletion Forms/Form_SLI_Irradiation_Log.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,6 @@ Public Class Form_SLI_Irradiation_Log
End If

Dim sqlConnection1 As New SqlConnection(Form_Main.MyConnectionString)
'Dim reader As SqlDataReader
Dim cmd As New System.Data.SqlClient.SqlCommand
cmd.CommandType = System.Data.CommandType.Text

Expand Down
6 changes: 1 addition & 5 deletions Forms/Form_Samples_List.vb
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,7 @@ Public Class Form_Samples_List
Form_Main.B_Select_Sample_Set.PerformClick()

Catch ex As Exception
If Form_Main.language = "Русский" Then
MsgBox("Операция была отменена (ошибка в B_Insert_All_Samples_Into_Sample_Set_Click)!", MsgBoxStyle.Critical, Me.Text)
ElseIf Form_Main.language = "English" Then
MsgBox("The operation was cancelled (error in B_Insert_All_Samples_Into_Sample_Set_Click)!", MsgBoxStyle.Critical, Me.Text)
End If
MsgBox($"Операция была отменена. Ошибка при внесении данных в базу.{vbCrLf}{ex.ToString}", MsgBoxStyle.Critical, Me.Text)
Form_Sample_Accept.Close()
Exit Sub
End Try
Expand Down

0 comments on commit c905765

Please sign in to comment.