Beispiel #1
0
        public bool SqlUploadeInfo(string[] Column, Info InfoStruct)
        {
            string InsertStr = "insert into VehicleInfo (";
            for (int iLoop = 0; iLoop < Column.Length - 1; ++iLoop)
            {
                InsertStr += Column[iLoop] + ",";
            }
            InsertStr += "信息更新者姓名) values ('";
            InsertStr += InfoStruct.汽车ID + "','";
            InsertStr += InfoStruct.车型 + "','";
            InsertStr += InfoStruct.型号 + "','";
            InsertStr += InfoStruct.品牌 + "',";
            InsertStr += InfoStruct.年款 + ",'";
            InsertStr += InfoStruct.厂商 + "','";
            InsertStr += InfoStruct.级别 + "','";
            InsertStr += InfoStruct.车身结构 + "',";
            InsertStr += InfoStruct.长 + ",";
            InsertStr += InfoStruct.宽 + ",";
            InsertStr += InfoStruct.高 + ",";
            InsertStr += InfoStruct.最高车速 + ",";
            InsertStr += InfoStruct.百公里加速 + ",";
            InsertStr += InfoStruct.综合油耗 + ",";
            InsertStr += InfoStruct.最小离地间隙 + ",";
            InsertStr += InfoStruct.轴距 + ",";
            InsertStr += InfoStruct.前轮距 + ",";
            InsertStr += InfoStruct.后轮距 + ",";
            InsertStr += InfoStruct.整备质量 + ",";
            InsertStr += InfoStruct.车门数 + ",";
            InsertStr += InfoStruct.座位数 + ",";
            InsertStr += InfoStruct.行李厢容积 + ",";
            InsertStr += InfoStruct.排量 + ",";
            InsertStr += InfoStruct.最大马力 + ",";
            InsertStr += InfoStruct.最大功率 + ",'";
            InsertStr += InfoStruct.前轮胎规格 + "','";
            InsertStr += InfoStruct.后轮胎规格 + "','";
            InsertStr += InfoStruct.电动天窗 + "','";
            InsertStr += InfoStruct.全景天窗 + "','";
            InsertStr += InfoStruct.运动外观套件 + "','";
            InsertStr += InfoStruct.铝合金轮圈 + "','";
            InsertStr += InfoStruct.电动吸合门 + "','";
            InsertStr += InfoStruct.侧滑门 + "','";
            InsertStr += InfoStruct.电动后备厢 + "','";
            InsertStr += InfoStruct.感应后备厢 + "','";
            InsertStr += InfoStruct.车顶行李架 + "','";
            InsertStr += InfoStruct.外观颜色 + "','";
            InsertStr += InfoStruct.变速箱 + "','";
            InsertStr += InfoStruct.信息更新时间 + "','";
            InsertStr += InfoStruct.信息更新者工号 + "','";
            InsertStr += InfoStruct.信息更新者姓名 + "')";

            DatabaseCmd databasecmd = new DatabaseCmd();
            if (databasecmd.SqlExecuteNonQuery(InsertStr) == true)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #2
0
 //快速升级(只校验MD5值,不相同就更新)
 public void check()
 {
     string ThisApp = System.Windows.Forms.Application.ExecutablePath;
     string ThisAppMD5 = UserFunction.GetMD5HashFromFile(ThisApp);
     DatabaseCmd checkver = new DatabaseCmd();
     object obj = null;
     checkver.SqlExecuteScalar("select * from VerList where MD5 = '" + ThisAppMD5 + "'", out obj);
     if(obj == null)
     {
         update();
     }
 }
Beispiel #3
0
 public void update_info()
 {
     if(Login.disableCurrentVersion == true)
     {
         string selectcmd = "select 程序特点 from VerList where 程序名 = '汽车模型信息管理' and 屏蔽使用 = 'false'";
         DatabaseCmd checkUpdate = new DatabaseCmd();
         MySqlDataReader myreader;
         checkUpdate.SqlExecuteReader(selectcmd, out myreader);
         if(myreader.Read())
         {
             if(myreader.GetValue(0).ToString() != "")
             {
                 System.Windows.Forms.MessageBox.Show((string)myreader.GetValue(0).ToString(), "更新信息", System.Windows.Forms.MessageBoxButtons.OK);
             }
         }
         checkUpdate.SqlReaderClose();
     }
 }
Beispiel #4
0
 public void CheckVerList()
 {
     bool QuickUpdate = false;
     string selectcmd = "select 屏蔽使用,快速升级 from VerList where 程序名 = '汽车模型信息管理' and 版本号 = " + Version;
     DatabaseCmd checkUpdate = new DatabaseCmd();
     MySqlDataReader myreader;
     checkUpdate.SqlExecuteReader(selectcmd, out myreader);
     if(myreader.Read())
     {
         QuickUpdate = myreader.GetBoolean(1);
         Login.disableCurrentVersion = (myreader.GetBoolean(1) == true) ? (true) : (false);
     }
     checkUpdate.SqlReaderClose();
     update_info();
     if(QuickUpdate == true || Login.disableCurrentVersion == true)
     {
         check();
     }
 }
Beispiel #5
0
 private int GetAuthority(string Mail, string pwd, out string Name)
 {
     string str = "select 权限,姓名 from member where 邮箱 ='" + Mail + "' and 密码 ='" + pwd + "'";
     MySqlDataReader myreader;
     DatabaseCmd datacmd = new DatabaseCmd();
     datacmd.SqlExecuteReader(str,out myreader);
     if (myreader.Read())
     {
         Name = myreader.GetString(1);
         int authority = myreader.GetInt32(0);
         datacmd.SqlReaderClose();
         return authority;
     }
     else
     {
         Name = string.Empty;
         datacmd.SqlReaderClose();
         return 0;
     }
 }
Beispiel #6
0
        public bool SqlUploadGeoInfo(string[] Column, GeoInfo GeoInfoStruct, int ReserveNum)
        {
            DatabaseCmd SelectCmd = new DatabaseCmd();
            string sqlstr = "select count(汽车ID) from GeoInfo_" + GeoInfoStruct.Ext +
                " where 汽车ID = '" + GeoInfoStruct.汽车ID + "' and 视图 = '" + GeoInfoStruct.视图 + "'";
            try
            {
                MySqlDataReader myreader;
                SelectCmd.SqlExecuteReader(sqlstr, out myreader);
                if (myreader.Read())
                {
                    if (myreader.GetInt32(0) >= ReserveNum)
                    {
                        string delStr = "delete from GeoInfo_" + GeoInfoStruct.Ext + " where 汽车ID = '" + GeoInfoStruct.汽车ID +
                            "' and 视图 = '" + GeoInfoStruct.视图 + "' and 版本 not in (select top " + (ReserveNum - 1) + " (版本) from [GeoInfo_" +
                            GeoInfoStruct.Ext + "] where 汽车ID = '" + GeoInfoStruct.汽车ID + "' order by 版本 desc) ";
                        DatabaseCmd deleteCmd = new DatabaseCmd();
                        deleteCmd.SqlExecuteNonQuery(delStr);
                    }
                }
            }
            catch (Exception ex){MessageBox.Show(ex.Message);}
            finally{SelectCmd.SqlReaderClose();}

            DatabaseCmd datacmd = new DatabaseCmd();
            datacmd.GetConnection().Open();
            MySqlTransaction myTran = datacmd.GetConnection().BeginTransaction();
            try
            {
                datacmd.GetCommand().Connection = datacmd.GetConnection();
                datacmd.GetCommand().Transaction = myTran;
                datacmd.GetCommand().CommandType = CommandType.Text;
                datacmd.GetCommand().CommandText = "insert into GeoInfo_" + GeoInfoStruct.Ext + " (";
                for (int iLoop = 0; iLoop < Column.Length - 2; ++iLoop)
                {
                    datacmd.GetCommand().CommandText = datacmd.GetCommand().CommandText + Column[iLoop] + ",";
                }
                datacmd.GetCommand().CommandText += "信息更新者姓名) values (@str1, @str2, @str3, @str4,@byte1, @str5, @int1" +
                    ", @bool1, @date1, @str6, @str7)";

                SqlParameter str1 = new SqlParameter("@str1", SqlDbType.NVarChar);
                SqlParameter str2 = new SqlParameter("@str2", SqlDbType.NVarChar);
                SqlParameter str3 = new SqlParameter("@str3", SqlDbType.NVarChar);
                SqlParameter str4 = new SqlParameter("@str4", SqlDbType.NVarChar);
                SqlParameter byte1 = new SqlParameter("@byte1", SqlDbType.Image);
                SqlParameter str5 = new SqlParameter("@str5", SqlDbType.NVarChar);
                SqlParameter int1 = new SqlParameter("@int1", SqlDbType.Int);
                SqlParameter bool1 = new SqlParameter("@bool1", SqlDbType.Bit);
                SqlParameter date1 = new SqlParameter("@date1", SqlDbType.DateTime);
                SqlParameter str6 = new SqlParameter("@str6", SqlDbType.NVarChar);
                SqlParameter str7 = new SqlParameter("@str7", SqlDbType.NVarChar);

                str1.Value = GeoInfoStruct.汽车ID;
                str2.Value = GeoInfoStruct.Car;
                str3.Value = GeoInfoStruct.Factory;
                str4.Value = GeoInfoStruct.Band;

                if (GeoInfoStruct.ByteData != null) { byte1.Value = GeoInfoStruct.ByteData; }
                else { byte1.Value = System.DBNull.Value; }

                str5.Value = GeoInfoStruct.视图;

                int1.Value = GeoInfoStruct.Version;
                bool1.Value = GeoInfoStruct.IsModel;
                date1.Value = GeoInfoStruct.UpdateDate;
                str6.Value = GeoInfoStruct.信息更新者工号;
                str7.Value = GeoInfoStruct.信息更新者姓名;

                datacmd.GetCommand().Parameters.Add(str1);
                datacmd.GetCommand().Parameters.Add(str2);
                datacmd.GetCommand().Parameters.Add(str3);
                datacmd.GetCommand().Parameters.Add(str4);
                datacmd.GetCommand().Parameters.Add(byte1);
                datacmd.GetCommand().Parameters.Add(str5);
                datacmd.GetCommand().Parameters.Add(int1);
                datacmd.GetCommand().Parameters.Add(bool1);
                datacmd.GetCommand().Parameters.Add(date1);
                datacmd.GetCommand().Parameters.Add(str6);
                datacmd.GetCommand().Parameters.Add(str7);

                datacmd.GetCommand().ExecuteNonQuery();
                myTran.Commit();

                if (GeoInfoStruct.IsModel == true)
                {
                    string updatestr = "update GeoInfo_" + GeoInfoStruct.Ext + " set 是否模板 = 'false' where 汽车ID = '" +
                        GeoInfoStruct.汽车ID + "' and 视图 = '" + GeoInfoStruct.视图 + "'  and 版本 <>" + GeoInfoStruct.Version;
                    DatabaseCmd updatedatabase = new DatabaseCmd();
                    updatedatabase.SqlExecuteNonQuery(updatestr);
                }

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                myTran.Rollback();
                return false;
            }
            finally
            {
                myTran.Dispose();
                datacmd.GetCommand().Transaction = null;
                datacmd.GetConnection().Close();
            }
        }
Beispiel #7
0
        private void Upload_Geo_Click(object sender, EventArgs e)
        {
            openFileDialog1.Multiselect = false;
            openFileDialog1.Title = "几何信息导入数据库";
            openFileDialog1.FileName = "几何信息模板.xlsx";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ExcelCmd excelcmd = new ExcelCmd();
                excelcmd.CreateOrOpenExcelFile(false, openFileDialog1.FileName);
                excelcmd.SetActiveSheet(1);

                string[] column = Enum.GetNames(typeof(ColName_VehicleGeo));

                int ExcelRow = excelcmd.GetLastRow(1);

                progressBar.Minimum = 0;
                progressBar.Value = 0;
                progressBar.Maximum = ExcelRow - 1;

                for (int iLoop = 2; iLoop <= ExcelRow; ++iLoop)
                {
                    progressBar.Value++;
                    GeoInfo UpdataGeoInfo = new GeoInfo();

                    UpdataGeoInfo.视图 = (string)excelcmd.GetCell(iLoop, 6);
                    string path = (string)excelcmd.GetCell(iLoop, 5);
                    string filter = Path.GetExtension(path).Substring(1, Path.GetExtension(path).Length - 1);

                    UpdataGeoInfo.Ext = filter;
                    if (UpdataGeoInfo.Ext.ToUpper() == "TMPLT" ||
                            UpdataGeoInfo.Ext.ToUpper() == "LQB" ||
                            UpdataGeoInfo.Ext.ToUpper() == "BWF" ||
                            UpdataGeoInfo.Ext.ToUpper() == "PRT" ||
                            UpdataGeoInfo.Ext.ToUpper() == "STL" ||
                            UpdataGeoInfo.Ext.ToUpper() == "JPG")
                    {
                        UpdataGeoInfo.汽车ID = (string)excelcmd.GetCell(iLoop, 1);
                        UpdataGeoInfo.Car = (string)excelcmd.GetCell(iLoop, 2);
                        UpdataGeoInfo.Band = (string)excelcmd.GetCell(iLoop, 3);
                        UpdataGeoInfo.Factory = (string)excelcmd.GetCell(iLoop, 4);

                        string str = "select top 1 版本 from GeoInfo_" + UpdataGeoInfo.Ext +
                            " where 汽车ID = '" + UpdataGeoInfo.汽车ID + "' and 视图= '" + UpdataGeoInfo.视图 +
                            " 'order by 版本 desc";
                        DatabaseCmd datacmd = new DatabaseCmd();
                        MySqlDataReader myreader;
                        datacmd.SqlExecuteReader(str, out myreader);

                        UpdataGeoInfo.Version = (myreader.Read()) ? (UpdataGeoInfo.Version = myreader.GetInt32(0) + 1) : (1);
                        datacmd.SqlReaderClose();

                        UserFunction.FileToBinary(path, out UpdataGeoInfo.ByteData);
                        UpdataGeoInfo.IsModel = ((string)excelcmd.GetCell(iLoop, 7) == "是") ? (true) : (false);
                        UpdataGeoInfo.UpdateDate = UserFunction.GetServerDateTime();
                        UpdataGeoInfo.信息更新者工号 = ManagementMain.UserNum;
                        UpdataGeoInfo.信息更新者姓名 = ManagementMain.UserName;

                        if (UpdataGeoInfo.ByteData != null)
                        {
                            SqlUploadGeoInfo(column, UpdataGeoInfo, 5);
                        }
                    }
                    else
                    {
                        MessageBox.Show("请上传正确的数据文件");
                    }
                }
                excelcmd.ExitExcelApp();
                MessageBox.Show("导入成功");
                ManagementMain.refreshgeoinfo("", 1);
            }
        }
