コード例 #1
0
ファイル: frmInvoiceList.cs プロジェクト: sanatnegar/SPD
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (rbFDate.Checked == true)
            {
                if (txtFDate1.Text == "" || txtFDate2.Text == "")
                {
                    MessageBox.Show("لطفا محدوده تاریخ را وارد کنید", "خطا", MessageBoxButtons.OK);
                    return;
                }

                bool validfdate1 = G.ValidateParsianDate(txtFDate1.Text.ToString());
                bool validfdate2 = G.ValidateParsianDate(txtFDate2.Text.ToString());

                if (validfdate1 == false || validfdate2 == false)
                {
                    txtFDate1.BackColor = Color.Red;
                    txtFDate1.ForeColor = Color.White;
                    txtFDate2.BackColor = Color.Red;
                    txtFDate2.ForeColor = Color.White;
                    MessageBox.Show("تاریخ را بطور صحیح وارد کنید", "خطا", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    txtFDate1.BackColor = Color.White;
                    txtFDate1.ForeColor = Color.Black;
                    txtFDate2.BackColor = Color.White;
                    txtFDate2.ForeColor = Color.Black;
                }

                BL_frmInvoiceList A = new BL_frmInvoiceList();
                A.FD1 = txtFDate1.Text.ToString();
                A.FD2 = txtFDate2.Text.ToString();
                this.Datagridview1.DataSource = A.SelectByDate();
                UpdateDataGrid();
            }
            if (rbInvoiceNumber.Checked == true)
            {
                if (txtInvoiceNumber1.Text == "" || txtInvoiceNumber2.Text == "" || txtInvoiceNumber1.Text.Length != 6 || txtInvoiceNumber2.Text.Length != 6)
                {
                    MessageBox.Show("لطفا محدود شماره فاکتورها را به درستی وارد کنید", "خطا", MessageBoxButtons.OK);
                    return;
                }
                BL_frmInvoiceList B = new BL_frmInvoiceList();
                B.IN1 = txtInvoiceNumber1.Text.ToString();
                B.IN2 = txtInvoiceNumber2.Text.ToString();
                this.Datagridview1.DataSource = B.SelectByInvoiceNumber();
                UpdateDataGrid();
            }
        }