private void button1_Click(object sender, EventArgs e) { string start_time = dataGridView1.Rows[this.index].Cells[1].Value.ToString(); start_time = "是否还原到" + start_time + "的备份"; if (MessageBox.Show(start_time, "提醒", MessageBoxButtons.YesNo) == DialogResult.Yes) { Console.WriteLine("成功了"); string file_name = dataGridView1.Rows[this.index].Cells[0].Value.ToString(); string cur_dict = System.IO.Directory.GetCurrentDirectory(); DirectoryInfo d_info = new DirectoryInfo(cur_dict + "\\backup\\" + file_name); FileInfo file = new FileInfo(cur_dict + "\\backup\\" + file_name); //filename是sql脚本文件路径。 string sql = file.OpenText().ReadToEnd(); Maticsoft.BLL.baseconfig bf = new Maticsoft.BLL.baseconfig(); bf.backup(sql); MessageBox.Show(sql); } Console.WriteLine("取消了"); }
private void login4_Load(object sender, EventArgs e) { // 设置logo string cur_dict = System.IO.Directory.GetCurrentDirectory(); System.IO.FileStream fs = new System.IO.FileStream(cur_dict + "\\images\\configimg\\logo1.png", System.IO.FileMode.Open, System.IO.FileAccess.Read); pictureBox1.Image = System.Drawing.Image.FromStream(fs); fs.Close(); //string cur_dict = System.IO.Directory.GetCurrentDirectory(); //System.IO.FileStream fs2 = new System.IO.FileStream(, System.IO.FileMode.Open, System.IO.FileAccess.Read); this.BackgroundImage = System.Drawing.Image.FromFile(cur_dict + "\\images\\configimg\\bg.png"); // fs2.Close(); Maticsoft.BLL.baseconfig config_bll = new Maticsoft.BLL.baseconfig(); //config_bll.backup(); int count = config_bll.GetRecordCount(""); if (count <= 0) { MessageBox.Show("未激活"); baseconfig bc_xin = new baseconfig { companyName = "test", expTime = DateTime.Now.AddMonths(7), version = "0.1", startTime = DateTime.Now, }; if (config_bll.Add(bc_xin)) { MessageBox.Show("试用版激活成功"); } else { MessageBox.Show("激活失败"); System.Environment.Exit(0); } return; } else if (count == 1) { //MessageBox.Show(""); List <baseconfig> bc_list = config_bll.GetModelList(""); //MessageBox.Show("exptime ====== datetime " + bc_list[0].expTime.ToString() + DateTime.Now.ToString()); global.startTime = (DateTime)bc_list[0].startTime; if (bc_list[0].expTime > DateTime.Now) { MessageBox.Show("使用期限" + bc_list[0].expTime); string boardid = GetSystemInfo.GetMotherBoardID(); string mac = GetSystemInfo.GetMacAddress(); if (boardid == "" || mac == "") { MessageBox.Show("主板或者mac地址信息缺失"); System.Environment.Exit(0); } MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); string source = boardid + "HelloWorld" + mac; byte[] message; message = Encoding.Default.GetBytes(source); md5.ComputeHash(message); //Console.WriteLine(Convert.ToBase64String(md5.Hash)); global.MachineID = Convert.ToBase64String(md5.Hash); //MessageBox.Show(Convert.ToBase64String(md5.Hash)); } else { MessageBox.Show("已经过期了,无法继续使用"); MessageBox.Show("配置不正确, 请联系管理员"); System.Environment.Exit(0); } } else { MessageBox.Show("配置不正确, 请联系管理员"); System.Environment.Exit(0); return; } Maticsoft.BLL.workstation ws = new Maticsoft.BLL.workstation(); Maticsoft.Model.workstation ws_mode = ws.GetModel(global.MachineID); if (ws_mode != null) { } else { String str = Interaction.InputBox("请输入本机编号", "请输入编号", "", -1, -1); if (str == "") { System.Environment.Exit(0); return; } ws_mode = new workstation { workid = global.MachineID, remark = str, workstationname = str }; ws.Add(ws_mode); } global.workid = "工作站编号:" + ws_mode.workstationname; label2.Text = "工作站编号:" + ws_mode.workstationname; }