private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show("Vui lòng nhập username", "Thông Báo"); return; } if (textBox2.Text == "") { MessageBox.Show("Vui lòng nhập password", "Thông Báo"); return; } FbAccount fb = new FbAccount(); string token = "", account = "", password = ""; if (radioButton1.Checked) { (new Waiting(() => fb = Facebook.Login(textBox1.Text, textBox2.Text))).ShowDialog(); token = fb.token; account = fb.account; password = fb.password; } else { token = txtToken.Text; account = textBox1.Text; password = textBox2.Text; } List <FbAccount> fbAccounts = SQLDatabase.LoadFbAccount(string.Format("select * from FbAccount where account='{0}'", textBox1.Text)); if (fbAccounts.Count == 0) { SQLDatabase.AddFbAccount(new FbAccount() { account = account, password = password, token = token, IsAct = true }); } else { SQLDatabase.UpdateFbAccount(new FbAccount() { account = account, password = password, token = token, IsAct = true }); } /*goi hàm kiễm tra lại trạng thái token có vươc gioi han soa chưa?*/ this.DialogResult = DialogResult.OK; this.Close(); }
public MainWindow() { InitializeComponent(); try { FbAccount fbAccount = new FbAccount() { UserId = "2641545616", Username = "******", Email = "anys.com", Password = "******", LoginStatus = "Not Logged In", LogoSource = "sdfsfbi54d" }; DBConnector.AddData(fbAccount); } catch (Exception ex) { } }
public static string Token(object arrControl) { FbAccount fbAccount = new FbAccount(); try { ArrayList arr1 = (ArrayList)arrControl; System.Windows.Forms.Label lblMessage1 = (System.Windows.Forms.Label)arr1[0]; System.Windows.Forms.Label lblMessage2 = (System.Windows.Forms.Label)arr1[1]; System.Windows.Forms.Label lblSluongGoi = (System.Windows.Forms.Label)arr1[2]; TextBox txtToken = (TextBox)arr1[3]; CheckBox chkMe = (CheckBox)arr1[4]; CheckBox chkBanBe = (CheckBox)arr1[5]; CheckBox chkBaiViet = (CheckBox)arr1[6]; System.Windows.Forms.Label lblQuataDaDung = (System.Windows.Forms.Label)arr1[7]; System.Windows.Forms.Label lblQuataConLai = (System.Windows.Forms.Label)arr1[8]; DataTable tb = SQLDatabase.ExcDataTable("spToken"); if (tb.Rows.Count == 0) { return(""); } fbAccount.id = (Guid)tb.Rows[0]["id"]; fbAccount.account = tb.Rows[0]["account"].ToString(); fbAccount.password = tb.Rows[0]["password"].ToString(); fbAccount.token = tb.Rows[0]["token"].ToString(); fbAccount.IsAct = Convert.ToBoolean(tb.Rows[0]["IsAct"].ToString()); fbAccount.SoLuong = ConvertType.ToInt(tb.Rows[0]["sl"].ToString()); fbAccount.maxx = ConvertType.ToInt(tb.Rows[0]["maxx"].ToString()); /*update UI*/ txtToken.Invoke((Action) delegate { txtToken.Text = fbAccount.token; txtToken.Update(); }); lblQuataDaDung.Invoke((Action) delegate { lblQuataDaDung.Text = string.Format("{0:#,#.}", fbAccount.SoLuong); lblQuataDaDung.Update(); }); lblQuataConLai.Invoke((Action) delegate { lblQuataConLai.Text = string.Format("{0:#,#.}", fbAccount.maxx - fbAccount.SoLuong); lblQuataConLai.Update(); }); lblSluongGoi.Invoke((Action) delegate { lblSluongGoi.Text = string.Format("{0:#,#.}", fbAccount.maxx); lblSluongGoi.Update(); }); return(fbAccount.token); } catch (Exception ex) { return(fbAccount.token); } }