예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            CUserAccount user = new CUserAccount(txtUserName.Text, txtPassword.Text);

            foreach (DataGridViewRow r in gridUser.Rows)
            {
                if (r.Cells["colUser"].Value != null && r.Cells["colPass"].Value != null && r.Cells["colJobCount"].Value != null && r.Cells["colFaceCount"].Value != null)
                {
                    int job = 0;
                    if (r.Cells["colUser"].Value.ToString() == "-1" || r.Cells["colUser"].Value.ToString() == "" || r.Cells["colPass"].Value.ToString() == "" ||
                        Int32.TryParse(r.Cells["colJobCount"].Value.ToString(), out job) == false || Int32.TryParse(r.Cells["colFaceCount"].Value.ToString(), out job) == false)
                    {
                        MessageBox.Show(this, "Hay kiem tra lai tai khoan FB", "Web Auto - Sai du lieu", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                    user.addLinkAccount(r.Cells["colAccount"].Value.ToString(), r.Cells["colUser"].Value.ToString(), r.Cells["colPass"].Value.ToString(), Int32.Parse(r.Cells["colJobCount"].Value.ToString()), Int32.Parse(r.Cells["colFaceCount"].Value.ToString()), (bool)(r.Cells["colEnable"].Value), Int32.Parse(r.Cells["colMaxGoLike"].Value.ToString()), Int32.Parse(r.Cells["colMaxLink"].Value.ToString()));
                }
            }
            try
            {
                user.GoLikeDelay1       = Int32.Parse(txtGolikeDelay1.Text);
                user.FBDelay1           = Int32.Parse(txtFBDelay1.Text);
                user.LimitFault         = Int32.Parse(txtFaultLimit.Text);
                user.EnableRedoJob      = chkEnableRedo.Checked;
                user.JobLessMoney       = chkJobLessMoney.Checked;
                user.CheckLinkCondition = chkLinkCondition.Checked;
            }
            catch (Exception ii)
            {
                MessageBox.Show(this, "Hay kiem tra lai thoi gian.", "Web Auto - Sai du lieu", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            string file = "";

            using (SaveFileDialog openFileDialog = new SaveFileDialog())
            {
                openFileDialog.InitialDirectory = Environment.CurrentDirectory + "\\profile";
                openFileDialog.Filter           = "Web Auto (*.wbq)|*.wbq|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 1;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    file = openFileDialog.FileName;
                }
            }
            if (file != "")
            {
                using (System.IO.StreamWriter fileIO = new System.IO.StreamWriter(file))
                {
                    fileIO.Write(user.EndCode());
                }
            }
        }
 public ActionResult Register(CUserAccount user)
 {
     if (ModelState.IsValid)
     {
         using (AccountDbContext db = new AccountDbContext())
         {
             db.userAccounts.Add(user);
             db.SaveChanges();
         }
         ModelState.Clear();
         ViewBag.Msg = user.fName + "註冊成功!!";
     }
     return(View());
 }
 public ActionResult Login(CUserAccount user)
 {
     using (AccountDbContext db = new AccountDbContext())
     {
         var account = db.userAccounts.Single(a => a.fUserName == user.fUserName && a.fPassword == user.fPassword);
         if (account != null)
         {
             Session["UserId"]   = account.fUserId.ToString();
             Session["UserName"] = account.fUserName.ToString();
             return(RedirectToAction("LoggedIn"));
         }
         else
         {
             ModelState.AddModelError("", "使用者名稱或密碼錯誤");
         }
     }
     return(View());
 }