Beispiel #8
0
        private void ShowInfo(string str, int mode)
        {
            DatabaseCmd datacmd = new DatabaseCmd();

            InfoDataAdapter = null;

            if (mode == 0)
            {
                datacmd.SqlDataTable("Info", str, out InfoDataSet, out InfoDataAdapter);
            }
            else
            {
                datacmd.SqlDataTable("SearchInfo", str, out InfoDataSet, out InfoDataAdapter);
            }
            try
            {
                bindingSource_Info.DataSource = InfoDataSet.Tables[0];
                dataGridView_Info.DataSource = bindingSource_Info;
                bindingNavigator_Info.BindingSource = bindingSource_Info;

                ClearInfoBinding();

                string[] array1 = Enum.GetNames(typeof(ColName_Vehicle));

                int iLoop = 0;
                for (iLoop = 0; iLoop < array1.Length; ++iLoop)
                {
                    txtInfo[iLoop].DataBindings.Add("Text", bindingSource_Info, (string)array1.GetValue(iLoop));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #9
0
        private void ShowGeoInfo(string str, int mode)
        {
            DatabaseCmd datacmd = new DatabaseCmd();

            if (GeoInfoDataSet.Tables["GeoInfo"] != null)
            {
                GeoInfoDataSet.Tables["GeoInfo"].Clear();
            }
            datacmd.SqlDataTable("GeoInfo", str, out GeoInfoDataSet, out GeoInfoDataAdapter);

            try
            {
                bindingSource_GeoInfo.DataSource = GeoInfoDataSet.Tables[0];
                dataGridView_GeoInfo.DataSource = bindingSource_GeoInfo;
                bindingNavigator_GeoInfo.BindingSource = bindingSource_GeoInfo;

                ClearGeoInfoBinding();

                txtGeoInfo[0].DataBindings.Add("Text", bindingSource_GeoInfo, "汽车ID");
                txtGeoInfo[1].DataBindings.Add("Text", bindingSource_GeoInfo, "车型");
                txtGeoInfo[2].DataBindings.Add("Text", bindingSource_GeoInfo, "品牌");
                txtGeoInfo[3].DataBindings.Add("Text", bindingSource_GeoInfo, "厂商");
                txtGeoInfo[4].DataBindings.Add("Text", bindingSource_GeoInfo, "视图");
                txtGeoInfo[5].DataBindings.Add("Text", bindingSource_GeoInfo, "版本");
                txtGeoInfo[6].DataBindings.Add("Text", bindingSource_GeoInfo, "是否模板");
                txtGeoInfo[7].DataBindings.Add("Text", bindingSource_GeoInfo, "信息更新时间");
                txtGeoInfo[8].DataBindings.Add("Text", bindingSource_GeoInfo, "信息更新者工号");
                txtGeoInfo[9].DataBindings.Add("Text", bindingSource_GeoInfo, "信息更新者姓名");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #10
0
        private void dataGridView_Info_SelectionChanged(object sender, EventArgs e)
        {
            DatabaseCmd databasecmd = new DatabaseCmd();
            MySqlDataReader myreader;

            if(dataGridView_Info.RowCount != 0 && dataGridView_Info.Rows[0].Cells[0].Value != null)
            {
                string str = "select count(*) from GeoInfo_BWF where 汽车ID = '"
                + dataGridView_Info.Rows[dataGridView_Info.CurrentRow.Index].Cells[1].Value + "'"
                + " union all "
                + "select count(*) from GeoInfo_LQB where 汽车ID = '"
                + dataGridView_Info.Rows[dataGridView_Info.CurrentRow.Index].Cells[1].Value + "'"
                + " union all "
                + "select count(*) from GeoInfo_TMPLT where 汽车ID = '"
                + dataGridView_Info.Rows[dataGridView_Info.CurrentRow.Index].Cells[1].Value + "'"
                + " union all "
                + "select count(*) from GeoInfo_PRT where 汽车ID = '"
                + dataGridView_Info.Rows[dataGridView_Info.CurrentRow.Index].Cells[1].Value + "'"
                + " union all "
                + "select count(*) from GeoInfo_STL where 汽车ID = '"
                + dataGridView_Info.Rows[dataGridView_Info.CurrentRow.Index].Cells[1].Value + "'"
                + " union all "
                + "select count(*) from GeoInfo_JPG where 汽车ID = '"
                + dataGridView_Info.Rows[dataGridView_Info.CurrentRow.Index].Cells[1].Value + "'";

            databasecmd.SqlExecuteReader(str, out myreader);
            int iLoop = 0;
            while (myreader.Read())
            {
                txtInfo[iLoop + 41].Text = (myreader.GetInt32(0) != 0) ? ("True") : ("False");
                iLoop++;
            }
            databasecmd.SqlReaderClose();
            myreader = null;
            }
        }
Beispiel #11
0
 public static DateTime GetServerDateTime()
 {
     string str = "select getdate() as serverDate";
     DatabaseCmd datacmd = new DatabaseCmd();
     MySqlDataReader myreader;
     try
     {
         datacmd.SqlExecuteReader(str, out myreader);
         if (myreader.Read())
         {
             return myreader.GetDateTime(0);
         }
         else
         {
             return DateTime.Now;
         }
     }
     catch (Exception ex)
     {
         return DateTime.Now;
         MessageBox.Show(ex.Message);
     }
     finally
     {
         datacmd.SqlReaderClose();
     }
 }