Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            View.valueinput inputval = new valueinput("Input some text in Name to seach code", "");

            inputval.ShowDialog();

            bool   chon       = inputval.kq;
            string valueinput = inputval.valuetext;

            if (valueinput == null)
            {
                valueinput = "";
            }
            if (chon)
            {
                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

                var rscode = from tbl_KaCustomer in dc.tbl_KaCustomers
                             where tbl_KaCustomer.FullNameN.Contains(valueinput) && (tbl_KaCustomer.SapCode == true)
                             select new
                {
                    tbl_KaCustomer.Region,
                    tbl_KaCustomer.Customer,
                    tbl_KaCustomer.FullNameN,
                    tbl_KaCustomer.SapCode,
                };



                Utils ut          = new Utils();
                var   tblcustomer = ut.ToDataTable(dc, rscode);

                Viewdatatable viewtb = new Viewdatatable(tblcustomer, "Please,Choose one code !");
                viewtb.ShowDialog();
                string codetemp = viewtb.valuecode;
                string region   = viewtb.region;

                if (codetemp != "0" && chon == true && codetemp != null)
                {
                    custcode.Text    = codetemp;
                    custcode.Enabled = false;

                    textregion.Text = region;
                    cbcust.Checked  = true;
                    //  groupBox1.Enabled = true;
                    //     cbcust.Checked = true;
                }
            }
            else
            {
                custcode.Text    = "";
                custcode.Enabled = true;
                textregion.Text  = "";
                cbcust.Checked   = true;
                //     groupBox1.Enabled = false;
                //   cbcust.Checked = false;
            }
        }
Example #2
0
        private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            cbcust.Checked = false;
            if (e.KeyChar == (char)Keys.Enter)
            {
                string valueinput = custcode.Text;

                string connection_string = Utils.getConnectionstr();
                LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

                var rscode = from tbl_KaCustomer in dc.tbl_KaCustomers
                             where tbl_KaCustomer.Customer.ToString().Contains(valueinput) && (tbl_KaCustomer.SapCode == true)
                             select new
                {
                    tbl_KaCustomer.Region,
                    tbl_KaCustomer.Customer,
                    tbl_KaCustomer.FullNameN,
                    tbl_KaCustomer.SapCode,
                };



                Utils ut          = new Utils();
                var   tblcustomer = ut.ToDataTable(dc, rscode);

                Viewdatatable viewtb = new Viewdatatable(tblcustomer, "Please, choose one code !");
                viewtb.ShowDialog();
                string codetemp = viewtb.valuecode;
                string region   = viewtb.region;
                //string region  =

                if (codetemp != "0" && codetemp != null)
                {
                    custcode.Text    = codetemp;
                    custcode.Enabled = false;
                    textregion.Text  = region;
                    cbcust.Checked   = true;
                    //  groupBox1.Enabled = true;
                }
                else
                {
                    custcode.Text    = "";
                    custcode.Enabled = true;
                    textregion.Text  = "";
                    cbcust.Checked   = false;
                    //  groupBox1.Enabled = false;
                }
            }
        }