Ejemplo n.º 1
0
            private void btn_KSSS_load_Click(object sender, EventArgs e)
            {
                if (listBox_KSSS.Text != "")
                {

                    string Warning = "";
                    int rows;
                    if (int.TryParse(tb_KSSS_lastRow.Text, out rows) && (Convert.ToInt32(tb_KSSS_lastRow.Text) - Convert.ToInt32(tb_KSSS_firstRow.Text)) >= 0)
                    {
                        //начать загрузку
                        if (tb_KSSS_firstRow.Text == "")
                            tb_KSSS_firstRow.Text = "1";
                        _range = "A" + (Convert.ToInt32(tb_KSSS_firstRow.Text) - 1).ToString() + ":D" + tb_KSSS_lastRow.Text;
                        OdbcConnection cn = new OdbcConnection();
                        cn.ConnectionString = string.Format(@"Driver={{Microsoft Excel Driver (*.xls)}};DBQ={0};ReadOnly=0;", lbl_KSSS_dateload.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_);
                        Warning = ds.SaveKSSStable(dt, Convert.ToInt32(tb_KSSS_firstRow.Text));
 
                        if (Warning != "")
                            MessageBox.Show(Warning);
                    }
                    else
                    {
                        MessageBox.Show("Укажите корректное количество строк!");
                    }
                }
                KSSStoContragentFill();
            }