예제 #1
0
        private void gridMaster_EditingControlShowing_1(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            try
            {
                int row = gridMaster.CurrentCell.RowIndex;
                int column = gridMaster.CurrentCell.ColumnIndex;
                string headerText = gridMaster.Columns[column].Name;

                if (headerText.Equals("Ma_vat_tu"))
                {
                    TextBox tb = e.Control as TextBox;
                    clsDMVatTu vattu = new clsDMVatTu();
                    if (tb != null)
                    {
                        tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                        tb.AutoCompleteCustomSource = vattu.getListToCombobox("ma_vat_tu");// AutoCompleteLoad;
                        tb.AutoCompleteSource = AutoCompleteSource.CustomSource;
                    }

                }
                if (headerText.Equals("Chat_luong"))
                {
                    TextBox tb = e.Control as TextBox;
                    clsDMChatLuong cl = new clsDMChatLuong();
                    if (tb != null)
                    {
                        tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                        tb.AutoCompleteCustomSource = cl.getListToCombobox("loai_chat_luong");// AutoCompleteLoad;
                        tb.AutoCompleteSource = AutoCompleteSource.CustomSource;
                    }

                }
                if (headerText.Equals("Ten_vat_tu"))
                {
                    TextBox tb = e.Control as TextBox;
                    clsDMVatTu cl = new clsDMVatTu();
                    if (tb != null)
                    {
                        tb.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                        tb.AutoCompleteCustomSource = cl.getListToCombobox("Ten_vat_tu");// AutoCompleteLoad;
                        tb.AutoCompleteSource = AutoCompleteSource.CustomSource;
                    }

                }

            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
예제 #2
0
        private void gridMaster_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int column = gridMaster.CurrentCell.ColumnIndex;
                string forcus = gridMaster.Columns[column].Name;
                int row = gridMaster.CurrentCell.RowIndex;
                if (forcus.ToLower().Equals("ma_vat_tu"))
                {

                    clsDMVatTu vattu = new clsDMVatTu();
                    string mavattu = gridMaster.Rows[row].Cells["Ma_vat_tu"].Value.ToString();
                    DataTable temp = vattu.getData_By_MaVatTu(mavattu);
                    if (temp == null)
                        return;
                    gridMaster.Rows[row].Cells["Ten_vat_tu"].Value = temp.Rows[0]["ten_vat_tu"];
                    gridMaster.Rows[row].Cells["Ten_don_vi_tinh"].Value = temp.Rows[0]["Ten_don_vi_tinh"];
                    gridMaster.Rows[row].Cells["Don_gia"].Value = temp.Rows[0]["Don_gia"];
                    gridMaster.Rows[row].Cells["id_don_vi_tinh"].Value = temp.Rows[0]["id_don_vi_tinh"];
                }
                if (forcus.ToLower().Equals("ten_vat_tu"))
                {

                    clsDMVatTu vattu = new clsDMVatTu();
                    string tenvattu = gridMaster.Rows[row].Cells["Ten_vat_tu"].Value.ToString();
                    DataTable temp = vattu.getTenVatTuData(tenvattu);
                    if (temp == null)
                        return;
                    gridMaster.Rows[row].Cells["Ma_vat_tu"].Value = temp.Rows[0]["Ma_vat_tu"];
                    gridMaster.Rows[row].Cells["Ten_don_vi_tinh"].Value = temp.Rows[0]["Ten_don_vi_tinh"];
                    gridMaster.Rows[row].Cells["Don_gia"].Value = temp.Rows[0]["Don_gia"];
                    gridMaster.Rows[row].Cells["id_don_vi_tinh"].Value = temp.Rows[0]["id_don_vi_tinh"];
                }
                // gridMaster.Rows[row].Cells["Chat_luong"].Selected = true;
                //gridMaster.CurrentCell = gridMaster.Rows[row].Cells["Chat_luong"];
                //gridMaster.BeginEdit(true);
                //gridMaster.CurrentCell.Selected = true;
                clsDMChatLuong cl = new clsDMChatLuong();

                string ten_chat_luong = gridMaster.Rows[row].Cells["chat_luong"].Value == null ? "" : gridMaster.Rows[row].Cells["chat_luong"].Value.ToString();
                if (ten_chat_luong != "")
                {
                    gridMaster.Rows[row].Cells["id_chat_luong"].Value = cl.getIDChatLuong(ten_chat_luong);

                }
            }
            catch (Exception ex) { }
        }
        private void init_cbChatLuong()
        {
            cbChatLuong.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            cbChatLuong.AutoCompleteSource = AutoCompleteSource.CustomSource;

            clsDMChatLuong ChatLuong = new clsDMChatLuong();
            AutoCompleteStringCollection combData1 = ChatLuong.getListLoaiChatLuong();

            cbChatLuong.AutoCompleteCustomSource = combData1;

            cbChatLuong.DataSource = ChatLuong.GetAllData();
            cbChatLuong.ValueMember = "Id_chat_luong";
            cbChatLuong.DisplayMember = "Loai_chat_luong";

            cbChatLuong.SelectedIndex = -1;
        }