Пример #1
0
        private void btndel_Click_1(object sender, EventArgs e)
        {
            if (grdDataViewer.CurrentRow != null)
            {
                DialogResult dr;
                dr = MessageBox.Show("آیا از حذف وضعیت این هنرجو در تاریخ انتخاب شده اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dr == DialogResult.Yes)
                {
                    int    icol = 0;
                    int    irow = grdDataViewer.CurrentRow.Index;
                    string val  = grdDataViewer[icol, irow].Value.ToString();

                    hozoorclass gha = new hozoorclass();
                    gha.stdno   = grdDataViewer["stdno", irow].Value.ToString();
                    gha.classno = long.Parse(grdDataViewer["classno", irow].Value.ToString());
                    gha.date    = grdDataViewer["date", irow].Value.ToString();
                    gha.Delete();

                    if (btnfilter.Enabled == true)
                    {
                        btnfilter.PerformClick();
                    }
                    else
                    {
                        hozoorclass pm = new hozoorclass();
                        DataTable   dt = new DataTable();
                        dt = pm.Select();
                        grdDataViewer.DataSource = dt;
                    }
                }
            }
        }
Пример #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();
            }
        }