Sorry, last post I put an wrong code. This is the correct code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.Odbc;
using System.IO;
namespace purchaseorder2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Data.Odbc.OdbcConnection odbcConnection1;
private System.Data.Odbc.OdbcDataAdapter odbcDataAdapter1;
private purchaseorder2.DataSet1 dataSet11;
private System.Data.Odbc.OdbcCommand odbcSelectCommand1;
private System.Windows.Forms.Label label1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
//mai jos sunt variabilele in care avem informatiile din fisier
String nrpo1;
String cui1;
String numef1;
String data1;
String nrfac1;
String lc1;
String ic1;
String desc1;
String compid1;
String numecomp1;
String nrgest1;
String qtty1;
String pretu1;
String pdisc1;
String vtf1;
String codt1;
String numed1;
String cnr1;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
StreamReader sr=new StreamReader("C:\\poclarisys\\po-dupa
modificare.txt");
int end;
String result="";
char[] vc={','};
while((result=sr.ReadLine())!=null)
{
string[] vs;
//result=sr.ReadLine();
vs=result.Split(vc);
//scoatem din fisier nr ordinului de cumparare
String nrpo=vs[0];
try
{
end=nrpo.LastIndexOf('"');
nrpo1=nrpo.Substring(1,end-1);
//Console.WriteLine("Numarul ordinului de cumparare: {0}\n",nrpo1);
}
catch(System.Exception){}
//scoatem din fisier codul unic de identificare al furnizorului
try
{
String cui=vs[1];
end=cui.LastIndexOf('"');
cui1=cui.Substring(1,end-1);
//Console.WriteLine("Nr unic de identif furnizor: {0}\n",cui1);
}
catch(System.Exception){};
//scoatem numele furnizorului
try
{
String numef=vs[2];
end=numef.LastIndexOf('"');
numef1=numef.Substring(1,end-1);
//Console.WriteLine("Nume furnizor: {0}\n",numef1);
}
catch(System.Exception){};
//scoatem data tranzactiei
try
{
String data=vs[3];
end=data.LastIndexOf('"');
data1=data.Substring(1,end-1);
//Console.WriteLine("Data tranzactiei: {0}\n",data1);
}
catch(System.Exception){};
//scoatem identificatorul companiei
try
{
String compid=vs[6];
end=compid.LastIndexOf('"');
compid1=compid.Substring(1,end-1);
//Console.WriteLine("Nr de identif al companiei: {0}\n",compid1);
}
catch(System.Exception){};
//scoatem numele companiei
try
{
string numecomp=vs[7];
end=numecomp.LastIndexOf('"');
numecomp1=numecomp.Substring(1,end-1);
//Console.WriteLine("Numele companiei: {0}\n",numecomp1);
}
catch(System.Exception){};
//scoatem numarul gestiunii
try
{
String nrgest=vs[8];
end=nrgest.LastIndexOf('"');
nrgest1=nrgest.Substring(1,end-1);
//Console.WriteLine("Numarul gestuinii: {0}\n",nrgest1);
}
catch(System.Exception){};
//scoatem line code
try
{
String lc=vs[9];
end=lc.LastIndexOf('"');
lc1=lc.Substring(1,end-1);
//Console.WriteLine("Codul grupei de produse: {0}\n",lc1);
}
catch(System.Exception){};
//scoatem item code
try
{
String ic=vs[10];
end=ic.LastIndexOf('"');
ic1=ic.Substring(1,end-1);
//Console.WriteLine("Item code: {0}\n",ic1);
}
catch(System.Exception){};
//scoatem descrierea produsului
try
{
String desc=vs[11];
end=desc.LastIndexOf('"');
desc1=desc.Substring(1,end-1);
//Console.WriteLine("Descrierea produsului cumparat: {0}\n",desc1);
}
catch(System.Exception){};
//scoatem cantitatea cumparata
try
{
String qtty=vs[12];
end=qtty.LastIndexOf('"');
qtty1=qtty.Substring(1,end-1);
//Console.WriteLine("Cantitatea achizitionata: {0}\n",qtty1);
}
catch(System.Exception){};
//scoatem pretul unitar
try
{
String pretu=vs[13];
end=pretu.LastIndexOf('"');
pretu1=pretu.Substring(1,end-1);
//Console.WriteLine("Pretul unitar: {0}\n",pretu1);
}
catch(System.Exception){};
//scoatem procentul de discount acordat
try
{
String pdisc=vs[14];
end=pdisc.LastIndexOf('"');
pdisc1=pdisc.Substring(1,end-1);
//Console.WriteLine("Procent discount: {0}\n",pdisc1);
}
catch(System.Exception){};
//scoatem valoare totala marfa fara TVA
try
{
String vtf=vs[15];
end=vtf.LastIndexOf('"');
vtf1=vtf.Substring(1,end-1);
//Console.WriteLine("Valoarea marfii fara TVA: {0}\n",vtf1);
}
catch(System.Exception){};
//scoatem numarul facturii
try
{
String nrfac=vs[16];
end=nrfac.LastIndexOf('"');
nrfac1=nrfac.Substring(1,end-1);
//Console.WriteLine("Numarul facturii: {0}\n",nrfac1);
}
catch(System.Exception){};
//scoatem codul tranzactiei
try
{
String codt=vs[17];
end=codt.LastIndexOf('"');
codt1=codt.Substring(1,end-1);
//Console.WriteLine("Codul tranzactiei: {0}\n",codt1);
}
catch(System.Exception){};
//scoatem numele delegatului
try
{
String numed=vs[18];
end=numed.LastIndexOf('"');
numed1=numed.Substring(1,end-1);
//Console.WriteLine("Numele delegatului: {0}\n",numed1);
}
catch(System.Exception){};
//scoatem nr masina
try
{
String cnr=vs[19];
end=cnr.LastIndexOf('"');
cnr1=cnr.Substring(1,end-1);
//Console.WriteLine("Numarul masinii: {0}\n",cnr1);
}
catch(System.Exception){};
//Console.Read();
//sfarsit parte de fisier
try
{
odbcConnection1.Open();
//'111122','BAR','13','Coca-Cola mea','99','99','1111','0','109989','1'
//,Cfrdet_order_number,Cfrdet_line_code,Cfrdet_item_code,Cfrdet_desc,Cfrdet_qty_order,Cfrdet_qty_received,Cfrdet_price,Cfrdet_discount,Cfrdet_total,Cfrdet_from_po
OdbcCommand cmd=new OdbcCommand("insert into
cfrdet(Cfrdet_paking_slip,Cfrdet_order_number,Cfrdet_line_code,Cfrdet_item_code,Cfrdet_desc,Cfrdet_qty_order,Cfrdet_qty_received,Cfrdet_price,Cfrdet_discount,Cfrdet_total,Cfrdet_from_po)"+
"values(?,?,?,?,?,?,?,?,?,?,?)",odbcConnection1);
cmd.Parameters.Add("@nrfac",OdbcType.Text);
cmd.Parameters["@nrfac"].Value=nrfac1.ToString();
cmd.Parameters.Add("@nrpo",OdbcType.Text);
cmd.Parameters["@nrpo"].Value=nrpo1.ToString();
cmd.Parameters.Add("@lc",OdbcType.Text);
cmd.Parameters["@lc"].Value=lc1.ToString();
cmd.Parameters.Add("@ic",OdbcType.Text);
cmd.Parameters["@ic"].Value=ic1.ToString();
cmd.Parameters.Add("@desc",OdbcType.Text);
cmd.Parameters["@desc"].Value=desc1.ToString();
cmd.Parameters.Add("@qtty",OdbcType.Double);
cmd.Parameters["@qtty"].Value=Convert.ToDouble(qtty1);
cmd.Parameters.Add("@qtty2",OdbcType.Double);
cmd.Parameters["@qtty2"].Value=Convert.ToDouble(qtty1);
cmd.Parameters.Add("@pret",OdbcType.Double);
cmd.Parameters["@pret"].Value=Convert.ToDouble(pretu1);
cmd.Parameters.Add("@pdisc",OdbcType.Double);
cmd.Parameters["@pdisc"].Value=Convert.ToDouble(pdisc1);
cmd.Parameters.Add("@vtf",OdbcType.Double);
cmd.Parameters["@vtf"].Value=Convert.ToDouble(vtf1);
if(nrpo1!="")
{
cmd.Parameters.Add("@fpo",OdbcType.Bit);
cmd.Parameters["@fpo"].Value=1;
}
else
{
cmd.Parameters.Add("@fpo",OdbcType.Bit);
cmd.Parameters["@fpo"].Value=0;
}
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
}
catch(OdbcException ex){}
finally
{
odbcConnection1.Close();
}
}
//
// TODO: Add any constructor code after InitializeComponent call
//
//Provider=MSDASQL.1;Persist Security Info=False;Extended
Properties="DSN=bdpo;DBQ=C:\CLARISYS040802\PPAK\DATA4\BDPO;DefaultDir=C:\CLARISYS040802\PPAK\DATA4\BDPO;DriverId=538;FIL=Paradox
5.X;MaxBufferSize=2048;PageTimeout=5;"
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.odbcConnection1 = new System.Data.Odbc.OdbcConnection();
this.odbcDataAdapter1 = new System.Data.Odbc.OdbcDataAdapter();
this.odbcSelectCommand1 = new System.Data.Odbc.OdbcCommand();
this.dataSet11 = new purchaseorder2.DataSet1();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
this.SuspendLayout();
//
// odbcConnection1
//
this.odbcConnection1.ConnectionString = "MaxBufferSize=2048;FIL=Paradox
5.X;DSN=bdpo;PageTimeout=5;DefaultDir=C:\\CLARISYS0" +
"40802\\PPAK\\DATA4\\BDPO;DBQ=C:\\CLARISYS040802\\PPAK\\DATA4\\BDPO;DriverId=538";
//
// odbcDataAdapter1
//
this.odbcDataAdapter1.SelectCommand = this.odbcSelectCommand1;
this.odbcDataAdapter1.TableMappings.AddRange(new
System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table",
"Table", new System.Data.Common.DataColumnMapping[] {
new
System.Data.Common.DataColumnMapping("Cfrdet_paking_slip",
"Cfrdet_paking_slip"),
new
System.Data.Common.DataColumnMapping("Cfrdet_line", "Cfrdet_line"),
new
System.Data.Common.DataColumnMapping("Cfrdet_order_number",
"Cfrdet_order_number"),
new
System.Data.Common.DataColumnMapping("Cfrdet_line_code", "Cfrdet_line_code"),
new
System.Data.Common.DataColumnMapping("Cfrdet_item_code", "Cfrdet_item_code"),
new
System.Data.Common.DataColumnMapping("Cfrdet_desc", "Cfrdet_desc"),
new
System.Data.Common.DataColumnMapping("Cfrdet_qty_order", "Cfrdet_qty_order"),
new
System.Data.Common.DataColumnMapping("Cfrdet_qty_received",
"Cfrdet_qty_received"),
new
System.Data.Common.DataColumnMapping("Cfrdet_price", "Cfrdet_price"),
new
System.Data.Common.DataColumnMapping("Cfrdet_discount", "Cfrdet_discount"),
new
System.Data.Common.DataColumnMapping("Cfrdet_total", "Cfrdet_total"),
new
System.Data.Common.DataColumnMapping("Cfrdet_bin_loc", "Cfrdet_bin_loc"),
new
System.Data.Common.DataColumnMapping("Cfrdet_from_po", "Cfrdet_from_po"),
new
System.Data.Common.DataColumnMapping("Cfrdet_CylindersReceived",
"Cfrdet_CylindersReceived")})});
this.odbcDataAdapter1.RowUpdated += new
System.Data.Odbc.OdbcRowUpdatedEventHandler(this.odbcDataAdapter1_RowUpdated);
//
// odbcSelectCommand1
//
this.odbcSelectCommand1.CommandText = "SELECT * FROM cfrdet";
this.odbcSelectCommand1.Connection = this.odbcConnection1;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("en-US");
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(144, 40);
this.label1.TabIndex = 0;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(504, 273);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.TransparencyKey = System.Drawing.Color.Silver;
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
//DSN=bdpo;DBQ=C:\CLARISYS040802\PPAK\DATA4\BDPO;DefaultDir=C:\CLARISYS040802\PPAK\DATA4\BDPO;DriverId=538;FIL=Paradox
5.X;MaxBufferSize=2048;PageTimeout=5;
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void odbcDataAdapter1_RowUpdated(object sender,
System.Data.Odbc.OdbcRowUpdatedEventArgs e)
{
}
private void dataGrid1_Navigate(object sender,
System.Windows.Forms.NavigateEventArgs ne)
{
}
}
}