예제 #1
0
        private void runClosedCommand()
        {
            int       a   = 0;
            DataTable dt3 = sql.ExecuteQuery("select count(1) from userTB where userpower=3");
            int       i   = Convert.ToInt32(dt3.Rows[0][0].ToString());

            if (i > 0)
            {
                //已经创建了普通用户,临时用户可以销毁
                int rownum = sql.ExecuteNonQuery("delete from userTB where username='******' and passwd='123456'");
                Console.WriteLine(rownum);
            }
        }
        private void NewUserCommandHandler(object obj)
        {
            MessageBox.Show("UserId= " + TxtUserId + Environment.NewLine + "Password= "******":" + TxtPassword;
            SqLiteHelper sql1       = new SqLiteHelper();
            string       query      = "INSERT INTO TblLogin(FbUserName,FbPassword) values('" + TxtUserId + "','" + TxtPassword + "')";

            int yy = sql.ExecuteNonQuery(query);

            BindListView();
        }
예제 #3
0
        private void NewUserCommandHandler(object obj)
        {
            if (!string.IsNullOrWhiteSpace(TxtUserId) && !string.IsNullOrWhiteSpace(TxtPassword))
            {
                string Credential = TxtUserId + ":" + TxtPassword;

                SqLiteHelper sql1 = new SqLiteHelper();


                string query1 = "select Count(*) from Users where UserName='******'";

                int count = Convert.ToInt32(sql1.ExecuteScalar(query1));


                if (TxtUserId != null && TxtPassword != null)
                {
                    if (count == 0)
                    {
                        string query = "INSERT INTO Users(UserName,Password,FacebookId) values('" + TxtUserId + "','" + TxtPassword + "','" + TxtUserId + TxtPassword + "')";

                        int yy = sql.ExecuteNonQuery(query);

                        NewUserNameInfoList.Add(new FacebookUserLoginInfo {
                            LoginUserName = TxtUserId
                        });
                        MessageBox.Show("Save successfully");
                    }
                }



                UserAdded(new SocialUser {
                    InboxUserName = TxtUserId, Password = TxtPassword
                });
                //UserAdded(new SocialUser { InboxUserName = TxtUserId });
                TxtUserId   = null;
                TxtPassword = null;
            }
            else
            {
                MessageBox.Show("Please enter valid username and password..!");
            }
        }
        public static void InsertFacebookCommentToDb(List <FbUserMessageInfo> messagingFbpageListInfo)
        {
            for (int i = 0; i < messagingFbpageListInfo.Count; i++)
            {
                var chatFb        = messagingFbpageListInfo[i].Message;
                var imagesrcFb    = messagingFbpageListInfo[i].loginguserimage;
                var otherimagesrc = messagingFbpageListInfo[i].otheruserimage;

                string       query1 = "select Count(*) from TblJobFb where Message='" + chatFb + "'and ImageSource='" + imagesrcFb + "'";
                SqLiteHelper sql1   = new SqLiteHelper();
                int          count  = Convert.ToInt32(sql1.ExecuteScalar(query1));

                if (count == 0)
                {
                    string       query = "INSERT INTO TblJobFb(PlateformType,Message,ImageSource) values('1" + "','" + chatFb + "','" + imagesrcFb + "')";
                    SqLiteHelper sql   = new SqLiteHelper();
                    int          yy    = sql.ExecuteNonQuery(query);
                }
            }
        }
예제 #5
0
        public static void Test()
        {
            //Ïà¶Ô·¾¶
            SqLiteHelp help = new SqLiteHelp(@"..\..\..\Doc\aa.db");
            string     sql  = "select * from TableTest";
            var        aa   = help.DbConnection.Query(sql);


            string insertSql = "insert into TableTest(col1, col2) values(@col1, @col2)";

            //using dapper
            var i = help.DbConnection.Execute(insertSql, new { col1 = "aa", col2 = "bb" });


            //using helper
            var paramss = new OleDbParameter[] { new OleDbParameter("@col1", "aa"), new OleDbParameter("@col2", "bb") };

            SqLiteHelper.ExecuteNonQuery(help.DbConnection.ConnectionString, insertSql, new object[] { "cc", "cc" });

            var count = help.RetriveDataSet(sql);
        }
예제 #6
0
        private void runLoginCommand(Login window)
        {
            if (Passwd == null || Username == null)
            {
                return;
            }
            if (isGen2)
            {
                if (Passwd == "guest" && Username == "guest")
                {
                    //客户权限
                    //五个权限分别对应实时信息、配置页面(读取配置和更改配置其中一个可见即为可见)、读取配置、更改配置、追溯码
                    Gen2MainWindow m = new Gen2MainWindow(new string[] { "Visible", "Hidden", "Hidden", "Hidden", "Hidden" });
                    m.Show();
                    window.Hide();
                }
                else if (Passwd == "production" && Username == "production")
                {
                    //产线
                    Gen2MainWindow m = new Gen2MainWindow(new string[] { "Visible", "Visible", "Visible", "Hidden", "Visible" });
                    m.Show();
                    window.Hide();
                }
                else if (Passwd == "ruineng" && Username == "ruineng")
                {
                    //锐能
                    Gen2MainWindow m = new Gen2MainWindow(new string[] { "Visible", "Visible", "Visible", "Visible", "Hidden" });
                    m.Show();
                    window.Hide();
                }
                else if (Passwd == "aftermarket" && Username == "aftermarket")
                {
                    Gen2MainWindow m = new Gen2MainWindow(new string[] { "Visible", "Visible", "Visible", "Visible", "Visible" });
                    m.Show();
                    window.Hide();
                }
                else if (Passwd == "abc@123" && Username == "Gotion")
                {
                    Gen2MainWindow m = new Gen2MainWindow(new string[] { "Visible", "Visible", "Visible", "Visible", "Visible" });
                    m.Show();
                    window.Hide();
                }
                else
                {
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        ModernDialog.ShowMessage("用户名或密码错误", "提示", MessageBoxButton.OK);
                    });
                    return;
                }
            }
            else if (isGen3)
            {
                if (Passwd == "master" && Username == "master")
                {
                    //超级用户
                    ////DataTable dt=sql.ExecuteQuery("select times from userTB where username='******'");
                    //登录次数
                    // int count = Convert.ToInt32(dt.Rows[0][0].ToString());
                    //  String pwd = PasswordBuilder.calPwdByTimes('master',count);

                    window.Hide();
                    if (isGen3)
                    {
                        MainWindow m = new MainWindow(new string[] { "Visible", "Visible", "Visible", "Visible", "Visible" }, 0);
                        m.Show();
                    }
                    //else if (isGen2) {
                    //    Gen2MainWindow m = new Gen2MainWindow();
                    //    m.Show();
                    //}
                    //AddUser m = new AddUser(0);
                    //m.Show();
                }
                else
                {
                    DataTable result = sql.ExecuteQuery("select * from userTB where username=@username and passwd=@passwd",
                                                        new Dictionary <string, string>()
                    {
                        { "@username", Username }, { "@passwd", Passwd }
                    });
                    bool ifHasRows = (result.Rows.Count != 0);
                    User u         = new User();
                    if (ifHasRows)
                    {
                        u.Username  = result.Rows[0]["username"].ToString();
                        u.Passwd    = result.Rows[0]["passwd"].ToString();
                        u.Itemlist  = result.Rows[0]["itemlist"].ToString();
                        u.Times     = Convert.ToInt32(result.Rows[0]["times"].ToString());
                        u.Userpower = Convert.ToInt32(result.Rows[0]["userpower"].ToString());
                    }
                    if (ifHasRows)
                    {
                        //登陆成功
                        if (u.Username == "admin")
                        {
                            //临时用户登陆
                            sql.ExecuteNonQuery("update userTB set times=(select times from userTB where username='******')+1 where username='******'");
                            //弹出建立用户界面
                            //window.Hide();
                            AddUser m = new AddUser(2);
                            m.Show();
                        }
                        else
                        {
                            //普通用户或管理员登陆

                            sql.ExecuteNonQuery("update userTB set times=(select times from userTB where username=@username)+1 where username=@username;",
                                                new Dictionary <string, string> {
                                { "@username", Username }
                            });

                            if (u.Userpower == 1)
                            {
                                //管理员登陆
                                string[] sArray = u.Itemlist.ToString().Split(',');
                                for (int i = 0; i < sArray.Length; i++)
                                {
                                    sArray[i] = sArray[i] == "0" ? "Hidden" : "Visible";
                                }
                                window.Hide();
                                MainWindow m = new MainWindow(sArray, 1);
                                m.Show();
                            }
                            else if (u.Userpower == 3)
                            {
                                //普通用户登陆
                                string[] sArray = u.Itemlist.ToString().Split(',');
                                for (int i = 0; i < sArray.Length; i++)
                                {
                                    sArray[i] = sArray[i] == "0" ? "Collapsed" : "Visible";
                                }
                                window.Hide();
                                MainWindow m = new MainWindow(sArray, 3);
                                m.Show();
                            }
                        }
                    }
                    else
                    {
                        //登陆失败
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            ModernDialog.ShowMessage("用户名或密码错误", "提示", MessageBoxButton.OK);
                        });
                        return;
                    }
                }
            }
            else if (IsUDS)
            {
                if (Passwd == "master" && Username == "master")
                {
                    window.Hide();
                    UDSTestMainWindow m = new UDSTestMainWindow();
                    m.Show();
                }
            }
            else if (IsTooling)
            {
                if (Passwd == "abc@123" && Username == "GotionTooling")
                {
                    window.Hide();
                    ToolingMainWindow m = new ToolingMainWindow();
                    m.Show();
                }
            }
        }