예제 #1
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();
     }
 }
예제 #2
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();
     }
 }
예제 #3
0
파일: Login.cs 프로젝트: zhaoziy/Project_Li
 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;
     }
 }
예제 #4
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();
            }
        }
예제 #5
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);
            }
        }
예제 #6
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;
            }
        }
예제 #7
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();
     }
 }