예제 #1
0
        private void EditAdvisor_Load(object sender, EventArgs e)
        {
            Advisors a = AdvisorUtile.updAdvisor;

            txtAdvisorId.Text     = Convert.ToString(ViewAdvisors.advisor_Id);
            txtsalaray.Text       = a.Salary1.ToString();
            cmbDesignation.Text   = a.Designationstring1;
            txtAdvisorId.ReadOnly = true;
        }
예제 #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            selected = dataGridView1.CurrentCell.RowIndex;
            DataGridViewRow row = dataGridView1.Rows[selected];

            if (e.ColumnIndex == 0)
            {
                Advisors a = AdvisorUtile.updAdvisor;

                advisor_Id     = (int)row.Cells[2].Value;
                a.Salary1      = Convert.ToInt32(row.Cells[4].Value);
                a.Designation1 = (int)row.Cells[3].Value;
                if (a.Designation1 == 6)
                {
                    a.Designationstring1 = "Professor";
                }
                else if (a.Designation1 == 7)
                {
                    a.Designationstring1 = "Associate Professor";
                }
                else if (a.Designation1 == 8)
                {
                    a.Designationstring1 = "Assistant Professor";
                }
                else if (a.Designation1 == 9)
                {
                    a.Designationstring1 = "Lecturer";
                }
                else if (a.Designation1 == 10)
                {
                    a.Designationstring1 = "Industry Professional";
                }



                EditAdvisor ea = new EditAdvisor();
                this.Hide();
                ea.Show();
            }
            if (e.ColumnIndex == 1)
            {
                int Id = Convert.ToInt32(row.Cells[2].Value);
                //string advisor = row.Cells[3].Value.ToString();
                DialogResult res = MessageBox.Show("Are you sure you want  to Delete " + Id, "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (res == DialogResult.OK)
                {
                    try
                    {
                        SqlConnection con = new SqlConnection(conStr);
                        con.Open();
                        //string Delete_Project_Advisor = "DELETE FROM ProjectAdvisor WHERE Id = '" + Id + "'";
                        string Delete = "DELETE FROM Advisor WHERE Id = '" + Id + "'";
                        //if (con.State == ConnectionState.Open)
                        //{
                        //    SqlCommand cmd = new SqlCommand(Delete_Project_Advisor, con);
                        //    cmd.ExecuteNonQuery();
                        //}

                        if (con.State == ConnectionState.Open)
                        {
                            SqlCommand cmd = new SqlCommand(Delete, con);
                            cmd.ExecuteNonQuery();
                        }

                        MessageBox.Show("Succesfully Deleted");
                        this.Hide();
                        ViewAdvisors va = new ViewAdvisors();
                        va.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error:" + ex);
                    }
                }
            }
        }