Пример #1
0
        private void cmdadd_Click(object sender, EventArgs e)
        {
            std stdn = new std();

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


            ghabz gh = new ghabz();

            gh.id        = txtid.Text;
            gh.stdno     = txtstdno.Text;
            gh.name      = txtname.Text.Trim();
            gh.artcourse = txtartcourse.Text.Trim();
            gh.date      = txtdate.Text;
            gh.lastcheck = txtlastcheck.Text;
            gh.lastdate  = txtlastdate.Text;
            gh.mablagh   = long.Parse(txtmablagh.Text);
            gh.paid      = long.Parse(txtpaid.Text);
            gh.sharh     = txtsharh.Text;
            gh.Update();

            if (!stdno.Equals(txtstdno.Text))
            {
                std_history st = new std_history();
                st.ghabz_id = txtid.Text;
                st.stdno    = stdno; // old stdno
                st.Delete();

                pardakht();
                Daryaft();
            }
            else
            {
                std_history sh = new std_history();
                sh.ghabz_id   = txtid.Text;
                sh.stdno      = txtstdno.Text;;
                sh.sharh      = "شهریه " + txtlastcheck.Text + "-" + txtsharh.Text;
                sh.date       = txtdate.Text;
                sh.bedehkari  = long.Parse(txtmablagh.Text);
                sh.bestankari = long.Parse(txtmablagh.Text);
                sh.UpdateAfterEslahGhabz();
            }

            MessageBox.Show("قبض با موفقیت ویرایش گردید");

            this.Close();
        }
Пример #2
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();

                    ghabz gha = new ghabz();
                    gha.id = val;
                    gha.Delete();

                    std_history st = new std_history();
                    st.ghabz_id = val;
                    st.stdno    = grdDataViewer["stdno", irow].Value.ToString();
                    st.Delete();

                    if (btnfilter.Enabled == true)
                    {
                        btnfilter.PerformClick();
                    }
                    else
                    {
                        ghabz     pm = new ghabz();
                        DataTable dt = new DataTable();
                        dt = pm.Select();
                        grdDataViewer.DataSource = dt;
                    }
                }
            }
        }