private void cboTaikhoan_SelectedIndexChanged(object sender, EventArgs e)
 {
     _KTTKRepo = new KTTKRepo();
     var item = _KTTKRepo.GetById(Utils.CIntDef(cboTaikhoan.SelectedValue, 0));
     if (item != null)
         txtTenTaikhoan.Text = item.TEN_TK; 
 }
Esempio n. 2
0
        private void LoadTK()
        {
            _KTTKRepo = new KTTKRepo();

            cboTaikhoan.DisplayMember = "MA_TK";
            cboTaikhoan.ValueMember = "ID";
            cboTaikhoan.DropDownColumns = "MA_TK,TEN_TK";
            cboTaikhoan.DataSource = _KTTKRepo.GetAll();
            cboTaikhoan.SelectedIndex = -1;
        }
 private void LoadTK()
 {
     _KTTKRepo = new KTTKRepo();
     List<string> list = new List<string>() { "131", "136", "141", "331", "336" };
     cboTaikhoan.DataSource = _KTTKRepo.GetByListMaTK(list);
     cboTaikhoan.DisplayMember = "MA_TK";
     cboTaikhoan.ValueMember = "ID";
     cboTaikhoan.DropDownColumns = "MA_TK,TEN_TK";
     cboTaikhoan.SelectedIndex = -1;
 }
 private void Load_Data()
 {
     try
     {
         _KTTKRepo = new KTTKRepo();
         gridData.DataSource = _KTTKRepo.GetAll();
         //_db = new dbVstoreAppDataContext(Const.builder.ConnectionString);
         //gridData.DataSource = null;
         //gridData.DataSource = _db.KT_TKs;
         //gridData.RefreshDataSource();
         //gridView1.RefreshData();
     }
     catch (Exception) { }
 }
        private void Save_Data(bool msg)
        {
            try
            {
                _KTTKRepo = new KTTKRepo();
                int i = 0;
                foreach (int pos in _listUpdate)
                {
                    int id = Utils.CIntDef(gridView1.GetRowCellValue(pos, "ID"), 0);
                    KT_TK obj = _KTTKRepo.GetById(id);
                    if (obj != null)
                    {
                        obj.MA_TK = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_TK"), "");
                        obj.TEN_TK = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_TK"), "");
                        obj.VND_DU_NO = Utils.CDblDef(gridView1.GetRowCellValue(pos, "VND_DU_NO"), 0);
                        obj.VND_DU_CO = Utils.CDblDef(gridView1.GetRowCellValue(pos, "VND_DU_CO"), 0);
                        obj.VND_PS_NO = Utils.CDblDef(gridView1.GetRowCellValue(pos, "VND_PS_NO"), 0);
                        obj.VND_PS_CO = Utils.CDblDef(gridView1.GetRowCellValue(pos, "VND_PS_CO"), 0);
                        obj.VND_CK_NO = Utils.CDblDef(gridView1.GetRowCellValue(pos, "VND_CK_NO"), 0);
                        obj.VND_CK_CO = Utils.CDblDef(gridView1.GetRowCellValue(pos, "VND_CK_CO"), 0);
                        obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DANH_DAU"), "");

                        _KTTKRepo.Update(obj);
                        i++;
                    }
                }
                _listUpdate = new List<int>();
                //if (i > 0 && msg)
                //{
                //    MessageBox.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }            
        }
 private void Save_Tick()
 {
     try
     {
         _KTTKRepo = new KTTKRepo();
         int _id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID"), 0);
         KT_TK obj = _KTTKRepo.GetById(_id);
         if (obj != null)
         {
             obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "").Trim() == "T" ? "" : "T";
             _KTTKRepo.Update(obj);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;
                _KTTKRepo = new KTTKRepo();
                //Kiểm tra đây là dòng dữ liệu mới hay cũ, nếu là mới thì mình insert
                if (view.IsNewItemRow(e.RowHandle))
                {
                    //e.RowHandle trả về giá trị int là thứ tự của dòng hiện tại
                    KT_TK obj = new KT_TK();
                    obj.MA_TK = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TK"), "");
                    obj.TEN_TK = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TK"), "");
                    obj.VND_DU_NO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_DU_NO"), 0);
                    obj.VND_DU_CO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_DU_CO"), 0);
                    obj.VND_PS_NO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_PS_NO"), 0);
                    obj.VND_PS_CO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_PS_CO"), 0);
                    obj.VND_CK_NO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_CK_NO"), 0);
                    obj.VND_CK_CO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_CK_CO"), 0);
                    obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");

                    _KTTKRepo.Create(obj);

                }
                //Cũ thì update
                else
                {
                    int id = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "ID"), 0);
                    KT_TK obj = _KTTKRepo.GetById(id);
                    if (obj != null)
                    {
                        obj.MA_TK = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TK"), "");
                        obj.TEN_TK = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TK"), "");
                        obj.VND_DU_NO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_DU_NO"), 0);
                        obj.VND_DU_CO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_DU_CO"), 0);
                        obj.VND_PS_NO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_PS_NO"), 0);
                        obj.VND_PS_CO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_PS_CO"), 0);
                        obj.VND_CK_NO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_CK_NO"), 0);
                        obj.VND_CK_CO = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "VND_CK_CO"), 0);
                        obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");

                        _KTTKRepo.Update(obj);
                    }

                }
                Load_Data();
            }
            catch (Exception ex)
            {
                e.Valid = false;
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void Remove_Data()
 {
     try
     {
         //if (_listUpdate.Count > 0)
         //{
         //    MessageBox.Show("Hãy thực hiện lưu trước khi xóa!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         //    return;
         //}
         Save_Data(false);
         _KTTKRepo = new KTTKRepo();
         int Id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID"), 0);
         _KTTKRepo.Remove(Id);
         //Id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_TK"), 0);
         //MessageBox.Show("Xóa dòng ID:" + Id + " thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Load_Data();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void Save_Duplicate()
        {
            try
            {
                if (MessageBox.Show("Bạn có muốn copy dòng này thành dòng mới?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    _KTTKRepo = new KTTKRepo();
                    KT_TK obj = new KT_TK();
                    obj.MA_TK = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MA_TK"), "");
                    obj.TEN_TK = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TEN_TK"), "");
                    obj.VND_DU_NO = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "VND_DU_NO"), 0);
                    obj.VND_DU_CO = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "VND_DU_CO"), 0);
                    obj.VND_PS_NO = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "VND_PS_NO"), 0);
                    obj.VND_PS_CO = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "VND_PS_CO"), 0);
                    obj.VND_CK_NO = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "VND_CK_NO"), 0);
                    obj.VND_CK_CO = Utils.CDblDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "VND_CK_CO"), 0);
                    obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "");

                    _KTTKRepo.Create(obj);
                    MessageBox.Show("Đã copy dòng này vào cuối bảng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 10
0
 private void LoadTKhaomon()
 {
     _KTTKRepo = new KTTKRepo();
     cboTKhaomon.DataSource = _KTTKRepo.GetByMaTK_Sub("214");
     cboTKhaomon.DisplayMember = "MA_TK";
     cboTKhaomon.ValueMember = "ID";
     cboTKhaomon.DropDownColumns = "MA_TK,TEN_TK";
     cboTKhaomon.SelectedIndex = -1;
 }
Esempio n. 11
0
 private void LoadTKChiphi()
 {
     _KTTKRepo = new KTTKRepo();
     cboTKchiphi.DataSource = _KTTKRepo.GetByMaTK_Sub("811", "6");
     cboTKchiphi.DisplayMember = "MA_TK";
     cboTKchiphi.ValueMember = "ID";
     cboTKchiphi.DropDownColumns = "MA_TK,TEN_TK";
     cboTKchiphi.SelectedIndex = -1;
 }
Esempio n. 12
0
 private void cboTKCo_KeyDown(object sender, KeyEventArgs e)
 {
     _KTTKRepo = new KTTKRepo();
     var item = _KTTKRepo.GetById(Utils.CIntDef(cboTKCo.SelectedValue, 0));
     if (item != null)
         txtTKCo.Text = item.TEN_TK;
 }
Esempio n. 13
0
 private void cboTKCo_TextChanged(object sender, EventArgs e)
 {
     _KTTKRepo = new KTTKRepo();
     var list = _KTTKRepo.GetAllToList();
     AutoCompleteStringCollection auto1 = new AutoCompleteStringCollection();
     foreach (var item in list)
     {
         auto1.Add(item.MA_TK);
     }
     cboTKCo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
     cboTKCo.AutoCompleteSource = AutoCompleteSource.CustomSource;
     cboTKCo.AutoCompleteCustomSource = auto1;
 }