private void Createbtn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(IDtxt.Text) || string.IsNullOrEmpty(Nametxt.Text) || string.IsNullOrEmpty(Emailtxt.Text) || string.IsNullOrEmpty(Phonenumbertxt.Text) || string.IsNullOrEmpty(Addresstxt.Text) || string.IsNullOrEmpty(Companytxt.Text) || string.IsNullOrEmpty(VatNotxt.Text)) { return; } ListViewItem item = new ListViewItem(IDtxt.Text); item.SubItems.Add(Nametxt.Text); item.SubItems.Add(Emailtxt.Text); item.SubItems.Add(Phonenumbertxt.Text); item.SubItems.Add(Addresstxt.Text); item.SubItems.Add(Companytxt.Text); item.SubItems.Add(VatNotxt.Text); item.SubItems.Add(Statustxt.Text); listView1.Items.Add(item); IDtxt.Clear(); Nametxt.Clear(); Emailtxt.Clear(); Phonenumbertxt.Clear(); Addresstxt.Clear(); Companytxt.Clear(); VatNotxt.Clear(); IDtxt.Focus(); }
private void button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(Nametxt.Text.ToString()) || string.IsNullOrEmpty(Nametxt.Text.ToString())) { MessageBox.Show("It Isn't vaild !!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string FileName = Nametxt.Text.ToString(); string number = Numattr.Text.ToString(); string FileNameD = FileName; FileName += ".txt"; FileNameD += "D.txt"; FileStream Data = new FileStream(FileNameD, FileMode.Create); FileStream Files = new FileStream("FilesName.txt", FileMode.Append); StreamWriter sw = new StreamWriter(Data); StreamWriter sw1 = new StreamWriter(Files); sw.WriteLine(FileName); sw.WriteLine(number); sw1.WriteLine(FileNameD); sw.Close(); sw1.Close(); Nametxt.Clear(); Numattr.Clear(); this.Close(); th = new Thread(opennewform); th.SetApartmentState(ApartmentState.STA); th.Start(); } }
private void SaveBtn_Click(object sender, EventArgs e) { if (Emailtxt.Text != "") { try { var eMailValidator = new System.Net.Mail.MailAddress(Emailtxt.Text); var result = FormOperations.ValidateFields(Nametxt.Text, Surnametext.Text, GenderCmb.SelectedItem.ToString(), Celltxt.Text); if (result) { DTO.Teacher teacher = new DTO.Teacher(); teacher.Name = Nametxt.Text; teacher.Surname = Surnametext.Text; teacher.Gender = GenderCmb.SelectedItem.ToString(); teacher.Cell = Celltxt.Text; teacher.Email = Emailtxt.Text; teacher.PIN = PINTxt.Text; DataAccess.InsertTeacher(teacher); DialogResult dl = MessageBox.Show("Teacer Saved Successfully. Do You want to Proceesd with another Registration?", "Success", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dl == DialogResult.Yes) { TeacherRegtxt.Clear(); Nametxt.Clear(); Surnametext.Clear(); GenderCmb.ResetText(); Celltxt.Clear(); PINTxt.Clear(); Emailtxt.Clear(); } else { FormOperations.OpenMenu(); this.Close(); } } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (FormatException ex) { MessageBox.Show("The Email entered is not a valid email address", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (Exception ee) { MessageBox.Show(ee.Message); } } else { MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void resetbutton_Click(object sender, EventArgs e) { IDtxt.Clear(); Nametxt.Clear(); DiaChitxt.Clear(); Emailtxt.Clear(); }
private void CPasswordtxt_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Nametxt.Focus(); } }
private void Refresh() { TeacherRegtxt.Clear(); Nametxt.Clear(); Surnametext.Clear(); GenderCmb.ResetText(); Celltxt.Clear(); PINTxt.Clear(); Emailtxt.Clear(); Statuscmb.ResetText(); dataGridView1.DataSource = DataAccess.GetTeachers(); }
public regpage() { List <RegInfo> countrymas = new List <RegInfo>(); List <RegInfo> regionmas = new List <RegInfo>(); List <RegInfo> citymas = new List <RegInfo>(); string site = MainPage.site + "reg.php"; InitializeComponent(); //----------------------------country picer loadpicerCountry(); picker.SelectedIndexChanged += picker_SelectedIndexChanged; pickerreg.SelectedIndexChanged += pickerreg_SelectedIndexChanged; Bregf.Clicked += btregf; //Bprov.Clicked += bprovv; void pickerreg_SelectedIndexChanged(object sender, EventArgs e) { pickercity.Items.Clear(); pickercity.Title = "Загрузка"; pickercity.IsEnabled = false; loadpicercity(int.Parse(regionmas[pickerreg.SelectedIndex].id)); } void picker_SelectedIndexChanged(object sender, EventArgs e) { pickerreg.Items.Clear(); pickerreg.Title = "Загрузка"; pickerreg.IsEnabled = false; pickercity.Items.Clear(); pickercity.Title = "Город"; pickercity.IsEnabled = false; loadpicerRegion(int.Parse(countrymas[picker.SelectedIndex].id)); } ///////////////////////////////////////// Boolean bprovv(string inputstr, int p) { string strPattern = ""; if (p == 1) { strPattern = "[а-яА-Яa-zA-Z][^0-9]"; } if (p == 2) { strPattern = @"^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$"; } if (p == 3) { strPattern = @"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$"; } if (p == 4) { strPattern = "[a-zA-Z0-9]"; } bool y = Regex.IsMatch(inputstr, strPattern); if (y == true) { return(true); } else { return(false); } } async void btregf(object sender, EventArgs e) { if (Nametxt.Text.Length < 1) { await DisplayAlert("Заполните все поля", "Поле 'Имя' не заполнено.", "ОK"); Nametxt.Focus(); } else if (bprovv(Nametxt.Text.Trim(), 1) == false) { await DisplayAlert("Заполните все поля", "Поле 'Имя' заполнено не верно.", "ОK"); Nametxt.Focus(); } else if (Secnametxt.Text.Length < 1) { await DisplayAlert("Заполните все поля", "Поле 'Фамилия' не заполнено.", "ОK"); Secnametxt.Focus(); } else if (bprovv(Nametxt.Text.Trim(), 1) == false) { await DisplayAlert("Заполните все поля", "Поле 'Фамилия' заполнено не верно.", "ОK"); Secnametxt.Focus(); } else if (mail.Text.Length < 1) { await DisplayAlert("Заполните все поля", "Поле 'e-mail' не заполнено.", "ОK"); mail.Focus(); } else if (bprovv(mail.Text.Trim(), 2) == false) { await DisplayAlert("Заполните все поля", "Поле 'e-mail' заполнено не верно.", "ОK"); mail.Focus(); } else if (phone.Text.Length < 1) { await DisplayAlert("Заполните все поля", "Поле 'Телефон' не заполнено.", "ОK"); phone.Focus(); //await DisplayAlert("Уведомление", picker.SelectedIndex.ToString(), "ОK"); } else if (bprovv(phone.Text.Trim(), 3) == false) { await DisplayAlert("Заполните все поля", "Поле 'Телефон' заполнено не верно.", "ОK"); phone.Focus(); } //else if (phone.Text.Length < 10) //{ // await DisplayAlert("Заполните все поля", "Поле 'Телефон' заполнено не верно. ", "ОK"); // phone.Focus(); //} else if (picker.SelectedIndex < 0) { await DisplayAlert("Заполните все поля", "Страна не выбрана", "ОK"); picker.Focus(); } else if (pickerreg.SelectedIndex < 0) { await DisplayAlert("Заполните все поля", "Регион не выбран", "ОK"); pickerreg.Focus(); } else if (pickercity.SelectedIndex < 0) { await DisplayAlert("Заполните все поля", "Город не выбран", "ОK"); pickercity.Focus(); } else if (pastxt.Text.Length < 1) { await DisplayAlert("Заполните все поля", "Поле 'Пароль' не заполнено.", "ОK"); pastxt.Focus(); //await DisplayAlert("Уведомление", picker.SelectedIndex.ToString(), "ОK"); } else if (pasctxt.Text.Length < 1) { await DisplayAlert("Заполните все поля", "Повторите пароль.", "ОK"); pasctxt.Focus(); //await DisplayAlert("Уведомление", picker.SelectedIndex.ToString(), "ОK"); } else if (bprovv(pastxt.Text.Trim(), 4) == false) { await DisplayAlert("Заполните все поля", "Поле 'Пароль' заполнено не верно.", "ОK"); pastxt.Focus(); } else if (bprovv(pasctxt.Text.Trim(), 4) == false) { await DisplayAlert("Заполните все поля", "Поле 'Пароль' заполнено не верно.", "ОK"); pasctxt.Focus(); } else if (pasctxt.Text.Trim() != pasctxt.Text.Trim()) { await DisplayAlert("Заполните все поля", "Пароли не совпадают.", "ОK"); } else { MD5 md5Hasher = MD5.Create(); byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(pastxt.Text.Trim())); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++) { //указывает, что нужно преобразовать элемент в шестнадцатиричную строку длиной в два символа sBuilder.Append(data[i].ToString("x2")); } Bregf.IsEnabled = false; var values = new Dictionary <string, string>(); values.Add("act", "reg"); values.Add("name", Nametxt.Text.Trim()); values.Add("secname", Secnametxt.Text.Trim()); values.Add("mail", mail.Text.Trim()); values.Add("phone", phone.Text.Trim()); values.Add("idcountry", countrymas[picker.SelectedIndex].id); values.Add("idregion", regionmas[pickerreg.SelectedIndex].id); values.Add("idcity", citymas[pickercity.SelectedIndex].id); values.Add("pas", sBuilder.ToString()); values.Add("token", MainPage.tokenF.ToString()); var content = new FormUrlEncodedContent(values); using (var client = new HttpClient()) { try { var httpResponseMessage = await client.PostAsync(site, content); if (httpResponseMessage.StatusCode == HttpStatusCode.OK) { var content1 = await httpResponseMessage.Content.ReadAsStringAsync(); //await DisplayAlert("Уведомление", content1.ToString(), "ОK"); content1 = content1.Remove(0, 1); JObject o = JObject.Parse(content1); var regInfo = JsonConvert.DeserializeObject <RateInfo>(o.ToString()); if (regInfo.err.Length < 1) { await DisplayAlert("Уведомление", "Успешно зарегистрировано. Вам отправлено письмо для подтверждения регистрации", "ОK"); } else { await DisplayAlert("Уведомление", regInfo.err.ToString(), "ОK"); } } } catch (OperationCanceledException) { } catch (Exception) { await DisplayAlert("Уведомление", "Сбой сети", "ОK"); } } Bregf.IsEnabled = true; } } async void loadpicercity(int idcity) { citymas.Clear(); pickercity.IsEnabled = false; pickercity.Title = "Загрузка"; var values = new Dictionary <string, string>(); values.Add("act", "city"); values.Add("idcity", idcity.ToString()); values.Add("token", MainPage.tokenF.ToString()); var content = new FormUrlEncodedContent(values); using (var client = new HttpClient()) { try { var httpResponseMessage = await client.PostAsync(site, content); if (httpResponseMessage.StatusCode == HttpStatusCode.OK) { var content1 = await httpResponseMessage.Content.ReadAsStringAsync(); //await DisplayAlert("Уведомление", content1.ToString(), "ОK"); content1 = content1.Remove(0, 1); JArray o = JArray.Parse(content1); var rateInfo = JsonConvert.DeserializeObject <List <RegInfo> >(o.ToString()); if (rateInfo[0].name != null) { foreach (var c in rateInfo) { pickercity.Items.Add(c.name.ToString()); //await DisplayAlert("Уведомление", c.id.ToString() + " " + c.name.ToString(), "ОK"); citymas.Add(c); } } else { await DisplayAlert("Уведомление", rateInfo[0].err.ToString(), "ОK"); } } } catch (OperationCanceledException) { } catch (Exception) { await DisplayAlert("Уведомление", "Сбой сети", "ОK"); } pickercity.Title = "Город"; pickercity.IsEnabled = true; } } ///////////////////////////////////////// async void loadpicerRegion(int idReg) { regionmas.Clear(); pickerreg.Title = "Загрузка"; pickerreg.IsEnabled = false; var values = new Dictionary <string, string>(); values.Add("act", "region"); values.Add("idreg", idReg.ToString()); values.Add("token", MainPage.tokenF.ToString()); var content = new FormUrlEncodedContent(values); using (var client = new HttpClient()) { try { var httpResponseMessage = await client.PostAsync(site, content); if (httpResponseMessage.StatusCode == HttpStatusCode.OK) { var content1 = await httpResponseMessage.Content.ReadAsStringAsync(); content1 = content1.Remove(0, 1); JArray o = JArray.Parse(content1); var rateInfo = JsonConvert.DeserializeObject <List <RegInfo> >(o.ToString()); if (rateInfo[0].name != null) { foreach (var c in rateInfo) { pickerreg.Items.Add(c.name.ToString()); //await DisplayAlert("Уведомление", c.id.ToString() + " " + c.name.ToString(), "ОK"); regionmas.Add(c); } } else { await DisplayAlert("Уведомление", rateInfo[0].err.ToString(), "ОK"); } } } catch (OperationCanceledException) { } catch (Exception) { await DisplayAlert("Уведомление", "Сбой сети", "ОK"); } pickerreg.Title = "Регион"; pickerreg.IsEnabled = true; } } ////////////////////////////////////////////////////////// async void loadpicerCountry() { countrymas.Clear(); var values = new Dictionary <string, string>(); values.Add("act", "country"); values.Add("token", MainPage.tokenF.ToString()); var content = new FormUrlEncodedContent(values); using (var client = new HttpClient()) { try { var httpResponseMessage = await client.PostAsync(site, content); if (httpResponseMessage.StatusCode == HttpStatusCode.OK) { var content1 = await httpResponseMessage.Content.ReadAsStringAsync(); //await DisplayAlert("fff", content1.ToString(), "ok"); //edn.Text = content1; content1 = content1.Remove(0, 1); JArray o = JArray.Parse(content1); //JObject o = JObject.Parse(content1); //await DisplayAlert("f", o.ToString(),"ok"); var rateInfo = JsonConvert.DeserializeObject <List <RegInfo> >(content1.ToString()); if (rateInfo[0].name != null) { foreach (var c in rateInfo) { picker.Items.Add(c.name.ToString()); countrymas.Add(c); //await DisplayAlert("", c.id + i.id, "jj" ); //i += 1; } } else { await DisplayAlert("Уведомление", rateInfo[0].err.ToString(), "ОK"); } } } catch (OperationCanceledException) { } catch (Exception) { await DisplayAlert("Уведомление", "Сбой сети", "ОK"); } } picker.IsEnabled = true; picker.Title = "Страна"; } }
private void SaveBtn_Click(object sender, EventArgs e) { try { if (kashf_rdiobtn.Checked) { visit_type = "كشف"; } else { visit_type = "استشارة"; } BL.SelectData sel = new BL.SelectData(); DataTable dt = new DataTable(); //dtp = selpat.get_Patientss(); //if (dtp.Rows.Count < 50) //{ BL.InsertData insert_patientdata = new BL.InsertData(); dt = sel.get_Patientss(); DataRow dr = dt.Rows[0]; if (Idtxt.Text == dr["patientID"].ToString()) { insert_patientdata.register_isteshara(Convert.ToInt32(Idtxt.Text), dateTimePicker1.Value.Date, visit_type); MessageBox.Show("add successfuly"); } else { insert_patientdata.add_patient( Convert.ToInt32(Idtxt.Text), Nametxt.Text, Convert.ToInt32(Agetxt.Text), gendercompobox.SelectedItem.ToString(), phonenum.Text, emailtxt.Text, dateTimePicker1.Value.Date, visit_type, Convert.ToInt32(reversnum.Value.ToString()), Convert.ToDecimal(costtxt.Text) ); MessageBox.Show("add successfuly"); ////////////////////////////////////////////////////// Idtxt.Clear(); Nametxt.Clear(); Agetxt.Clear(); phonenum.Clear(); emailtxt.Clear(); } // costtxt.Clear(); //} //else // MessageBox.Show("error =D"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }