예제 #1
0
        private void btnfilter_Click(object sender, EventArgs e)
        {
            try
            {
                Boolean check = false;

                string SQL = "select row_number() over (order by date desc) as id ,* from hozoor where ";
                check = false;


                if (txtartcourse.Text != "")
                {
                    SQL   = SQL + "artcourse = N'" + txtartcourse.Text.Trim() + "'AND ";
                    check = true;
                }

                if (txtname.Text != "")
                {
                    SQL   = SQL + "stdname = N'" + txtname.Text.Trim() + "'AND ";
                    check = true;
                }

                if (txtmos_date.MaskCompleted)
                {
                    checkBox1.Checked = false;
                    SQL   = SQL + "date>=N'" + txtmos_date.Text.Trim() + "'AND ";
                    check = true;
                }

                if (txttodate.MaskCompleted)
                {
                    checkBox1.Checked = false;
                    SQL   = SQL + "date<=N'" + txttodate.Text.Trim() + "'AND ";
                    check = true;
                }

                if (checkBox1.Checked)
                {
                    SQL   = SQL + "date=N'" + cur_date.Trim() + "'AND ";
                    check = true;
                }

                if (check == true)
                {
                    SQL = SQL.Remove(SQL.Length - 4) + " order by date desc";
                }

                hozoorclass rm = new hozoorclass();
                DataTable   dt = new DataTable();
                dt = rm.Search(SQL);
                grdDataViewer.DataSource = dt;
            }
            catch (Exception)
            {
                MessageBox.Show("لطفا اطلاعات را به صورت درست وارد نمایید!!!");
                txtname.Text = "";
            }
        }
예제 #2
0
        private void btnfilter_Click(object sender, EventArgs e)
        {
            try
            {
                Boolean check = false;

                string SQL = "select row_number() over (order by date ASC) as id,* from hozoor where classno in( select classno from classes where teacher=N'" + txtteacher.Text.Trim() + "')and ";
                check = true;


                if (txtmos_date.MaskCompleted)
                {
                    SQL   = SQL + "date>=N'" + txtmos_date.Text.Trim() + "'AND ";
                    check = true;
                }

                if (txttodate.MaskCompleted)
                {
                    SQL   = SQL + "date<=N'" + txttodate.Text.Trim() + "'AND ";
                    check = true;
                }

                if (check == true)
                {
                    SQL = SQL.Remove(SQL.Length - 4) + " order by date ASC";


                    hozoorclass rm = new hozoorclass();
                    DataTable   dt = new DataTable();
                    dt = rm.Search(SQL);
                    grdDataViewer.DataSource = dt;

                    string[] col_headers = { "ردیف", "مشخصه هنرجو", "نام و نام خانوادگی", "مشخصه کلاس", "رشته هنری", "تاریخ", "روز", "وضعیت" };
                    int[]    col_width   = { 60, 70, 120, 70, 90, 80, 80, 77 };

                    for (int i = 0; i < col_headers.Length; i++)
                    {
                        grdDataViewer.Columns[i].HeaderText = col_headers[i].ToString();
                        grdDataViewer.Columns[i].Width      = col_width[i];
                    }

                    int hc = 0, ghc = 0;

                    foreach (DataGridViewRow dgvr in grdDataViewer.Rows)
                    {
                        if (dgvr.Cells["status"].Value.ToString().Equals("حاضر"))
                        {
                            hc++;
                        }
                        else
                        {
                            ghc++;
                        }
                    }

                    lblkol.Text     = grdDataViewer.Rows.Count.ToString();
                    lblhozoor.Text  = hc.ToString();
                    lblgheybat.Text = ghc.ToString();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("لطفا اطلاعات را به صورت درست وارد نمایید!!!");
                txtteacher.Text = "";
            }
        }
예제 #3
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();
            }
        }