Ejemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            std_history sh = new std_history();

            sh.stdno = txtstdno.Text;
            DataTable dt = sh.Search("select sum (bedehkari- bestankari) as bedsum from std_history where (stdno=N'" + txtstdno.Text + "' and radif>1)");

            long   sumbed        = 0;
            long   newmandeh     = long.Parse(txtmandeh.Text);
            long   mandehafter   = 0;
            string tashkhisafter = "";

            if (txttashkhis.Text.Equals("بستانکار"))
            {
                newmandeh = -newmandeh;
            }

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["bedsum"].ToString().Trim().Equals("") || dt.Rows[0]["bedsum"].ToString().Trim().Equals("NULL"))
                {
                    sumbed = 0;
                }
                else
                {
                    sumbed = long.Parse(dt.Rows[0]["bedsum"].ToString());
                }

                //sumbed = Math.Abs(sumbed);

                mandehafter = newmandeh - sumbed;

                if (mandehafter >= 0)
                {
                    sh.bestankari = 0;
                    sh.bedehkari  = mandehafter;
                    tashkhisafter = "بدهکار";
                }
                else
                {
                    sh.bedehkari  = 0;
                    sh.bestankari = Math.Abs(mandehafter);
                    tashkhisafter = "بستانکار";
                }

                sh.tashkhis = tashkhisafter;
                sh.mandeh   = Math.Abs(mandehafter);
                sh.UpdateAfterMandehChanged();
            }
            this.Close();
        }
Ejemplo n.º 2
0
        private void btnfilter_Click(object sender, EventArgs e)
        {
            try
            {
                Boolean check = false;

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


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


                if (txtfrom_date.MaskCompleted)
                {
                    SQL   = SQL + "date>=N'" + txtfrom_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);
                }

                std_history sickh = new std_history();
                DataTable   dt    = new DataTable();
                dt = sickh.Search(SQL);

                ///////////////////////////////////////////////////////////////////
                dataGridView1.DataSource = dt;

                dataGridView1.Columns[0].HeaderText = "ردیف";
                dataGridView1.Columns[0].Width      = 50;
                dataGridView1.Columns[1].HeaderText = "کد قبض";
                dataGridView1.Columns[1].Width      = 70;
                dataGridView1.Columns[2].HeaderText = "شماره هنرجو";
                dataGridView1.Columns[2].Width      = 100;
                dataGridView1.Columns[3].HeaderText = "شرح";
                dataGridView1.Columns[3].Width      = 170;
                dataGridView1.Columns[4].HeaderText = "تاریخ";
                dataGridView1.Columns[4].Width      = 70;
                dataGridView1.Columns[5].HeaderText = "بدهکار";
                dataGridView1.Columns[5].Width      = 80;
                dataGridView1.Columns[6].HeaderText = "بستانکار";
                dataGridView1.Columns[6].Width      = 80;
                dataGridView1.Columns[7].HeaderText = "تشخیص";
                dataGridView1.Columns[7].Width      = 80;
                dataGridView1.Columns[8].HeaderText = "مانده";
                dataGridView1.Columns[8].Width      = 80;

                std si = new std();
                si.stdno     = txtstdno.Text;
                txtname.Text = si.Selectforedit().Rows[0]["name"].ToString();

                if (dataGridView1.Rows.Count > 0)
                {
                    dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
                }

                DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
                dataGridViewCellStyle1.BackColor = Color.LightBlue;
                dataGridViewCellStyle1.Font      = new Font("tahoma", 8, FontStyle.Bold);
                dataGridViewCellStyle1.Format    = "N0";
                dataGridViewCellStyle1.NullValue = null;
                dataGridView1.Columns["bedehkari"].DefaultCellStyle  = dataGridViewCellStyle1;
                dataGridView1.Columns["bestankari"].DefaultCellStyle = dataGridViewCellStyle1;
                dataGridView1.Columns["mandeh"].DefaultCellStyle     = dataGridViewCellStyle1;
            }

            catch (Exception)
            {
                MessageBox.Show("اطلاعاتی موجود نمی باشد!!!");
                txtstdno.Text = "";
            }
        }