예제 #1
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("income");
            dt.Columns.Add("paid");
            dt.Columns.Add("hazineh");
            dt.Columns.Add("month");
            ghabz gh = new ghabz();

            string year = txtyear.Value.ToString() + @"/";

            string[] fromdate = new string[12];
            string[] todate   = new string[12];
            string[] months   = { "فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند" };

            for (int i = 1; i <= 12; i++)
            {
                fromdate[i - 1] = year + i.ToString("00") + @"/01";
                todate[i - 1]   = year + i.ToString("00") + @"/31";

                DataTable dtrows        = gh.Search("SELECT isnull(SUM(mablagh),0) AS income FROM GHABZ WHERE (date>=N'" + fromdate[i - 1] + "' and date<=N'" + todate[i - 1] + "' )");
                DataTable dtpaidrows    = gh.Search("SELECT isnull(SUM(mablagh),0) AS paid FROM payments WHERE (paidformonth>=N'" + months[i - 1] + "' and paidformonth<=N'" + months[i - 1] + "' )");
                DataTable dthazinehrows = gh.Search("SELECT isnull(SUM(mablagh),0) AS hazineh FROM hazineh WHERE (date>=N'" + fromdate[i - 1] + "' and date<=N'" + todate[i - 1] + "' )");

                dt.Rows.Add(new object[] { dtrows.Rows[0]["income"].ToString(), dtpaidrows.Rows[0]["paid"].ToString(), dthazinehrows.Rows[0]["hazineh"].ToString(), months[i - 1] });
            }

            this.reportDataSource1.Value = dt;

            this.reportViewer1.RefreshReport();
        }
예제 #2
0
        private void newform()
        {
            ghabz gh = new ghabz();

            txtid.Text = gh.Selectmaxid();

            DataTable lastmablagh = gh.Search("select top 1(mablagh) from ghabz order by id desc");

            if (lastmablagh.Rows.Count > 0)
            {
                txtmablagh.Text = lastmablagh.Rows[0][0].ToString();
            }
            else
            {
                txtmablagh.Text = "0";
            }

            txtdate.Text = cur_date;

            txtlastdate.Text = Date.returnLastDateOfaDate(txtdate.Text);

            txtsharh.Text = "";
            groupBox1.Focus();
            txtname.Focus();
        }
        private void fillInfo()
        {
            ghabz gh = new ghabz();

            txtid.Text = gh.Selectmaxid();

            DataTable lastmablagh = gh.Search("select top 1(mablagh) from ghabz order by id desc");

            if (lastmablagh.Rows.Count > 0)
            {
                txtmablagh.Text = lastmablagh.Rows[0][0].ToString();
            }
            else
            {
                txtmablagh.Text = "0";
            }

            txtdate.Text  = cur_date;
            txtsharh.Text = "";

            std       st        = new std();
            DataTable dtstdname = new DataTable();

            dtstdname     = st.Search("SELECT stdno,name FROM std where stdno=" + stdno);
            txtname.Text  = dtstdname.Rows[0]["name"].ToString();
            txtstdno.Text = dtstdname.Rows[0]["stdno"].ToString();

            txtlastdate.Text = Date.returnLastDateOfaDate(txtdate.Text);

            groupBox1.Focus();
            txtname.Focus();
        }
예제 #4
0
        private void btnfilter_Click(object sender, EventArgs e)
        {
            //     try
            //     {
            Boolean check = false;

            string SQL = "select * from ghabz where ";

            check = false;


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

            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 + "lastdate>=N'" + txtlastdatefrom.Text.Trim() + "'AND ";
                check = true;
            }

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

            ghabz     rm = new ghabz();
            DataTable dt = new DataTable();

            dt = rm.Search(SQL);
            grdDataViewer.DataSource = dt;

            //}
            //catch (Exception)
            //{
            //    MessageBox.Show("لطفا اطلاعات را به صورت درست وارد نمایید!!!");
            //    txtname.Text = "";
            //}
        }