Exemple #1
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtZerenren1.Text.Trim()))
            {
                MessageBox.Show("登录用户不许为空!", "软件提示");

                return;
            }

            if (String.IsNullOrEmpty(txtPwd.Text))
            {
                MessageBox.Show("登录密码不许为空!", "软件提示");
                txtPwd.Focus();
                return;
            }
            //用户编码不重复
            string strSql = "select * from tb_operator where 用户名 = '" + txtZerenren1.Text.Trim() + "'";

            if (Convert.ToString(SQLhelp.ExecuteScalar(strSql, CommandType.Text)) == "")
            {
                MessageBox.Show("登录用户不正确!", "软件提示");

                return;
            }
            try
            {
                DataTable dt = SQLhelp.GetDataTable(strSql, CommandType.Text);
                DataRow   dr = dt.Rows[0];



                string a = dt.Rows[0]["用户名"].ToString(); //用户名


                string ce = dt.Rows[0]["密码"].ToString();


                if (txtPwd.Text != dt.Rows[0]["密码"].ToString())  //若密码不相同
                {
                    MessageBox.Show("登录密码不正确!", "软件提示");
                    txtPwd.Focus();
                }
                else
                {
                    String  Triton  = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    version version = new version();
                    if (version.pluto(Triton, "zttoffice") && judgedepartment(a))
                    {
                        downloadexe downloadexe = new downloadexe();
                        downloadexe.ShowDialog();
                        this.Close();
                    }
                    else if (version.pluto1(Triton))
                    {
                        version.setprocess();
                    }

                    else
                    {
                        BonusSkins.Register();
                        SkinManager.EnableFormSkins();
                        UserLookAndFeel.Default.SetSkinStyle("Office 2010 Blue");  // 设置皮肤样式
                        getdevice getdevice = new getdevice();
                        getData   getData   = new getData();
                        //string s = Convert.ToDateTime(getData.getservertime());
                        Dictionary <string, string> dty = getdevice.getdevice1();
                        //getdevice.readdata(dt.Rows[0]["用户名"].ToString());
                        string sql = "insert into tb_denglu (登录人,登录时间,mac号,cpuid,硬盘序号,操作系统,内外网,公网ip,内网ip,显卡信息,机子类型,版本号) values('" + dt.Rows[0]["用户名"].ToString() + "','" + Convert.ToDateTime(getData.getservertime())
                                     + "','" + dty["mac号"] + "','" + dty["cpuid"] + "','" + dty["硬盘序号"] + "','" + dty["操作系统"] + "','" + dty["内外网"] + "','" + dty["公网ip"] + "','" + dty["内网ip"] + "','" + dty["显卡信息"] + "','" + dty["机子类型"] + "','" + Triton + "')";
                        xiangmusql.ExecuteScalar(sql, CommandType.Text);

                        aa.yonghu = dt.Rows[0]["用户名"].ToString();
                        Properties.Settings.Default.isrem = this.checkbox1.Checked;
                        Properties.Settings.Default.name  = this.txtZerenren1.Text;
                        Properties.Settings.Default.Save();

                        byte[]     byData   = new byte[100];
                        char[]     charData = new char[1000];
                        FileStream file     = new FileStream(Application.StartupPath + "\\提示.txt", FileMode.Open);
                        file.Seek(0, SeekOrigin.Begin);
                        file.Read(byData, 0, 100);
                        Decoder d = Encoding.Default.GetDecoder();
                        d.GetChars(byData, 0, byData.Length, charData, 0);

                        file.Close();

                        FileStream fs = new FileStream(Application.StartupPath + "\\提示.txt", FileMode.Open);
                        //获得字节数组
                        byte[] data = System.Text.Encoding.Default.GetBytes("1");
                        //开始写入
                        fs.Write(data, 0, data.Length);
                        //清空缓冲区、关闭流
                        fs.Flush();
                        fs.Close();
                        if (charData[0].ToString() == "0")
                        {
                            Frtishi form1 = new Frtishi();
                            form1.yonghu = dt.Rows[0]["用户名"].ToString();
                            form1.Show();
                            this.Hide();
                        }

                        string    sql3 = "select mac号 from tb_mac where mac号='" + dty["mac号"] + "'";
                        DataTable dt1  = xiangmusql.GetDataTable(sql3, CommandType.Text);
                        if (dt1.Rows.Count < 1)
                        {
                            Frtishi1 Frtishi1 = new Frtishi1(dty["mac号"]);
                            Frtishi1.ShowDialog();
                        }
                        else
                        {
                            if (charData[0].ToString() == "1")
                            {
                                aa.Show();
                                this.Hide();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "软件提示");
            }
        }