Esempio n. 1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DM_Intent_Type data = mListViewData.SelectedObject as DM_Intent_Type;

            if (data != null && data.DM_Intent_TypeID > 0)
            {
                if (SanitaMessageBox.Show("Bạn có chắc chắn muốn xóa loại chủ đề này không ?", "Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    //Check xem có Entity nào ko
                    IList <DM_Entity_Type> listcheck = DM_Entity_Type.GetDefaultList(0).Where(p => p.DM_Entity_TypeID == data.DM_Intent_TypeID).ToList();
                    if (listcheck.Count == 0)
                    {
                        if (DM_Intent_TypePresenter.DeleteDM_Intent_Type(data) > 0)
                        {
                            DoRefresh();
                        }
                    }
                    else
                    {
                        SanitaMessageBox.Show("Loại chủ đề đã tồn tại đối tượng !", "Thông Báo".Translate());
                        return;
                    }
                }
            }
        }
Esempio n. 2
0
        private void bwAsync_Worker(object sender, DoWorkEventArgs e)
        {
            ProcessingType type = (ProcessingType)e.Argument;

            e.Result = type;

            switch (type)
            {
            case ProcessingType.SaveData:
            {
                if (mDM_Intent_Type.DM_Intent_TypeID > 0)
                {
                    DM_Intent_TypePresenter.UpdateDM_Intent_Type(mDM_Intent_Type);
                }
                else
                {
                    if (DM_Intent_TypePresenter.InsertDM_Intent_Type(mDM_Intent_Type) > 0)
                    {
                        //Tăng số ID lên
                        mDM_Intent_Type.DM_Intent_TypeID = mDM_Intent_Type.DM_Intent_TypeDBID + 10000;
                        DM_Intent_TypePresenter.UpdateDM_Intent_Type(mDM_Intent_Type);
                    }
                }
            }
            break;

            default:
                break;
            }
        }
Esempio n. 3
0
        private void bwAsync_DoWork(object sender, DoWorkEventArgs e)
        {
            Stopwatch mStopWatch = new Stopwatch();

            mStopWatch.Start();

            SanitaLogEx.d(TAG, "Start database cache...");
            PostMessage("Start database cache ...");
            IsCacheCompleted = false;

            try
            {
                //Update timer
                SystemInfo.NOW = SoftUpdatePresenter.GetCurrentTime(null, null);

                //Kiểm tra và nâng cấp cấu trúc database
                Splasher.Status = "Check and update database...";
                SoftUpdatePresenter.DoUpdateDatabaseSQL();

                using (IDbConnection connection = SoftUpdatePresenter.GetConnection())
                {
                    //Open connection
                    connection.Open();

                    //Begin transtation
                    using (IDbTransaction trans = connection.BeginTransaction())
                    {
                        Splasher.Status = "Đang xử lý : Danh sách danh mục...".Translate();
                        DM_Intent_Type.InitDefaultList(DM_Intent_TypePresenter.GetDM_Intent_Types(connection, trans));
                        MyVar.mListDM_Intent_Type = DM_Intent_Type.GetDefaultList(0).OrderBy(p => p.DM_Intent_TypeID).ToList();

                        DM_Entity_Type.InitDefaultList(DM_Entity_TypePresenter.GetDM_Entity_Types(connection, trans));
                        MyVar.mListDM_Entity_Type = DM_Entity_Type.GetDefaultList(0).OrderBy(p => p.DM_Entity_TypeID).ToList();

                        MyVar.mListUser   = UserPresenter.GetUsers(connection, trans);
                        MyVar.mListHome   = HomePresenter.GetHomes(connection, trans);
                        MyVar.mListRoom   = RoomPresenter.GetRooms(connection, trans);
                        MyVar.mListDevice = DevicePresenter.GetDevices(connection, trans);

                        //-----------------------------------------------------------------------------

                        //Commit transtation
                        trans.Commit();

                        //Close connection
                        connection.Close();
                    }
                }

                SanitaLogEx.d(TAG, "End database cache...");
            }
            catch (Exception ex)
            {
                SanitaLogEx.e(TAG, "bwAsync_DoWork error !", ex);
            }

            IsCacheCompleted = true;
        }
Esempio n. 4
0
        private void bwAsync_Worker(object sender, DoWorkEventArgs e)
        {
            ProcessingType type = (ProcessingType)e.Argument;

            e.Result = type;

            switch (type)
            {
            case ProcessingType.LoadData:
            {
                DM_Intent_Type.InitDefaultList(DM_Intent_TypePresenter.GetDM_Intent_Types(null, null));
                mListDM_Intent_Type       = DM_Intent_Type.GetDefaultList(1).OrderBy(p => p.DM_Intent_TypeID).ToList();
                MyVar.mListDM_Intent_Type = DM_Intent_Type.GetDefaultList(0).OrderBy(p => p.DM_Intent_TypeID).ToList();
            }
            break;

            default:
                break;
            }
        }