private void materialRaisedButton1_Click(object sender, EventArgs e) { string room1 = materialSingleLineTextField6.Text; FileStream ambildata1 = new FileStream("Room.txt", FileMode.Open, FileAccess.Read); StreamReader bacadata1 = new StreamReader(ambildata1); string linee = bacadata1.ReadLine(); while (linee != null) { // Console.Clear(); string[] dataroom = linee.Split('#'); if (room1 == dataroom[0]) { dataroom0 = dataroom[0]; dataroom1 = dataroom[1]; dataroom2 = dataroom[2]; dataroom3 = dataroom[3]; dataroom4 = dataroom[4]; dataroom5 = dataroom[5]; } else { } linee = bacadata1.ReadLine(); } bacadata1.Close(); ambildata1.Close(); if (room1 == dataroom0) { //Load Data declaredata(); //Membersihkan Error errorProvider1.Clear(); //Check Data Kosong if (RoomNumber.Trim().Length != 0) { if (comboBox1.Text != "- Select Room Class -") { if (Capacityroom.Trim().Length != 0) { if (Price.Trim().Length != 0) { if (comboBox2.Text != "- Select Room Status -") { if (comboBox3.Text != "- Select Room Condition -") { string old = dataroom0 + "#" + dataroom1 + "#" + dataroom2 + "#" + dataroom3 + "#" + dataroom4 + "#" + dataroom5 + "#"; string neww = RoomNumber + "#" + Roomclass + "#" + Capacityroom + "#" + Price + "#" + Roomstatus + "#" + Roomcondition + "#"; string update = File.ReadAllText("Room.txt"); update = update.Replace(old, neww); File.WriteAllText("Room.txt", update); MessageBox.Show("Data has been updated.", "SUCCESS!"); this.Hide(); var tc = new Technic(); tc.Closed += (s, args) => this.Close(); tc.Show(); } else { errorProvider1.SetError(comboBox3, "Please select room condition!"); } } else { errorProvider1.SetError(comboBox2, "Please select room status!"); } } else { errorProvider1.SetError(materialSingleLineTextField3, "Must be filled!"); } } else { errorProvider1.SetError(materialSingleLineTextField2, "Must be filled!"); } } else { errorProvider1.SetError(comboBox1, "Please select roomclass!"); } } else { errorProvider1.SetError(materialSingleLineTextField1, "Must be filled!"); } } else { MessageBox.Show("Data not found, Try again!", "WRONG DATA!"); materialSingleLineTextField6.Text = ""; materialSingleLineTextField6.Focus(); } }
private void materialRaisedButton6_Click(object sender, EventArgs e) { //Untuk Validasi Room FileStream bd = new FileStream("Room.txt", FileMode.Open, FileAccess.Read); StreamReader bdd = new StreamReader(bd); string line = bdd.ReadLine(); string[] dataroom2; int flag = 0; while (line != null) { dataroom2 = line.Split('#'); if (materialSingleLineTextField1.Text == dataroom2[0]) { flag = 1; } else { } line = bdd.ReadLine(); } bdd.Close(); bd.Close(); //Load Data declaredata(); //Membersihkan Error errorProvider1.Clear(); //Check Data Kosong if (RoomNumber.Trim().Length != 0) { if (comboBox1.Text != "- Select Room Class -") { if (Capacityroom.Trim().Length != 0) { if (Price.Trim().Length != 0) { if (comboBox2.Text != "- Select Room Status -") { if (comboBox3.Text != "- Select Room Condition -") { if (flag != 1) { FileStream fs = new FileStream("Room.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); string savedata = RoomNumber + "#" + Roomclass + "#" + Capacityroom + "#" + Price + "#" + Roomstatus + "#" + Roomcondition + "#"; sw.WriteLine(savedata); sw.Close(); fs.Close(); MessageBox.Show("Data has been added.", "SUCCESS!"); this.Hide(); var tc = new Technic(); tc.Closed += (s, args) => this.Close(); tc.Show(); } else { MessageBox.Show("Sorry room already exists!", "FAILED!"); this.Hide(); var tc = new Technic(); tc.Closed += (s, args) => this.Close(); tc.Show(); } } else { errorProvider1.SetError(comboBox3, "Please select room condition!"); } } else { errorProvider1.SetError(comboBox2, "Please select room status!"); } } else { errorProvider1.SetError(materialSingleLineTextField3, "Must be filled!"); } } else { errorProvider1.SetError(materialSingleLineTextField2, "Must be filled!"); } } else { errorProvider1.SetError(comboBox1, "Please select roomclass!"); } } else { errorProvider1.SetError(materialSingleLineTextField1, "Must be filled!"); } }
private void materialRaisedButton8_Click(object sender, EventArgs e) { string akunid = materialSingleLineTextField15.Text; string password = materialSingleLineTextField10.Text; FileStream ambildata = new FileStream("Akun.txt", FileMode.Open, FileAccess.Read); StreamReader bacadata = new StreamReader(ambildata); string linee = bacadata.ReadLine(); while (linee != null) { // Console.Clear(); string[] dataakun = linee.Split('#'); if (akunid == dataakun[0]) { dataakun0 = dataakun[0]; dataakun1 = dataakun[1]; dataakun2 = dataakun[2]; dataakun3 = dataakun[3]; dataakun4 = dataakun[4]; dataakun5 = dataakun[5]; dataakun6 = dataakun[6]; dataakun7 = dataakun[7]; dataakun8 = dataakun[8]; dataakun9 = dataakun[9]; dataakun10 = dataakun[10]; dataakun11 = dataakun[11]; dataakun12 = dataakun[12]; dataakun13 = dataakun[13]; } else { } linee = bacadata.ReadLine(); } bacadata.Close(); ambildata.Close(); //validasi email string vemail = materialSingleLineTextField12.Text; Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(vemail); //Load Data declaredata1(); //Load Encrypt string sandi = Encrypt(materialSingleLineTextField10.Text); string jawaban = Encrypt(materialSingleLineTextField9.Text); //Membersihkan Error errorProvider1.Clear(); //Check Data Kosong if (nama.Trim().Length != 0) { if (comboBox9.Text != "- Select Citizenship -") { if (alamat.Trim().Length != 0) { if (hp.Trim().Length != 0) { if (email.Trim().Length != 0) { if (username.Trim().Length != 0) { if (password.Trim().Length != 0) { if (comboBox8.Text != "- Select Type -") { if (comboBox6.Text != "- Select Question -") { if (jawaban.Trim().Length != 0) { if (match.Success) { string old = dataakun0 + "#" + dataakun1 + "#" + dataakun2 + "#" + dataakun3 + "#" + dataakun4 + "#" + dataakun5 + "#" + dataakun6 + "#" + dataakun7 + "#" + dataakun8 + "#" + dataakun9 + "#" + dataakun10 + "#" + dataakun11 + "#" + dataakun12 + "#" + dataakun13 + "#"; string neww = akunid + "#" + nama + "#" + ttl + "#" + gender + "#" + warganegara + "#" + alamat + "#" + hp + "#" + email + "#" + username + "#" + sandi + "#" + status + "#" + type + "#" + quest + "#" + jawaban + "#"; string update = File.ReadAllText("Akun.txt"); update = update.Replace(old, neww); File.WriteAllText("Akun.txt", update); MessageBox.Show("Account has been Updated.", "SUCCESS!"); this.Hide(); var ad = new Technic(); ad.Closed += (s, args) => this.Close(); ad.Show(); } else { errorProvider1.SetError(materialSingleLineTextField12, "Please enter valid email!"); } } else { errorProvider1.SetError(materialSingleLineTextField9, "Must be filled!"); } } else { errorProvider1.SetError(comboBox6, "Please select question!"); } } else { errorProvider1.SetError(comboBox8, "Please select type account!"); } } else { errorProvider1.SetError(materialSingleLineTextField10, "Must be filled!"); } } else { errorProvider1.SetError(materialSingleLineTextField11, "Must be filled!"); } } else { errorProvider1.SetError(materialSingleLineTextField12, "Must be filled!"); } } else { errorProvider1.SetError(materialSingleLineTextField13, "Must be filled!"); } } else { errorProvider1.SetError(textBox2, "Must be filled!"); } } else { errorProvider1.SetError(comboBox9, "Please select citizenship!"); } } else { errorProvider1.SetError(materialSingleLineTextField14, "Must be filled!"); } }