private void cmdsearch_Click(object sender, EventArgs e)
        {
            try
            {

                ProductServiceTable service = new ProductServiceTable();
                DataTable table = service.searchByProductName(txtSearch.Text.Trim());
                DataSet ds = new DataSet();
                ds.Tables.Add(table);

                if (table.Rows.Count != 0)
                {
                    panel1.Visible = true;
                    dataGrid2.DataSource = ds.Tables["Products"];

                    TotalRecord = ds.Tables["Products"].Rows.Count;
                    double tmpPageCount = (double)TotalRecord / PageSize;
                    PageCount = Convert.ToInt32(Math.Ceiling(tmpPageCount));

                   // tsRecordCount.Text = TotalRecord.ToString() + " รายการ";
                    CurrentPage = 1;
                    RecordToDisplay = 0;
                    ShowRecord(CurrentPage);
                    FormatDgvProduct("Products2");
                    lbltotal.Visible = true;
                    lbltotal.Text = "จำนวนที่ค้นพบ :" + table.Rows.Count + " รายการ";

                }
                else
                {
                    panel1.Visible = false;
                    DataTable tablenull = new DataTable("Products");
                    DataSet dsnull = new DataSet();
                    dataGrid1.DataSource = dsnull.Tables["Products"];

                    lbltotal.Visible = true;
                    lbltotal.Text = "จำนวนที่ค้นพบ : " + tablenull.Rows.Count + " รายการ";

                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
        }
        private void loadData()
        {
            try
            {
                ProductServiceTable service = new ProductServiceTable();
                DataTable table = service.getDocCheckProductAll(); ;
                DataSet ds = new DataSet();
                ds.Tables.Add(table);
                if (table.Rows.Count != 0)
                {

                    dataGrid1.DataSource = ds.Tables["DocCheckProduct"];
                    FormatDgvProduct("DocCheckProduct");
                    label2.Visible = true;
                    label2.Text = "�ӹǹ���鹾� :" + table.Rows.Count + " ��¡��";

                }
                else
                {

                    DataTable tablenull = new DataTable("DocCheckProduct");
                    DataSet dsnull = new DataSet();
                    dsnull.Tables.Add(tablenull);
                    dataGrid1.DataSource = dsnull.Tables["DocCheckProduct"];
                    FormatDgvProduct("DocCheckProduct");
                    label2.Visible = true;
                    label2.Text = "�ӹǹ���鹾� : " + tablenull.Rows.Count + " ��¡��";

                }

            }
            catch (Exception ex) {

            }
        }
Example #3
0
        private void frmTest4_Load(object sender, EventArgs e)
        {
            ProductServiceTable service = new ProductServiceTable();

            DataTable table = new DataTable("DocCheckProductDetails");
            table = service.getDocCheckProductDetailByDCodeDataTable("1");
            DataSet ds = new DataSet();
            ds.Tables.Add(table);
            dataGrid1.DataSource = ds.Tables["DocCheckProductDetails"];
            FormatDgvProduct();
        }
        private void cmdsearch_Click(object sender, EventArgs e)
        {
            try
            {

                ProductServiceTable service = new ProductServiceTable();

                DataTable table = new DataTable("DocCheckProductDetails");
                table = service.getDocCheckProductDetailByDCodeAndPNameTable(idocCheckProduct.Code, this.txtSearch.Text.Trim());
                DataSet ds = new DataSet();
                ds.Tables.Add(table);

                if (table.Rows.Count != 0)
                {

                    dataGrid2.DataSource = ds.Tables["DocCheckProductDetails"];

                    TotalRecord = ds.Tables["DocCheckProductDetails"].Rows.Count;
                    double tmpPageCount = (double)TotalRecord / PageSize;
                    PageCount = Convert.ToInt32(Math.Ceiling(tmpPageCount));

                    //tsRecordCount.Text = TotalRecord.ToString() + " ��¡��";
                    CurrentPage = 1;
                    RecordToDisplay = 0;
                    ShowRecord(CurrentPage);

                    FormatDgvProduct("DocCheckProductDetails2");
                    label2.Visible = true;
                    label2.Text = "�ӹǹ���鹾� :" + table.Rows.Count + " ��¡��";

                    if (TotalRecord > 3)
                    {
                        panel1.Visible = true;
                    }
                    else {
                        panel1.Visible = false;
                    }

                }
                else
                {

                    DataTable tablenull = getDataTableDocCheck();
                    DataSet dsnull = new DataSet();
                    dsnull.Tables.Add(tablenull);
                    dataGrid1.DataSource = tablenull;

                    label2.Visible = true;
                    label2.Text = "�ӹǹ���鹾� : 0 ��¡��";
                    panel1.Visible = false;

                }

                checkgrid = false;
            }
               catch (NullReferenceException ex)
            {

            }
        }