Exemplo n.º 1
0
        public void Search_Click()
        {
            Courses   co     = new Courses();
            DataTable dtname = new DataTable();

            dtname = co.Search("SELECT coursename FROM courses");
            txtartcourse.DataSource    = dtname;
            txtartcourse.DisplayMember = "coursename";
            txtartcourse.ValueMember   = "coursename";

            DataTable dt = new DataTable();
            teachers  cu = new teachers();

            cu.teacherno = int.Parse(txtteacherno.Text);
            dt           = cu.Selectforedit();
            if (dt.Rows.Count > 0)
            {
                btnUpdate.Enabled    = true;
                txtteacherno.Enabled = false;
                //idsearch.Enabled = false;
                grpinfo_box.Enabled = true;

                // Clear any previous bindings & Add new bindings to the DataView object...
                foreach (Control c in grpinfo_box.Controls)
                {
                    if (c.GetType() == typeof(NormalTextbox) || c.GetType() == typeof(NormalCombobox))
                    {
                        c.Text = dt.Rows[0][c.Name.Substring(3)].ToString();
                    }
                }
                // End of Clearing & Adding of Controls Binding

                txtname.Focus();
            }
            else
            {
                MessageBox.Show("مشخصه استاد در سیستم موجود نمی باشد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 2
0
        private void cmdedit_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                int    col = 0;
                int    row = dataGridView1.CurrentRow.Index;
                string val = dataGridView1[col, row].Value.ToString();

                teachers  te    = new teachers();
                DataTable datat = new DataTable();
                te.teacherno = int.Parse(val);
                datat        = te.Selectforedit();

                editteacher es = new editteacher();
                es.txtteacherno.Text = val;
                es.Search_Click();
                es.ShowDialog();

                DataTable dt = new DataTable();
                dt = te.SelectforView();
                dataGridView1.DataSource = dt;
            }
        }