Пример #1
0
        public List <Viewtable.ComboboxItem> Getcomboudata()
        {
            List <Viewtable.ComboboxItem> dataCollection = new List <Viewtable.ComboboxItem>();
            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext dc  = new LinqtoSQLDataContext(connection_string);

            var rs = from tblCustomer in dc.tblCustomers
                     where tblCustomer.Reportsend == true
                     select tblCustomer;


            string drowdowvalue = "";

            if (rs.Count() > 0)
            {
                foreach (var item in rs)
                {
                    drowdowvalue = item.Customer.ToString() + " " + item.Name_1;


                    Viewtable.ComboboxItem itemcb = new Viewtable.ComboboxItem();
                    itemcb.Text  = drowdowvalue;
                    itemcb.Value = item.Customer.ToString();



                    dataCollection.Add(itemcb);
                }

                return(dataCollection);
            }
            return(null);
        }
        private void comboBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            this.cb_onlycode.CheckState = CheckState.Checked;

            if (e.KeyChar == (char)Keys.Enter)
            {
                #region  onlycode data

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

                try
                {
                    //   List<Viewtable.ComboboxItem> dataCollection = new List<Viewtable.ComboboxItem>();

                    //     tblCustomer t = new tblCustomer();
                    //  t.Name_1
                    List <Viewtable.ComboboxItem> dataCollection2 = new List <Viewtable.ComboboxItem>();

                    //var ListCustomre = db.ExecuteQuery<tblCustomer>(@"SELECT * FROM tblCustomer WHERE Cusromergroup IN (SELECT DISTINCT Cusromergroup
                    //                                                                                               FROM tblCustomer
                    //                                                                                                WHERE tblCustomer.Reportsend = 'True'
                    //                                                                                                 And  Customer like {0}
                    //                                                                                                       )", input_onlycode.Text).AsQueryable();

                    var ListCustomre = from pp in dc.tblCustomers
                                       where pp.Reportsend == true &&
                                       Convert.ToInt32(pp.Cusromergroup).ToString().Contains(input_onlycode.Text)
                                       select pp;


                    Selectcodechoice hh = new Selectcodechoice(ListCustomre, dc, "PLEASE SELECT CODE !");


                    hh.ShowDialog();
                    //  int id = view.id;
                    if (hh.Customernumber > 0)
                    {
                        Viewtable.ComboboxItem itemcb = new Viewtable.ComboboxItem();

                        itemcb.Value = hh.Customernumber;
                        itemcb.Text  = hh.Customernumber.ToString();

                        dataCollection2.Add(itemcb);
                        input_onlycode.DataSource    = dataCollection2;
                        input_onlycode.SelectedIndex = 0;
                        lbnamecode.Text = hh.Customernumber + ": " + hh.Name_1;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                #endregion
            }
        }
        public PrintLetterOption()
        {
            InitializeComponent();
            lbnamecode.Text = "";
            this.choice     = 0;
            //   this.cb_printall.CheckState = CheckState.Checked;
            this.cb_groupprit.CheckState      = CheckState.Unchecked;
            this.cb_onlycode.CheckState       = CheckState.Unchecked;
            this.cb_fromcodetocode.CheckState = CheckState.Unchecked;


            #region  customer senđing grup data



            //try
            //{
            List <Viewtable.ComboboxItem> dataCollection = new List <Viewtable.ComboboxItem>();


            string connection_string = Utils.getConnectionstr();
            LinqtoSQLDataContext db  = new LinqtoSQLDataContext(connection_string);
            db.CommandTimeout = 0;

            var ListCustomre = db.ExecuteQuery <string>("SELECT DISTINCT SendingGroup FROM tblCustomer WHERE tblCustomer.Reportsend = 'true'").ToList();



            foreach (var item in ListCustomre)
            {
                if (item != null)
                {
                    Viewtable.ComboboxItem itemcb = new Viewtable.ComboboxItem();

                    itemcb.Value = item;
                    itemcb.Text  = item;

                    dataCollection.Add(itemcb);
                }
            }


            input_groupcode.DataSource = dataCollection;



            //   }
            //catch (Exception ex)
            //{

            //    MessageBox.Show(ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

            //}

            #endregion
        }