} // Fix types string public void OfflineTransfer(string Char) { try { dbase.OpenslConnection(); dbase.slQueryText = "SELECT Barcode, Qty FROM prCount WHERE CountName = '" + comboBoxCounts.Text.ToString() + "'"; dbase.slCommand = new SQLiteCommand(dbase.slQueryText, dbase.slConnection); dbase.slDataReader = dbase.slCommand.ExecuteReader(); List <string> TransferList = new List <string>(); while (dbase.slDataReader.Read()) { TransferList.Add(dbase.slDataReader["Barcode"].ToString() + FixSpecialCharacter(Char) + dbase.slDataReader["Qty"].ToString()); } dbase.CloseslConnection(); WriteTextFile.RW(TransferList, comboBoxCounts.Text.ToString()); MessageBox.Show(comboBoxCounts.Text.ToString() + " isimli dosya aktarıldı.", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Aktarım sırasında hata ile karşılarışdı" + Environment.NewLine + ex, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } // Offline transfer operations
} // Offline transfer operations public void OnlineTransfer() { dbase.OpenslConnection(); dbase.slQueryText = "SELECT Barcode, Qty FROM prCount WHERE CountName = '" + comboBoxCounts.Text.ToString() + "'"; dbase.slCommand = new SQLiteCommand(dbase.slQueryText, dbase.slConnection); dbase.slDataReader = dbase.slCommand.ExecuteReader(); dbase.OpenmsConnection(); dbase.msQueryText = "SELECT Barcode,ItemCode,ColorCode,ItemDim1Code,ItemDim2Code,ItemDim3Code FROM prItemBarcode WHERE Barcode = @Barcode"; dbase.msCommand = new SqlCommand(dbase.msQueryText, dbase.msConnection); dbase.msCommand.Parameters.Add("@Barcode", SqlDbType.VarChar); while (dbase.slDataReader.Read()) { dbase.msCommand.Parameters["@Barcode"].Value = dbase.slDataReader["Barcode"].ToString(); using (dbase.msDataReader = dbase.msCommand.ExecuteReader()) { while (dbase.msDataReader.Read()) { SqlConnection cnn = new SqlConnection(dbase.Msconnectionstring.ToString()); cnn.Open(); string insert = string.Concat("INSERT INTO [dbo].[xtrCount] ([DepoKodu] ,[Barkod],[UrunKodu],[Renk],[Boyut1],[Boyut2],[Boyut3],[Miktar]) VALUES ('", comboBoxWareHouse.Text.ToString(), "' , '", dbase.msDataReader["Barcode"].ToString(), "','", dbase.msDataReader["ItemCode"].ToString(), "','", dbase.msDataReader["ColorCode"].ToString(), "','", dbase.msDataReader["ItemDim1Code"].ToString(), "','", dbase.msDataReader["ItemDim2Code"].ToString(), "','", dbase.msDataReader["ItemDim3Code"].ToString(), "','", dbase.slDataReader["Qty"].ToString(), "')"); SqlCommand cmd = new SqlCommand(insert, cnn); cmd.ExecuteNonQuery(); cnn.Close(); } } } dbase.ClosemsConnection(); StringBuilder errorMessages = new StringBuilder(); try { dbase.OpenmsConnection(); dbase.msCommand.Parameters.Clear(); dbase.msCommand.Connection = dbase.msConnection; dbase.msCommand.CommandType = CommandType.StoredProcedure; dbase.msCommand.CommandText = "ct_ImportCount"; dbase.msCommand.Parameters.Add("@InventoryDate", SqlDbType.Date); dbase.msCommand.Parameters["@InventoryDate"].Value = DateTime.Now.Date; dbase.msCommand.ExecuteNonQuery(); MessageBox.Show("Sayım fişi programa aktarıldı", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); dbase.msCommand.CommandType = CommandType.Text; dbase.msCommand.CommandText = "SELECT Barkod FROM [dbo].[xtrCount] WHERE UrunKodu = ''"; using (dbase.msDataReader = dbase.msCommand.ExecuteReader()) { List <string> UndefinedBarcodes = new List <string>(); while (dbase.msDataReader.Read()) { UndefinedBarcodes.Add(dbase.msDataReader["Barkod"].ToString()); } WriteTextFile.RW(UndefinedBarcodes, "TANIMSIZ_BARKODLAR"); MessageBox.Show("Sayıma eklenemeyen barkodlar 'TANIMSIZ BARKODLAR' isimli text dosyasına kaydedildi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); } dbase.msCommand.CommandText = "DELETE FROM [dbo].[xtrCount]"; dbase.msCommand.ExecuteNonQuery(); dbase.ClosemsConnection(); dbase.CloseslConnection(); } catch (SqlException ex) { for (int i = 0; i < ex.Errors.Count; i++) { errorMessages.Append("Index #" + i + "\n" + "Message: " + ex.Errors[i].Message + "\n" + "LineNumber: " + ex.Errors[i].LineNumber + "\n" + "Source: " + ex.Errors[i].Source + "\n" + "Procedure: " + ex.Errors[i].Procedure + "\n"); } MessageBox.Show(errorMessages.ToString(), "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } // Online transfer operations