示例#1
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();
            }
        }
示例#2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            std stdn = new std();

            stdn.stdno = txtstdno.Text;
            if (!stdn.SelectfornameCheck().Equals(txtstdname.Text))
            {
                MessageBox.Show("نام هنرجو  با شماره پرونده مطابقت ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtstdname.Focus();
                return;
            }

            // Inserting the Data to the DataBase
            hozoorclass si   = new hozoorclass();
            DataTable   temp = si.Search("select status from hozoor where (stdno=" + txtstdno.Text + " and classno=" + dataGridView1.CurrentRow.Cells["classno"].Value.ToString() + " and date=N'" + txtdate.Text + "')");

            if (temp.Rows.Count > 0)
            {
                DialogResult dr;
                dr = MessageBox.Show("برای این هنرجو در این روز " + temp.Rows[0]["status"].ToString() + "ثبت شده است، آیا مایل به جایگزینی وضعیت هستید؟ ", "خطا", MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2);

                if (dr == DialogResult.Yes)
                {
                    si.classno = long.Parse(dataGridView1.CurrentRow.Cells["classno"].Value.ToString());
                    si.stdno   = txtstdno.Text;
                    si.date    = txtdate.Text;
                    if (rdoHazer.Checked)
                    {
                        si.status = "حاضر";
                    }
                    else if (rdoGhayeb.Checked)
                    {
                        si.status = "غائب";
                    }
                    si.UpdateifExists();

                    //////////////////////////////////////////////////////////////////////////////////////////////////
                    hozoorclass hzc = new hozoorclass();
                    hzc.stdno = txtstdno.Text;
                    dataGridView2.DataSource = hzc.SelectSabegheh();

                    // Display a message that the record was added...
                    MessageBox.Show("عملیات جایگزینی حضور و غیاب هنرجو با موفقیت انجام شد");

                    newform();
                }
                else
                {
                    if (rdoHazer.Checked)
                    {
                        rdoHazer.Focus();
                    }
                    else if (rdoGhayeb.Checked)
                    {
                        rdoGhayeb.Focus();
                    }
                }
            }

            else
            {
                si.stdno     = txtstdno.Text;
                si.stdname   = txtstdname.Text;
                si.classno   = long.Parse(dataGridView1.CurrentRow.Cells["classno"].Value.ToString());
                si.artcourse = txtartcourse.Text;
                si.date      = txtdate.Text;
                si.day       = txtday.Text;
                if (rdoHazer.Checked)
                {
                    si.status = "حاضر";
                }
                else if (rdoGhayeb.Checked)
                {
                    si.status = "غائب";
                }

                si.Add();

                hozoorclass hzc = new hozoorclass();
                hzc.stdno = txtstdno.Text;
                dataGridView2.DataSource = hzc.SelectSabegheh();
                //////////////////////////////////////////////////////////////////////////////////////////////////

                // Display a message that the record was added...
                MessageBox.Show("عملیات ثبت حضور و غیاب هنرجو با موفقیت انجام شد");

                newform();
            }
        }