Exemple #1
0
        public void idsearch_Click()
        {
            std       st        = new std();
            DataTable dtstdname = new DataTable();

            dtstdname                = st.Search("SELECT stdno, name FROM std order by name");
            txtstdname.DataSource    = dtstdname;
            txtstdname.DisplayMember = "name";
            txtstdname.ValueMember   = "name";

            txtstdno.DataBindings.Clear();
            txtstdno.DataBindings.Add("Text", dtstdname, "stdno");

            hozoorclass gha = new hozoorclass();

            gha.stdno   = OLD_STDNO;
            gha.classno = long.Parse(OLD_CLASSNO);
            gha.date    = OLD_DATE;
            DataTable dt = gha.Selectforedit();

            if (dt.Rows.Count > 0)
            {
                btnUpdate.Enabled = true;
                txtstdno.Enabled  = false;
                groupBox1.Enabled = true;
                // Clear any previous bindings & Add new bindings to the DataView object...
                foreach (Control c in groupBox1.Controls)
                {
                    if (c.GetType() == typeof(NormalTextbox) || c.GetType() == typeof(NormalCombobox) || c.GetType() == typeof(DateMaskedTextbox))
                    {
                        c.Text = dt.Rows[0][c.Name.Substring(3)].ToString();
                    }
                }

                if (dt.Rows[0]["status"].ToString() == "حاضر")
                {
                    rdoHazer.Checked = true;
                }
                else
                {
                    rdoGhayeb.Checked = true;
                }
                // End of Clearing & Adding of Controls Binding
                btnUpdate.Enabled = true;
                txtstdname.Focus();
            }
            else
            {
                MessageBox.Show("مشخصات در سیستم موجود نمی باشد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #2
0
        private void btnHozoorAll_Click(object sender, EventArgs e)
        {
            DialogResult dr;

            dr = MessageBox.Show(" آیا از انجام عملیات اطمینان دارید؟", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, MessageBoxOptions.RightAlign);

            if (dr == DialogResult.Yes)
            {
                foreach (DataGridViewRow dgvr in dataGridView4.Rows)
                {
                    if (dgvr.Cells[0].Value.ToString().Trim().Equals("----"))
                    {
                        hozoorclass si = new hozoorclass();
                        si.stdno   = dgvr.Cells["class_stdno"].Value.ToString();
                        si.classno = long.Parse(dgvr.Cells["class_classno"].Value.ToString());
                        si.date    = class_txtdate.Text;

                        si.Delete();
                    }
                    else
                    {
                        hozoorclass si = new hozoorclass();

                        si.stdno     = dgvr.Cells["class_stdno"].Value.ToString();
                        si.stdname   = dgvr.Cells["class_stdname"].Value.ToString();
                        si.classno   = long.Parse(dgvr.Cells["class_classno"].Value.ToString());
                        si.artcourse = dgvr.Cells["class_artcourse"].Value.ToString();
                        si.date      = class_txtdate.Text;
                        si.day       = dgvr.Cells["class_classday"].Value.ToString();
                        si.status    = dgvr.Cells["class_hozoor_status"].Value.ToString();

                        DataTable ifExists = si.Selectforedit();
                        if (ifExists.Rows.Count == 0)
                        {
                            si.Add();
                        }
                    }
                }

                MessageBox.Show("عملیات ثبت وضعیت حضور هنرجویان با موفقیت انجام شد");
                this.Close();
            }
        }