private void btnRegister_Click(object sender, EventArgs e) { string a = txtMobileNumber.Text.Insert(0, "84"); a = a.Remove(2, 1); dynamic profile = Helper.DataHelper.Get("profile", Query.EQ("mobile", a)); if (CheckPhoneSupport(txtMobileNumber.Text) == true) { if (CheckIphone(txtMobileNumber.Text) == true) { pin = (long.Parse(DateTime.Now.ToString("ssHHmm")) + 153103).ToString(); var user = new ApplicationUser() { UserName = SessionVariables.CardId }; var result = Helper.UserManager.CreateAsync(user, pin).Result; if (!result.Succeeded) { MessageBox.Show(result.Errors.ToArray()[0], "Thông báo"); return; } else { SessionVariables.MobileNumber = txtMobileNumber.Text; SessionVariables.CardOwner = txtCardHolder.Text; SessionVariables.Email = txtEmail.Text; SessionVariables.Personal_id = txtcmnd.Text; SessionVariables.Address = txtdiachi.Text; dynamic response = Helper.RegisterCard(); string error_code = response.error_code.ToString(); MessageBox.Show(response.error_message.ToString(), "Kết quả đăng ký", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (error_code == "00") { //Cash In here //Helper.CashIn(SessionVariables.CardPrepaidAmount); var cardProfile = Helper.GetProfile(); SessionVariables.ProfileId = cardProfile._id; SessionVariables.FinanceAccount = Helper.GetAccountInfo(); SessionVariables.IsActived = true; SessionVariables.IsRegister = true; Helper.RegisterWalletToCard(); this.DialogResult = DialogResult.OK; print(); } else { this.DialogResult = DialogResult.Cancel; } } } else { DialogResult dialogResult = MessageBox.Show("số điện thoại đã tồn tại bạn muốn tiếp tục đăng ký !", "Kết quả đăng ký", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (dialogResult == DialogResult.Yes) { pin = (long.Parse(DateTime.Now.ToString("ssHHmm")) + 153103).ToString(); var user = new ApplicationUser() { UserName = SessionVariables.CardId }; var result = Helper.UserManager.CreateAsync(user, pin).Result; if (!result.Succeeded) { MessageBox.Show(result.Errors.ToArray()[0], "Thông báo"); return; } else { //Cash In here SessionVariables.MobileNumber = txtMobileNumber.Text; SessionVariables.CardOwner = txtCardHolder.Text; SessionVariables.Email = txtEmail.Text; SessionVariables.Personal_id = txtcmnd.Text; SessionVariables.Address = txtdiachi.Text; dynamic response = Helper.RegisterCard(); Helper.CashIn(SessionVariables.CardPrepaidAmount); if (profile != null) { SessionVariables.ProfileId = profile._id; profile.user_name = SessionVariables.CardId; Helper.DataHelper.SaveUpdate("profile", profile); } SessionVariables.FinanceAccount = Helper.GetAccountInfo(); SessionVariables.IsActived = true; SessionVariables.IsRegister = true; Helper.RegisterWalletToCard(); this.DialogResult = DialogResult.OK; print(); } } else if (dialogResult == DialogResult.No) { MessageBox.Show("bạn đã huỷ đăng ký thành công !", "Kết quả đăng ký", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); } } } else { MessageBox.Show("số điện thoại không đúng, xin mời nhập lại !", "Kết quả đăng ký", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); } }
private void btnRegister_Click(object sender, EventArgs e) { string a = txtMobileNumber.Text.Insert(0, "84"); a = a.Remove(2, 1); dynamic profile = Helper.DataHelper.Get("profile", Query.EQ("mobile", a)); try { if (CheckPhoneSupport(txtMobileNumber.Text) == true) { if (txtEmail.Text != "") { if (IsValidEmail(txtEmail.Text) == true) { pin = (long.Parse(DateTime.Now.ToString("ssHHmm")) + 153103).ToString(); var user = new ApplicationUser() { UserName = SessionVariables.CardId }; var result = Helper.UserManager.CreateAsync(user, pin).Result; if (!result.Succeeded) { MessageBox.Show(result.Errors.ToArray()[0], "Thông báo"); return; } else { SessionVariables.MobileNumber = txtMobileNumber.Text.Trim(); SessionVariables.CardOwner = (String.IsNullOrEmpty(txtCardHolder.Text.Trim())) ? "THẺ CHƯA ĐỊNH DANH" : txtCardHolder.Text.Trim(); SessionVariables.Email = txtEmail.Text.Trim(); SessionVariables.Personal_id = txtcmnd.Text; SessionVariables.Address = txtdiachi.Text; dynamic response = Helper.RegisterCard(); string error_code = response.error_code.ToString(); MessageBox.Show(response.error_message.ToString(), "Kết quả đăng ký", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (error_code == "00") { Helper.CashIn(SessionVariables.CardPrepaidAmount); var cardProfile = Helper.GetProfile(); SessionVariables.ProfileId = cardProfile._id; SessionVariables.FinanceAccount = Helper.GetAccountInfo(); SessionVariables.IsActived = true; SessionVariables.IsRegister = true; Helper.RegisterWalletToCard(); dynamic pr = Helper.DataHelper.Get("profile", Query.EQ("_id", SessionVariables.ProfileId)); if (pr != null) { pr.email = SessionVariables.Email; pr.personal_id = SessionVariables.Personal_id; pr.address = SessionVariables.Address; pr.Pin = 1; Helper.DataHelper.SaveUpdate("profile", pr); } this.DialogResult = DialogResult.OK; Helper.AddLogCard("Register", "Đăng ký Thành công", SessionVariables.FinanceAccount.available_balance, SessionVariables.FinanceAccount.available_balance, 0, SessionVariables.CounterName, "null"); print(); } else { this.DialogResult = DialogResult.Cancel; } } } else { DialogResult comfirm = MessageBox.Show("Địa chỉ email không hợp lệ, xin mời nhập lại !", "Kết quả đăng ký", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (comfirm == DialogResult.No) { this.Close(); } else if (comfirm == DialogResult.Yes) { txtEmail.Text = ""; return; } } } else { pin = (long.Parse(DateTime.Now.ToString("ssHHmm")) + 153103).ToString(); var user = new ApplicationUser() { UserName = SessionVariables.CardId }; var result = Helper.UserManager.CreateAsync(user, pin).Result; if (!result.Succeeded) { MessageBox.Show(result.Errors.ToArray()[0], "Thông báo"); return; } else { SessionVariables.MobileNumber = txtMobileNumber.Text.Trim(); SessionVariables.CardOwner = (String.IsNullOrEmpty(txtCardHolder.Text.Trim())) ? "THẺ CHƯA ĐỊNH DANH" : txtCardHolder.Text.Trim(); //SessionVariables.Email = txtEmail.Text.Trim(); SessionVariables.Personal_id = txtcmnd.Text; SessionVariables.Address = txtdiachi.Text; dynamic response = Helper.RegisterCard(); string error_code = response.error_code.ToString(); MessageBox.Show(response.error_message.ToString(), "Kết quả đăng ký", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); if (error_code == "00") { Helper.CashIn(SessionVariables.CardPrepaidAmount); var cardProfile = Helper.GetProfile(); SessionVariables.ProfileId = cardProfile._id; SessionVariables.FinanceAccount = Helper.GetAccountInfo(); SessionVariables.IsActived = true; SessionVariables.IsRegister = true; Helper.RegisterWalletToCard(); dynamic pr = Helper.DataHelper.Get("profile", Query.EQ("_id", SessionVariables.ProfileId)); if (pr != null) { //pr.email = SessionVariables.Email; pr.personal_id = SessionVariables.Personal_id; pr.address = SessionVariables.Address; pr.Pin = 1; Helper.DataHelper.SaveUpdate("profile", pr); } this.DialogResult = DialogResult.OK; Helper.AddLogCard("Register", "Đăng ký Thành công", SessionVariables.FinanceAccount.available_balance, SessionVariables.FinanceAccount.available_balance, 0, SessionVariables.CounterName, "null"); print(); } else { this.DialogResult = DialogResult.Cancel; } } } } else { DialogResult comfirm = MessageBox.Show("Số điện thoại không đúng, xin mời nhập lại !", "Kết quả đăng ký", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); if (comfirm == DialogResult.No) { this.Close(); } else if (comfirm == DialogResult.Yes) { txtMobileNumber.Text = ""; return; } } } catch (Exception ex) { } }