public void My_Serialize(gl Obj, string filePath) { XmlSerializer serializer = new XmlSerializer(typeof(gl)); if (!File.Exists(filePath)) { FileStream read = new FileStream(filePath, FileMode.Append, FileAccess.Write, FileShare.None); using (read) { serializer.Serialize(read, Obj); read.Close(); } } else { XDocument doc = XDocument.Load(filePath); var newElement = new XElement("User", new XElement("Name", Obj.temp[0].Name), new XElement("Email", Obj.temp[0].Email), new XElement("Password", Obj.temp[0].Password), new XElement("Confirm_Password", Obj.temp[0].Confirm_Password), new XElement("Number", Obj.temp[0].Number) ); doc.Element("Users_Details").Add(newElement); doc.Save(filePath); } }
private void Loginbtn_Click(object sender, EventArgs e) { if (EmailInput.Text == "Admin" && PasswordInput.Text == "123") { busobj.busname = "Ajanata Travels"; busobj.departure = "12:20"; busobj.fare = 1200; busobj.seatcount = 20; busobj.from = "Indore"; busobj.to = "Bangalore"; busobj.sendbus_details(Resources.Resource1.FilePathBus, busobj); MessageBox.Show("Admin"); return; } BLL obj1 = new BLL(); gl cat = obj1.get_details(obj1, Resources.Resource1.FilePathData); // MessageBox.Show(Convert.ToString(cat.Count)); string pass = ""; for (int i = 0; i < cat.temp.Count; i++) { if (cat.temp[i].Email == EmailInput.Text) { pass = cat.temp[i].Password; } } if (pass == PasswordInput.Text && pass != "") { DashBoard db = new DashBoard(); this.Hide(); this.Parent.Controls.Add(db); } else { Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(EmailInput.Text); if (!(match.Success)) { errorProvider1.SetError(EmailInput, "Invalid Email"); } else { errorProvider1.SetError(EmailInput, ""); } if (String.IsNullOrEmpty(PasswordInput.Text)) { errorProvider2.SetError(PasswordInput, "Enter Password "); } else { errorProvider2.SetError(PasswordInput, ""); } } }
public gl get_details(BLL obj, string file) { DLL dobj = new DLL(); gl t = dobj.My_Deserialize(obj, file); return(t); }
public void RegisterBtn_Click(object sender, EventArgs e) { obj.Name = RNameInput.Text; obj.Email = REmailInput.Text; obj.Password = RPassword.Text; obj.Confirm_Password = RCnfmPassword.Text; obj.Number = RContact.Text; int f = 0; BLL obj1 = new BLL(); gl cat = obj1.get_details(obj1, Resources.Resource1.FilePathData); for (int i = 0; i < cat.temp.Count; i++) { if (REmailInput.Text == cat.temp[i].Email) { f = 1; break; } } bool validate = false; if (f == 1) { MessageBox.Show("Email Already Exists"); } else { validate = obj.send_details(obj, Resources.Resource1.FilePathData); } if (validate) { LoginUserControl obj = new LoginUserControl(); this.Hide(); this.Parent.Controls.Add(obj); } }