Beispiel #1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {// delete button
            try
            {
                AdminDB objt = new AdminDB();
                String  NicNumber;
                NicNumber       = dataGridViewUpdateAdmin.SelectedCells[0].Value.ToString();
                objt.NICNumber1 = NicNumber;
                objt.DeleteAdmin(objt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            // refersh table
            try
            {
                AdminDB       obcj = new AdminDB();
                SqlDataReader DR   = obcj.getAdminInfo();
                DataTable     dt   = new DataTable();
                dt.Columns.Add("AdminID");
                dt.Columns.Add("FristName");
                dt.Columns.Add("LastName");
                dt.Columns.Add("Email");
                dt.Columns.Add("UserPassword");
                dt.Columns.Add("gender");
                dt.Columns.Add("Adress");
                dt.Columns.Add("Phone_Number");
                dt.Columns.Add("Registerdate");
                while (DR.Read())
                {
                    DataRow row = dt.NewRow();
                    row["AdminID"]      = DR["AdminID"];
                    row["FristName"]    = DR["FristName"];
                    row["LastName"]     = DR["LastName"];
                    row["Email"]        = DR["Email"];
                    row["UserPassword"] = DR["UserPassword"];
                    row["gender"]       = DR["gender"];
                    row["Adress"]       = DR["Adress"];
                    row["Phone_Number"] = DR["Phone_Number"];
                    row["Registerdate"] = DR["Registerdate"];

                    dt.Rows.Add(row);
                }
                dataGridViewUpdateAdmin.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            // clear text filed
            textBoxFristName.Text       = "";
            textBoxLastName.Text        = "";
            textBoxEmail.Text           = "";
            textBoxPassword.Text        = "";
            textBoxConfirmpassword.Text = "";
            richTextBoxAdress.Text      = "";
            textBoxPhonenumber.Text     = "";
        }
Beispiel #2
0
        private void UpdateAdmin_Load(object sender, EventArgs e)
        {
            //geting all  admin details admin table
            try
            {
                AdminDB       obj = new AdminDB();
                SqlDataReader DR  = obj.getAdminInfo();
                DataTable     dt  = new DataTable();
                dt.Columns.Add("AdminID");
                dt.Columns.Add("FristName");
                dt.Columns.Add("LastName");
                dt.Columns.Add("Email");
                dt.Columns.Add("UserPassword");
                dt.Columns.Add("gender");
                dt.Columns.Add("Adress");
                dt.Columns.Add("Phone_Number");
                dt.Columns.Add("Registerdate");
                while (DR.Read())
                {
                    DataRow row = dt.NewRow();
                    row["AdminID"]      = DR["AdminID"];
                    row["FristName"]    = DR["FristName"];
                    row["LastName"]     = DR["LastName"];
                    row["Email"]        = DR["Email"];
                    row["UserPassword"] = DR["UserPassword"];
                    row["gender"]       = DR["gender"];
                    row["Adress"]       = DR["Adress"];
                    row["Phone_Number"] = DR["Phone_Number"];
                    row["Registerdate"] = DR["Registerdate"];

                    dt.Rows.Add(row);
                }
                dataGridViewUpdateAdmin.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        private void ButtonUpdate_Click(object sender, EventArgs e)
        {//Update button coding
            if (textBoxFristName.Text == "")
            {
                MessageBox.Show("Frist Name cant be Empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else if (textBoxLastName.Text == "")
            {
                MessageBox.Show("Last Name cant be Empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBoxEmail.Text == "")
            {
                MessageBox.Show("Email year cant be Empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBoxPassword.Text == "")
            {
                MessageBox.Show("Password cant be Empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBoxConfirmpassword.Text == "")
            {
                MessageBox.Show("Confirm Password cant be Empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (richTextBoxAdress.Text == "")
            {
                MessageBox.Show("Adress cant be Empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (textBoxPhonenumber.Text == "")
            {
                MessageBox.Show("Phone number cant be Empty", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //updatecoding
                AdminDB obj = new AdminDB();
                String  NICNO;
                NICNO            = dataGridViewUpdateAdmin.SelectedCells[0].Value.ToString();
                obj.NICNumber1   = NICNO;
                obj.FristName1   = textBoxFristName.Text;
                obj.LastName1    = textBoxLastName.Text;
                obj.Email1       = textBoxEmail.Text;
                obj.Password     = textBoxPassword.Text;
                obj.Gender1      = comboBoxGender.Text;
                obj.Address1     = richTextBoxAdress.Text;
                obj.Phonenumber1 = Convert.ToInt32(textBoxPhonenumber.Text);
                obj.enterupdaeAdmin(obj);
                // refersh table
                try
                {
                    AdminDB       obcj = new AdminDB();
                    SqlDataReader DR   = obcj.getAdminInfo();
                    DataTable     dt   = new DataTable();
                    dt.Columns.Add("AdminID");
                    dt.Columns.Add("FristName");
                    dt.Columns.Add("LastName");
                    dt.Columns.Add("Email");
                    dt.Columns.Add("UserPassword");
                    dt.Columns.Add("gender");
                    dt.Columns.Add("Adress");
                    dt.Columns.Add("Phone_Number");
                    dt.Columns.Add("Registerdate");
                    while (DR.Read())
                    {
                        DataRow row = dt.NewRow();
                        row["AdminID"]      = DR["AdminID"];
                        row["FristName"]    = DR["FristName"];
                        row["LastName"]     = DR["LastName"];
                        row["Email"]        = DR["Email"];
                        row["UserPassword"] = DR["UserPassword"];
                        row["gender"]       = DR["gender"];
                        row["Adress"]       = DR["Adress"];
                        row["Phone_Number"] = DR["Phone_Number"];
                        row["Registerdate"] = DR["Registerdate"];

                        dt.Rows.Add(row);
                    }
                    dataGridViewUpdateAdmin.DataSource = dt;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                // send email
                try
                {
                    SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
                    smtp.EnableSsl             = true;
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials           = new NetworkCredential("*****@*****.**", "ishpvi928280");
                    MailMessage mail = new MailMessage("*****@*****.**", textBoxEmail.Text, "Your detalis has been updated get mor info please contact administor!!Your loinid is  Your NIC Number and password given bellow ", textBoxConfirmpassword.Text);
                    mail.Priority = MailPriority.High;
                    smtp.Send(mail);
                    MessageBox.Show("Mail Send");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                // clear text filed
                textBoxFristName.Text       = "";
                textBoxLastName.Text        = "";
                textBoxEmail.Text           = "";
                textBoxPassword.Text        = "";
                textBoxConfirmpassword.Text = "";
                richTextBoxAdress.Text      = "";
                textBoxPhonenumber.Text     = "";
            }
        }