public Form10(int rownumber, int licence) { // // Required for Windows Form Designer support lic = licence; InitializeComponent(); this.Height = Screen.PrimaryScreen.Bounds.Height; this.Width = Screen.PrimaryScreen.Bounds.Width; Update(); string connectionString; connectionString = "DataSource=Baza.sdf; Password=matrix1"; SqlCeConnection cn = new SqlCeConnection(connectionString); cn.Open(); SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM dok", cn); DataTable table = new DataTable(); da.Fill(table); index = table.Rows[rownumber][0].ToString(); SqlCeCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT nazwadok, typ, data, send FROM dok WHERE id = ?"; cmd.Parameters.Add("@k", SqlDbType.Int); cmd.Parameters["@k"].Value = int.Parse(index); cmd.Prepare(); SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { nazwa_t.Text = dr.GetString(0); comboBox1.Text = dr.GetString(1); data_t.Text = dr.GetSqlDateTime(2).ToString(); if (dr.GetBoolean(3) == true) { send_c.Checked = dr.GetBoolean(3); } } nazwa_t.Focus(); data_t.Text = System.DateTime.Now.ToString(); // // TODO: Add any constructor code after InitializeComponent call cn.Close(); // }
public void senddoc() { string connectionString; string filename = (ufile); StreamWriter sw = new StreamWriter(filename); connectionString = "DataSource=Baza.sdf; Password=matrix1"; SqlCeConnection cn = new SqlCeConnection(connectionString); cn.Open(); SqlCeDataAdapter da = new SqlCeDataAdapter("SELECT * FROM dok", cn); DataTable table = new DataTable(); da.Fill(table); string index = table.Rows[rownum][0].ToString(); SqlCeCommand cmdh = cn.CreateCommand(); cmdh.CommandText = "SELECT nazwadok, typ, data FROM dok WHERE id = ?"; cmdh.Parameters.Add("@d", SqlDbType.Int); cmdh.Prepare(); cmdh.Parameters["@d"].Value = int.Parse(index); SqlCeDataReader drh = cmdh.ExecuteReader(); while (drh.Read()) { sw.WriteLine(drh.GetString(0) + ";" + drh.GetString(1) + ";" + Convert.ToString(drh.GetSqlDateTime(2))); } SqlCeCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT dokid, kod, nazwa, cenazk, ilosc, stan, cenasp, vat FROM bufor WHERE dokid = ?"; cmd.Parameters.Add("@d", SqlDbType.Int); cmd.Prepare(); cmd.Parameters["@d"].Value = int.Parse(index); SqlCeDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { decimal n = dr.GetDecimal(4); int did = dr.GetInt32(0); sw.WriteLine(Convert.ToString(did) + ";" + dr.GetString(1) + ";" + dr.GetString(2) + ";" + dr.GetString(3) + ";" + Convert.ToString(n) + ";" + dr.GetString(5) + ";" + dr.GetString(6) + ";" + dr.GetString(7)); } sw.Close(); cn.Close(); }