Ejemplo n.º 1
0
        private void import_data()
        {
            List <tmpdata>        alist = session.blist;
            List <AI_listenScore> blist = new List <AI_listenScore>();
            string sqlstr    = string.Format("SELECT batchno FROM AI_listenScore ORDER BY batchno desc LIMIT 1");
            var    a         = MySqlHelper.ExecuteScalar(CommandType.Text, sqlstr);
            int    batchno   = 1;
            string batchdesc = txtbatchdesc.Text.Trim();

            if (a != null)
            {
                batchno = Convert.ToInt32(a) + 1;
            }
            List <string> sqllist = new List <string>();

            foreach (var item1 in alist)
            {
                AI_listenScore es = new AI_listenScore();

                try
                {
                    es.papercode = getproval(item1, comboBox1.Text);
                    if (textBox1.Text != "")
                    {
                        es.papercode = es.papercode.Replace(textBox1.Text, textBox12.Text);
                    }
                    es.itemno = getproval(item1, comboBox2.Text);
                    if (textBox2.Text != "")
                    {
                        es.itemno = es.itemno.Replace(textBox2.Text, textBox11.Text);
                    }
                    es.encodeno = getproval(item1, comboBox3.Text);
                    if (textBox3.Text != "")
                    {
                        es.encodeno = es.encodeno.Replace(textBox3.Text, textBox10.Text);
                    }
                    es.filename = getproval(item1, comboBox4.Text);
                    if (textBox4.Text != "")
                    {
                        es.filename = es.filename.Replace(textBox4.Text, textBox9.Text);
                    }
                    es.Score1 = getproval(item1, comboBox5.Text);
                    if (textBox5.Text != "")
                    {
                        es.Score1 = es.Score1.Replace(textBox5.Text, textBox8.Text);
                    }

                    es.Statu = "0";

                    string sql1 = string.Format("INSERT INTO AI_listenScore ( papercode, itemno, encodeno, filename, Score1, Statu,batchno,batchdesc) VALUES ('{0}','{1}','{2}','{3}','{4}' ,'{5}','{6}','{7}')", es.papercode, es.itemno, es.encodeno, es.filename.Replace(@"\", "/"), es.Score1, es.Statu, batchno, batchdesc);

                    sqllist.Add(sql1);
                }
                catch (Exception)
                {
                    //blist.Add(es);
                }
            }

            MySqlHelper.ExecuteSqlTran(sqllist);
            MessageBox.Show("导入成功!!!");
        }