Exemplo n.º 1
0
        private void cmdadd_Click(object sender, EventArgs e)
        {
            payments gh = new payments();

            gh.id           = txtid.Text;
            gh.name         = txtname.Text.Trim();
            gh.date         = txtdate.Text;
            gh.paidformonth = txtpaidformonth.Text;
            gh.mablagh      = long.Parse(txtmablagh.Text);
            gh.sharh        = txtsharh.Text;
            gh.Add();

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


            frmPayments_PrintViewer pv = new frmPayments_PrintViewer();

            pv.P = gh.Search("select * from payments where (id=" + txtid.Text.Trim() + ")");
            pv.Show();

            this.Close();
        }
Exemplo n.º 2
0
        private void btnfilter_Click(object sender, EventArgs e)
        {
            try
            {
                Boolean check = false;

                string SQL = "select * from payments where ";
                check = false;


                if (txtname.Text != "")
                {
                    SQL   = SQL + "name like 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 (txtlastdatefrom.MaskCompleted)
                {
                    checkBox1.Checked = false;
                    SQL   = SQL + "paidformonth>=N'" + txtlastdatefrom.Text.Trim() + "'AND ";
                    check = true;
                }

                if (txtlastdateto.MaskCompleted)
                {
                    checkBox1.Checked = false;
                    SQL   = SQL + "paidformonth<=N'" + txtlastdateto.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);
                }

                payments  rm = new payments();
                DataTable dt = new DataTable();
                dt = rm.Search(SQL);
                grdDataViewer.DataSource = dt;
            }
            catch (Exception)
            {
                MessageBox.Show("لطفا اطلاعات را به صورت درست وارد نمایید!!!");
                txtname.Text = "";
            }
        }