Exemplo n.º 1
0
        private void BindingCombobox()
        {
            #region bien So

            var xe = new Xe { ID = 0, BienSo = "" , LOAIXE_ID = 0 };
            XeList.Insert(0, xe);

            drlBienSo.AutoCompleteMode = AutoCompleteMode.Suggest;
            drlBienSo.AutoCompleteSource = AutoCompleteSource.CustomSource;

            drlBienSo.DroppedDown = false;
            drlBienSo.Enabled = true;

            #endregion

            #region Loai xe

            var loaiXe = new LoaiXe { ID = 0, Ten = "" };
            LoaiXeList.Insert(0, loaiXe);

            cbxLoaiXe.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cbxLoaiXe.AutoCompleteSource = AutoCompleteSource.ListItems;

            cbxLoaiXe.DataSource = LoaiXeList;
            cbxLoaiXe.DroppedDown = false;
            cbxLoaiXe.DisplayMember = "Ten";
            cbxLoaiXe.ValueMember = "ID";
            cbxLoaiXe.Enabled = true;

            #endregion
            backgroundWorker1.Dispose();
            drlBienSo.Focus();
        }
Exemplo n.º 2
0
        private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            cbxLoaiXe.SelectedValue = 0;
            drlBienSo.Focus();

            Debug.WriteLine(XeVaoBenInsertRs == 0 ? string.Format("Lỗi: {0}", XeVaoBenInsertRs) : string.Format("ID: {0}", XeVaoBenInsertRs));
            backgroundWorker2.Dispose();
            backgroundWorker4.RunWorkerAsync();
            // binding new item
            if (XeId == 0 && !backgroundWorker1.IsBusy)
            {
                #region Plain solution: Just add new item to exists list without update to server
                var xe = new Xe()
                {
                    BienSo = BienSoStr
                    ,
                    LOAIXE_ID = LoaiXeInt
                };
                XeList.Insert(1, xe);
                XeListStrArray = XeList.Select(x => x.BienSo.ToLower()).ToArray();

                #endregion

                #region Chance to get new list
                //backgroundWorker1.RunWorkerAsync();
                #endregion
            }
        }