Ejemplo n.º 1
0
 private void btn_Insert_Click(object sender, EventArgs e)
 {
     if (listBox1.Text != "")
     {
         int rows;
         if (int.TryParse(textBox2.Text, out rows))
         {
             //начать загрузку
             if (textBox1.Text == "")
                 textBox1.Text = "1";
             _range = "A" + (Convert.ToInt32(textBox1.Text) - 1).ToString() + ":V" + textBox2.Text;
             OdbcConnection cn = new OdbcConnection();
             cn.ConnectionString = string.Format(@"Driver={{Microsoft Excel Driver (*.xls)}};DBQ={0};ReadOnly=0;", label1.Text);
             string strCom = "select * from [" + _sheet + "$" + _range + "]";
             cn.Open();
             OdbcCommand comm_mon = new OdbcCommand(strCom, cn);
             OdbcDataAdapter da = new OdbcDataAdapter();
             da.SelectCommand = comm_mon;
             System.Data.DataTable dt = new System.Data.DataTable();
             da.Fill(dt);
             DataSaver ds = new DataSaver(login_, password_);
             string Warning = "";
             Warning = ds.Save(dt, Convert.ToInt32(textBox1.Text));
             ContractsFill();
             if (Warning != "")
                 MessageBox.Show(Warning);
         }
         else
         {
             MessageBox.Show("Укажите количество строк");
         }
     }
 }