Пример #1
0
        private void tlStripBtn_DbUpdate_Click(object sender, EventArgs e)
        {
            RawDataBLL rdb = new RawDataBLL();

            if (clickCounterSingle == 0 && clickCounterMulti == 0)
            {
                MessageBox.Show("没有要删除的数据记录存在。", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.tlStripBtn_DbUpdate.Enabled = false;
                return;
            }
            if (clickCounterSingle != 0)
            {
                //RawDataBLL rdb = new RawDataBLL();
                sqlSingle.Append(")");
                rdb.ExecuteCmd(sqlSingle.ToString());
                sqlSingle.Replace(sqlSingle.ToString(), "delete  from target where tgt_id in (");
                //sqlSingle="delete  from target where tgt_id in (";
                clickCounterSingle = 0;
            }
            if (clickCounterMulti != 0)
            {
                //RawDataBLL rdb = new RawDataBLL();
                sqlMulti.Append(")");
                rdb.ExecuteCmd(sqlMulti.ToString());
                sqlMulti.Replace(sqlMulti.ToString(), "delete  from target where tgt_id in (");
                //sqlSingle="delete  from target where tgt_id in (";
                clickCounterMulti = 0;
            }
            this.tlStripBtn_DbUpdate.Enabled = false;
            MessageBox.Show("数据已成功从数据库删除。", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #2
0
        /// <summary>
        /// 用于导入Excel表格中的源数据到数据库表 target 中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImport_Click(object sender, EventArgs e)
        {
            int counter = 0;

            try
            {
                if (rawDataGridView.SelectedRows.Count > 0)
                {
                    RawDataBLL rdb = new RawDataBLL();
                    string     tgtName, bsnName, tgtPs, tgtSc = "";
                    float      tgtGrN, tgtGrX, tgtTrRomsN, tgtTrRomsX, tgtTocN, tgtTocX;
                    string     tgtKt;
                    float      tgtRoN, tgtRoX, tgtEa, tgtGcN, tgtGcX, tgtRrN, tgtRrX, tgtPorN, tgtPorX;
                    string     tgtScd = "", tgtRfc = "";
                    int        tgtDrN, tgtDrX;
                    float      tgtPcN, tgtPcX, tgtPer;
                    string     tgtFdd = "";
                    float      tgtPsdcN, tgtPsdcX;
                    int        tgtBmcN, tgtBmcX;
                    string     tgtDs, tgtLed, tgtGp, tgtDmd, tgtTu, tgtPn, tgtSg;
                    int[]      colIndex = { 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 23, 24, 25, 26, 27, 29, 30, 31, 32 };
                    int        rowIndex = 0, diffVal;
                    int        rowsAmount = rawDataGridView.SelectedRows.Count;

                    StringBuilder sql = new StringBuilder("insert ignore into target " +
                                                          "(tgt_Att_Name, bsn_Att_Name, tgt_Att_Ps, tgt_Att_Para_Sc, tgt_Att_Para_Gr_Min, " +
                                                          "tgt_Att_Para_Gr_Max, tgt_Geo_Para_TrRoms_Min, tgt_Geo_Para_TrRoms_Max, tgt_Geo_Para_Toc_Min, tgt_Geo_Para_Toc_Max," +
                                                          " tgt_Geo_Para_Kt, tgt_Geo_Para_Ro_Min, tgt_Geo_Para_Ro_Max, tgt_Geo_Para_Ea, tgt_Geo_Para_Gc_Min, " +
                                                          "tgt_Geo_Para_Gc_Max, tgt_Geo_Para_Rr_Min, tgt_Geo_Para_Rr_Max, tgt_Geo_Para_Por_Min, tgt_Geo_Para_Por_Max, " +
                                                          "tgt_Geo_Para_Scd, tgt_Geo_Para_Rfc, tgt_Eng_Para_Dr_Min, tgt_Eng_Para_Dr_Max, tgt_Eng_Para_Pc_Min, " +
                                                          "tgt_Eng_Para_Pc_Max, tgt_Eng_Para_Per, tgt_Eng_Para_Fdd, tgt_Eng_Para_Psdc_Min, tgt_Eng_Para_Psdc_Max, " +
                                                          "tgt_Eng_Para_Bmc_Min, tgt_Eng_Para_Bmc_Max, tgt_Eng_Para_Ds, tgt_Eng_Para_Led, tgt_Mkt_Para_Gp," +
                                                          "tgt_Mkt_Para_Dmd, tgt_Mkt_Para_Tu, tgt_Mkt_Para_Pn, tgt_Mkt_Para_Sg) values ");
                    DialogResult RSS = MessageBox.Show(this, "确定要写入选中行数据吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    switch (RSS)
                    {
                    case DialogResult.Yes:
                        for (int i = rowsAmount; i > 0; i--)
                        {
                            rowIndex++;
                            sql.Append("(\"");
                            for (int j = 0; j < colIndex.Length; j++)
                            {
                                if (rawDataGridView.SelectedRows[i - 1].Cells[colIndex[j]].Value.ToString() == "")
                                {
                                    rawDataGridView.SelectedRows[i - 1].Cells[colIndex[j]].Value = 0;
                                }
                            }
                            if ((rawDataGridView.SelectedRows[i - 1].Cells[1].Value).ToString() != "")
                            {
                                tgtName = (rawDataGridView.SelectedRows[i - 1].Cells[1].Value).ToString() + "\",";
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[2].Value).ToString() != "")
                                {
                                    bsnName = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[2].Value).ToString() + "\",";
                                }
                                else
                                {
                                    bsnName = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[3].Value).ToString() != "")
                                {
                                    tgtPs = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[3].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtPs = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[4].Value).ToString() != "")
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[4].Value).ToString().Equals("中") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[4].Value).ToString().Equals("好") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[4].Value).ToString().Equals("差") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[4].Value).ToString().Equals("较好"))
                                    {
                                        tgtSc = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[4].Value).ToString() + "\",";
                                    }
                                    else
                                    {
                                        MessageBox.Show("第 " + rowIndex + " 行 '保存条件' 该字段值是枚举类型,只能是“好,较好,中,差”值中的一个。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        return;
                                    }
                                }
                                else
                                {
                                    tgtSc = "NULL,";
                                }

                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[6].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[5].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[5].Value).ToString() != "")
                                    {
                                        tgtGrN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[5].Value);
                                    }
                                    else
                                    {
                                        tgtGrN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[6].Value).ToString() != "")
                                    {
                                        tgtGrX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[6].Value);
                                    }
                                    else
                                    {
                                        tgtGrX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大地质资源量应该大于或等于最小地质资源量!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[8].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[7].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[7].Value).ToString() != "")
                                    {
                                        tgtTrRomsN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[7].Value);
                                    }
                                    else
                                    {
                                        tgtTrRomsN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[8].Value).ToString() != "")
                                    {
                                        tgtTrRomsX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[8].Value);
                                    }
                                    else
                                    {
                                        tgtTrRomsX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大富有机质页岩厚度应该大于或等于最小富有机质页岩厚度!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[10].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[9].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[9].Value).ToString() != "")
                                    {
                                        tgtTocN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[9].Value);
                                    }
                                    else
                                    {
                                        tgtTocN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[10].Value).ToString() != "")
                                    {
                                        tgtTocX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[10].Value);
                                    }
                                    else
                                    {
                                        tgtTocX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大Toc值应该大于或等于最小Toc值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[11].Value).ToString() != "")
                                {
                                    tgtKt = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[11].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtKt = "NULL,";
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[13].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[12].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[12].Value).ToString() != "")
                                    {
                                        tgtRoN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[12].Value);
                                    }
                                    else
                                    {
                                        tgtRoN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[13].Value).ToString() != "")
                                    {
                                        tgtRoX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[13].Value);
                                    }
                                    else
                                    {
                                        tgtRoX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大Ro值应该大于或等于最小Ro值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[14].Value).ToString() != "")
                                {
                                    tgtEa = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[14].Value);
                                }
                                else
                                {
                                    tgtEa = 0;
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[16].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[15].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[15].Value).ToString() != "")
                                    {
                                        tgtGcN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[15].Value);
                                    }
                                    else
                                    {
                                        tgtGcN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[16].Value).ToString() != "")
                                    {
                                        tgtGcX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[16].Value);
                                    }
                                    else
                                    {
                                        tgtGcX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大含气量值应该大于或等于最小含气量值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[18].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[17].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[17].Value).ToString() != "")
                                    {
                                        tgtRrN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[17].Value);
                                    }
                                    else
                                    {
                                        tgtRrN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[18].Value).ToString() != "")
                                    {
                                        tgtRrX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[18].Value);
                                    }
                                    else
                                    {
                                        tgtRrX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大资源丰度值应该大于或等于最小资源丰度值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[20].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[19].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[19].Value).ToString() != "")
                                    {
                                        tgtPorN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[19].Value);
                                    }
                                    else
                                    {
                                        tgtPorN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[20].Value).ToString() != "")
                                    {
                                        tgtPorX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[20].Value);
                                    }
                                    else
                                    {
                                        tgtPorX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大孔隙度值应该大于或等于最小孔隙度值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[21].Value).ToString() != "")
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[21].Value).ToString().Equals("中") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[21].Value).ToString().Equals("好") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[21].Value).ToString().Equals("差") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[21].Value).ToString().Equals("较好"))
                                    {
                                        tgtScd = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[21].Value).ToString() + "\",";
                                    }
                                    else
                                    {
                                        MessageBox.Show("第 " + rowIndex + " 行 '构造复杂程度' 该字段值是枚举类型,只能是“好,较好,中,差”值中的一个。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        return;
                                    }
                                }
                                else
                                {
                                    tgtScd = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[22].Value).ToString() != "")
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[22].Value).ToString().Equals("中") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[22].Value).ToString().Equals("好") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[22].Value).ToString().Equals("差") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[22].Value).ToString().Equals("较好"))
                                    {
                                        tgtRfc = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[22].Value).ToString() + "\",";
                                    }
                                    else
                                    {
                                        MessageBox.Show("第 " + rowIndex + " 行 '顶底板条件' 该字段值是枚举类型,只能是“好,较好,中,差”值中的一个。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        return;
                                    }
                                }
                                else
                                {
                                    tgtRfc = "NULL,";
                                }
                                if (Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[24].Value) >=
                                    Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[23].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[23].Value).ToString() != "")
                                    {
                                        tgtDrN = Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[23].Value);
                                    }
                                    else
                                    {
                                        tgtDrN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[24].Value).ToString() != "")
                                    {
                                        tgtDrX = Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[24].Value);
                                    }
                                    else
                                    {
                                        tgtDrX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大埋深范围值应该大于或等于最小埋深范围值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[26].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[25].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[25].Value).ToString() != "")
                                    {
                                        tgtPcN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[25].Value);
                                    }
                                    else
                                    {
                                        tgtPcN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[26].Value).ToString() != "")
                                    {
                                        tgtPcX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[26].Value);
                                    }
                                    else
                                    {
                                        tgtPcX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大压力系数值应该大于或等于最小压力系数值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[27].Value).ToString() != "")
                                {
                                    tgtPer = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[27].Value);
                                }
                                else
                                {
                                    tgtPer = 0;
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[28].Value).ToString() != "")
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[28].Value).ToString().Equals("中") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[28].Value).ToString().Equals("好") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[28].Value).ToString().Equals("差") ||
                                        (rawDataGridView.SelectedRows[i - 1].Cells[28].Value).ToString().Equals("较好"))
                                    {
                                        tgtFdd = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[28].Value).ToString() + "\",";
                                    }
                                    else
                                    {
                                        MessageBox.Show("第 " + rowIndex + " 行 '裂缝发育程度' 该字段值是枚举类型,只能是“好,较好,中,差”值中的一个。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        return;
                                    }
                                }
                                else
                                {
                                    tgtFdd = "NULL,";
                                }
                                if (Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[30].Value) >=
                                    Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[29].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[29].Value).ToString() != "")
                                    {
                                        tgtPsdcN = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[29].Value);
                                    }
                                    else
                                    {
                                        tgtPsdcN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[30].Value).ToString() != "")
                                    {
                                        tgtPsdcX = Convert.ToSingle(rawDataGridView.SelectedRows[i - 1].Cells[30].Value);
                                    }
                                    else
                                    {
                                        tgtPsdcX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大主应力差异系数值应该大于或等于最小主应力差异系数值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if (Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[32].Value) >=
                                    Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[31].Value))
                                {
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[31].Value).ToString() != "")
                                    {
                                        tgtBmcN = Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[31].Value);
                                    }
                                    else
                                    {
                                        tgtBmcN = 0;
                                    }
                                    if ((rawDataGridView.SelectedRows[i - 1].Cells[32].Value).ToString() != "")
                                    {
                                        tgtBmcX = Convert.ToInt32(rawDataGridView.SelectedRows[i - 1].Cells[32].Value);
                                    }
                                    else
                                    {
                                        tgtBmcX = 0;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("第 " + rowIndex + " 行最大脆性矿物含量值应该大于或等于最小脆性矿物含量值!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    return;
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[33].Value).ToString() != "")
                                {
                                    tgtDs = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[33].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtDs = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[34].Value).ToString() != "")
                                {
                                    tgtLed = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[34].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtLed = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[35].Value).ToString() != "")
                                {
                                    tgtGp = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[35].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtGp = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[36].Value).ToString() != "")
                                {
                                    tgtDmd = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[36].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtDmd = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[37].Value).ToString() != "")
                                {
                                    tgtTu = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[37].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtTu = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[38].Value).ToString() != "")
                                {
                                    tgtPn = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[38].Value).ToString() + "\",";
                                }
                                else
                                {
                                    tgtPn = "NULL,";
                                }
                                if ((rawDataGridView.SelectedRows[i - 1].Cells[39].Value).ToString() != "")
                                {
                                    tgtSg = "\"" + (rawDataGridView.SelectedRows[i - 1].Cells[39].Value).ToString() + "\")";
                                }
                                else
                                {
                                    tgtSg = "NULL)";
                                }
                                sql.Append(tgtName);
                                sql.Append(bsnName);
                                sql.Append(tgtPs);
                                sql.Append(tgtSc);
                                sql.Append(tgtGrN);
                                sql.Append(",");
                                sql.Append(tgtGrX);
                                sql.Append(",");
                                sql.Append(tgtTrRomsN);
                                sql.Append(",");
                                sql.Append(tgtTrRomsX);
                                sql.Append(",");
                                sql.Append(tgtTocN);
                                sql.Append(",");
                                sql.Append(tgtTocX);
                                sql.Append(",");
                                sql.Append(tgtKt);
                                sql.Append(tgtRoN);
                                sql.Append(",");
                                sql.Append(tgtRoX);
                                sql.Append(",");
                                sql.Append(tgtEa);
                                sql.Append(",");
                                sql.Append(tgtGcN);
                                sql.Append(",");
                                sql.Append(tgtGcX);
                                sql.Append(",");
                                sql.Append(tgtRrN);
                                sql.Append(",");
                                sql.Append(tgtRrX);
                                sql.Append(",");
                                sql.Append(tgtPorN);
                                sql.Append(",");
                                sql.Append(tgtPorX);
                                sql.Append(",");
                                sql.Append(tgtScd);
                                sql.Append(tgtRfc);
                                sql.Append(tgtDrN);
                                sql.Append(",");
                                sql.Append(tgtDrX);
                                sql.Append(",");
                                sql.Append(tgtPcN);
                                sql.Append(",");
                                sql.Append(tgtPcX);
                                sql.Append(",");
                                sql.Append(tgtPer);
                                sql.Append(",");
                                sql.Append(tgtFdd);
                                sql.Append(tgtPsdcN);
                                sql.Append(",");
                                sql.Append(tgtPsdcX);
                                sql.Append(",");
                                sql.Append(tgtBmcN);
                                sql.Append(",");
                                sql.Append(tgtBmcX);
                                sql.Append(",");
                                sql.Append(tgtDs);
                                sql.Append(tgtLed);
                                sql.Append(tgtGp);
                                sql.Append(tgtDmd);
                                sql.Append(tgtTu);
                                sql.Append(tgtPn);
                                sql.Append(tgtSg);
                                //sql.ToString();
                            }
                            else
                            {
                                MessageBox.Show("目标区块名称不能为空,数据导入中止!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                            //counter += rdb.Insert(sql.ToString());
                            if ((i - 1) != 0)
                            {
                                sql.Append(",");
                            }
                        }
                        rdb.ExecuteCmd("alter table target auto_increment=1");
                        counter += rdb.Insert(sql.ToString());
                        if (counter != 0)
                        {
                            if (counter == rowsAmount)
                            {
                                MessageBox.Show("成功写入所选中 " + counter + " 行数据!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                diffVal = rowsAmount - counter;
                                MessageBox.Show("成功写入所选 " + rowsAmount + " 数据中的 " + counter + " 行数据!\n\r导入数据中有 " + diffVal + " 条与数据库中目标区名称重复!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("成功写入所选 " + rowsAmount + "行数据中的 0 行数据!\n\r导入数据中有 " + rowsAmount + " 条与数据库中目标区名称重复!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        break;

                    case DialogResult.No:
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("请选择需要写入的行。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
            }
            catch
            {
                MessageBox.Show("目标区块名称冲突,数据库中已存在当前要插入的第 " + (counter + 1) + " 行数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }