private void btn_signup_Click(object sender, EventArgs e) { lbl_error_msg.Text = ""; if (txt_email.TextLength < 1 || txt_password.TextLength < 1 || txt_username.TextLength < 1) { lbl_error_msg.Text = "Tous les champs sont obligatoires !"; } if (UserAuthService.userExist(txt_email.Text, txt_username.Text)) { lbl_error_msg.Text = "Veuillez indiquer un autre email ou nom d'utilisateur !"; } try { SlaDataSet dataSet = new SlaDataSet(); SlaDataSetTableAdapters.SLA_USERSTableAdapter usersTableAdapter = new SlaDataSetTableAdapters.SLA_USERSTableAdapter(); // Create a new row. SlaDataSet.SLA_USERSRow usersRow; usersRow = dataSet.SLA_USERS.NewSLA_USERSRow(); usersRow.USR_EMAIL = txt_email.Text; usersRow.USR_NAME = txt_username.Text; usersRow.USR_PASSWORD = txt_password.Text; usersRow.USR_AGE = (int)nud_age.Value; switch (cbo_type.SelectedText) { case "Client": usersRow.USR_TYPE = 1; break; case "Artiste": usersRow.USR_TYPE = 2; break; default: usersRow.USR_TYPE = 1; break; } usersTableAdapter.InsertQuery(usersRow.USR_NAME, usersRow.USR_PASSWORD, usersRow.USR_TYPE, usersRow.USR_EMAIL, usersRow.USR_AGE); lbl_error_msg.Text = "Votre compte a bien été enregistré !"; Dispose(); } catch (SqlException ex) { lbl_error_msg.Text = "Une erreur est survenue ! Veuillez introduire des champs valides !"; } }
private void Main_Load(object sender, EventArgs e) { flp_articles_list.AutoScroll = true; SlaDataSet dataSet = new SlaDataSet(); SlaDataSetTableAdapters.SLA_PRODUCTSTableAdapter listProducts = new SlaDataSetTableAdapters.SLA_PRODUCTSTableAdapter(); listProducts.Fill(dataSet.SLA_PRODUCTS); foreach (SlaDataSet.SLA_PRODUCTSRow product in listProducts.GetData().Where(p => p.PRD_USR_ID != UserAuthService.getUserId())) { FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel(); Label lbId = new Label(); lbId.Hide(); lbId.Text = product.PRD_ID.ToString(); Label lbNom = new Label(); lbNom.AutoSize = false; lbNom.Text = product.PRD_NAME; lbNom.TextAlign = ContentAlignment.MiddleCenter; Label lbPrix = new Label(); lbPrix.AutoSize = false; lbPrix.Text = product.PRD_PRICE + " .-"; lbPrix.TextAlign = ContentAlignment.MiddleCenter; flowLayoutPanel.Size = new Size(78, 122); lbNom.Size = new Size(75, 20); lbPrix.Size = new Size(75, 20); PictureBox picture = new PictureBox(); picture.Size = new Size(78, 70); flowLayoutPanel.Controls.Add(lbId); flowLayoutPanel.Controls.Add(picture); flowLayoutPanel.Controls.Add(lbNom); flowLayoutPanel.Controls.Add(lbPrix); foreach (Control control in flowLayoutPanel.Controls) { control.Click += new EventHandler(produit_click); } flp_articles_list.Controls.Add(flowLayoutPanel); picture.Image = simplart.Properties.Resources.bsi_toomt14; picture.SizeMode = PictureBoxSizeMode.StretchImage; picture.Refresh(); } }
private void button1_Click(object sender, EventArgs e) { SlaDataSet dataSet = new SlaDataSet(); SlaDataSet.SLA_PRODUCTSRow productModified = dataSet.SLA_PRODUCTS.NewSLA_PRODUCTSRow(); productModified.PRD_ID = product.PRD_ID; productModified.PRD_NAME = product.PRD_NAME; productModified.PRD_PRICE = product.PRD_PRICE; productModified.PRD_QUANTITY = int.Parse(nud_quantity.Text); main.addProductToBasket(productModified); main.openBasket(); }
public static bool userExist(String email, String username) { SlaDataSet dataSet = new SlaDataSet(); SlaDataSetTableAdapters.SLA_USERSTableAdapter listLogin = new SlaDataSetTableAdapters.SLA_USERSTableAdapter(); listLogin.Fill(dataSet.SLA_USERS); SlaDataSet.SLA_USERSRow user = listLogin.GetDataByUserEmail(username, email).FirstOrDefault(); if (user != null) { return(true); } return(false); }
public fv_product(Main main, int id) { this.main = main; SlaDataSet dataSet = new SlaDataSet(); SlaDataSetTableAdapters.SLA_PRODUCTSTableAdapter listProducts = new SlaDataSetTableAdapters.SLA_PRODUCTSTableAdapter(); listProducts.Fill(dataSet.SLA_PRODUCTS); product = listProducts.GetData().Where(p => p.PRD_ID.Equals(id)).First(); InitializeComponent(); lbl_product_name.Text = product.PRD_NAME; lbl_prd_price.Text = product.PRD_PRICE + " .-"; rtxt_product_description.Text = product.PRD_DESCRIPTION; nud_quantity.Maximum = product.PRD_QUANTITY; }
public static bool login(String username, String password) { SlaDataSet dataSet = new SlaDataSet(); SlaDataSetTableAdapters.SLA_USERSTableAdapter listLogin = new SlaDataSetTableAdapters.SLA_USERSTableAdapter(); listLogin.Fill(dataSet.SLA_USERS); SlaDataSet.SLA_USERSRow user = listLogin.GetDataByUser(username).First(); if (user != null && user.USR_PASSWORD.Equals(password)) { actual_user = user; return(true); } return(false); }