private void button1_Click(object sender, EventArgs e) { if (textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0) { MessageBox.Show("Please filled all the field properly", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { if (textBox3.Text.Length <= 3) { MessageBox.Show("password too short", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { Admin a = new Admin { user_name = textBox2.Text, First_Name = textBox5.Text, Last_name = textBox4.Text, AdminPassword = textBox3.Text, AdminId = Convert.ToInt32(textBox1.Text), Status = status }; MessageBox.Show("New Admin Added Successfully", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); pd.Admins.InsertOnSubmit(a); pd.SubmitChanges(); //dataGridView1.DataSource = pd.Admins; AdminHome h = new AdminHome(ai); h.Show(); this.Visible = false; } } }
// logout button private void button1_Click(object sender, EventArgs e) { var x = from az in pd.Carts select az; foreach (Cart c in x) { pd.Carts.DeleteOnSubmit(c); } pd.SubmitChanges(); Login l = new Login(); l.Show(); this.Visible = false; }
private void button2_Click_1(object sender, EventArgs e) { var x = from a in pd.ProductInfos where a.PId == textBox1.Text select a; foreach (ProductInfo p in x) { pd.ProductInfos.DeleteOnSubmit(p); } pd.SubmitChanges(); UpdateGridView(); MessageBox.Show("Successfull", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
public string UpdateAdmin(string x, string y, string z) { try { Admin t = new Admin(); var str = from a in ptx.Admins where a.user_name == x select a; t = str.First(); t.user_name = x; t.First_Name = y; t.Last_name = z; ptx.SubmitChanges(); r = "Successfull"; } catch { r = "notupdated"; } return(r); }
private void button2_Click(object sender, EventArgs e) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || comboBox1.SelectedIndex.ToString() == "Select" || comboBox2.SelectedIndex.ToString() == "Select" || numericUpDown1.Value == 0) { MessageBox.Show("Please fill all the field properly", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { pp.ProductName = textBox1.Text; pp.PID = textBox2.Text; pp.Quantity = Convert.ToInt32(numericUpDown1.Value); pp.BuyingPrice = Convert.ToSingle(textBox3.Text); pp.SellingPrice = Convert.ToSingle(textBox4.Text); pp.Product_Type = textBox5.Text; pp.DivisionP = comboBox1.SelectedItem.ToString(); pp.DistrictsP = comboBox2.SelectedItem.ToString(); ProductInfo p = new ProductInfo { Name = pp.ProductName, ProductType = pp.Product_Type, Division = pp.DivisionP, Districts = pp.DistrictsP, Quantity = pp.Quantity, BuyingPrice = pp.BuyingPrice, SellingPrice = pp.SellingPrice, PId = pp.PID, Profit = Convert.ToSingle(textBox4.Text) - Convert.ToSingle(textBox3.Text), }; pm.ProductInfos.InsertOnSubmit(p); pm.SubmitChanges(); MessageBox.Show("Add Successfully", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); AdminHome h = new AdminHome(ai); h.Show(); this.Visible = false; } }
private void button2_Click(object sender, EventArgs e) { u.Name = textBox1.Text; u.FirstName = textBox2.Text; u.LastName = textBox8.Text; u.Password = textBox3.Text; u.MobileNo = textBox5.Text; u.Email = textBox6.Text; bool isChecked = radioButton1.Checked; if (isChecked) { u.Gender = radioButton1.Text; } else { u.Gender = radioButton2.Text; } u.Address = textBox7.Text; if (textBox3.Text.Length <= 3) { MessageBox.Show("Password is too short !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); textBox3.Text = ""; textBox4.Text = ""; } if (textBox5.Text.Length == 11 && (textBox5.Text.StartsWith("016") || textBox5.Text.StartsWith("017") || textBox5.Text.StartsWith("018") || textBox5.Text.StartsWith("019") || textBox5.Text.StartsWith("015"))) { } else { MessageBox.Show("Wrong Mobile Number !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); textBox5.Text = ""; } if ((textBox6.Text.Contains("@") && textBox6.Text.Contains(".com")) && (!textBox6.Text.StartsWith("@") || !textBox6.Text.StartsWith(" "))) { } else { MessageBox.Show("Use Valid Email ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (textBox3.Text == textBox4.Text) { if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0 || textBox7.Text.Length == 0 || textBox8.Text.Length == 0) { MessageBox.Show("Please filled all the field properly", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //////////////////////// try { SmtpClient client = new SmtpClient("smtp.gmail.com", 587); client.EnableSsl = true; client.Timeout = 10000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential("*****@*****.**", "zigatola1234"); MailMessage msg = new MailMessage(); msg.To.Add(textBox6.Text); msg.From = new MailAddress("*****@*****.**"); msg.Subject = "Email Validaton . Login accepted for Inventory management"; msg.Body = "WELCOME TO INVENTORY MANAGEMENT SYSTEM \n\n\n Your mail address is validet \n\n\n Thank you"; client.Send(msg); MessageBox.Show("Email Validation Complete"); } catch (Exception ex) { MessageBox.Show(ex.Message); } /////////////////////// CustomerInfo c = new CustomerInfo { user_name = u.Name, First_name = u.FirstName, Last_name = u.LastName, password = u.Password, mobile = u.MobileNo, address = u.Address, gender = u.Gender, email = u.Email, Status = status }; pd.CustomerInfos.InsertOnSubmit(c); pd.SubmitChanges(); UserHome h = new UserHome(u); h.Show(); this.Visible = false; } } else { MessageBox.Show("Wrong Password ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }