Click here to Skip to main content
16,012,223 members

Comments by Member 12896983 (Top 2 by date)

Member 12896983 10-Dec-16 3:59am View    
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace whatsapp
{
public partial class frmRegistration : Form
{
string Password;
public frmRegistration()
{
InitializeComponent();
}

private void btnRequest_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtPhoneNumber.Text))
{
MessageBox.Show("Please enter your Phone Number.","Message",MessageBoxButtons .OK,MessageBoxIcon.Information);
txtPhoneNumber.Focus();
return;

}
if(string.IsNullOrEmpty (txtFullName .Text))
{
MessageBox.Show("Please enter your Full Name.","Message",MessageBoxButtons .OK,MessageBoxIcon.Information);
txtFullName.Focus();
return;

}
if (WhatsAppApi.Register.WhatsRegisterV2.RequestCode(txtPhoneNumber.Text, out Password, "sms"))
{
if (!string.IsNullOrEmpty(Password))
save();
else
{
grpRequestcode.Enabled = false;
grpConfirmCode.Enabled = true;

}
}
else
MessageBox.Show("Could not generate password","Message",MessageBoxButtons .OK,MessageBoxIcon.Information);

}
private void save()
{
this.grpRequestcode.Enabled = false;
this.grpConfirmCode.Enabled = false;
Properties.Settings.Default.PhoneNumber = txtPhoneNumber.Text;
Properties.Settings.Default.Password = Password;
Properties.Settings.Default.FullName = txtFullName.Text;
Properties.Settings.Default.Save();
if (Globals.DB.Accounts.FindByAccountid(txtPhoneNumber.Text) == null)
{
AppData.AccountsRow row = Globals.DB.Accounts.NewAccountsRow();
row.Accountid = txtPhoneNumber.Text;
row.FullName = txtFullName.Text;
row.Password = Password;
Globals.DB.Accounts.AddAccountsRow(row);
Globals.DB.Accounts.AcceptChanges();
Globals.DB.Accounts.WriteXml(string.Format("{0}\\accounts.dat",Application .StartupPath));


}
DialogResult = System.Windows.Forms.DialogResult.OK;
}



private void btnConfirm_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtSms.Text))
{
MessageBox.Show("please enter your sms code","Message",MessageBoxButtons .OK,MessageBoxIcon.Information);
txtSms.Focus();
return;
}
Password = WhatsAppApi.Register.WhatsRegisterV2.RegisterCode(txtPhoneNumber .Text ,txtSms .Text);
save();
}
}
}
Member 12896983 10-Dec-16 3:58am View    
ok I'll show you the full code