コード例 #1
0
 /// <summary>
 /// Deletes the item.
 /// </summary>
 protected virtual void DeleteItem()
 {
     try
     {
         ActionMode = ActionModeEnum.Delete;
         var result = XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteContent"),
                                          ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                          MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (result == DialogResult.OK)
         {
             DeleteGrid();
             _audittingLogPresenter.Save();
             XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteResult"),
                                 ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                 MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption"),
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         LoadData();
         SetRowSelected();
         GetRowValueSelected();
     }
 }
コード例 #2
0
ファイル: FrmLogin.cs プロジェクト: blackface13/TSDAccounting
        /// <summary>
        /// Có một lỗi hay xảy ra là trường hợp tên dữ liệu được lưu trong registry không đúng, không tồn tại
        /// dẫn đến việc phát sinh lỗi, không mở được dữ liệu. Phải can thiệp khó khăn
        /// Giải pháp là kiểm tra tên dữ liệu có tồn tại không, trước khi thực hiện các lệnh khác.
        ///
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidData())
                {
                    return;
                }
                //check valid user
                _userProfilePresenter.DisplayByUserProfileName(UserProfileName, Password);
                if (UserProfileId == 0)
                {
                    XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResLoginFailded"), ResourceHelper.GetResourceValueByName("ResExceptionCaption"),
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPassword.Focus();
                }

                if (PostLoginState != null)
                {
                    PostLoginState(this, true);
                }
                LoadOption();
                GlobalVariable.LoginName = UserProfileName;
                _audittingLogPresenter.Save();
                Close();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
            }
        }
コード例 #3
0
 /// <summary>
 /// Deletes the item.
 /// </summary>
 protected void DeleteItem()
 {
     try
     {
         ActionMode = ActionModeEnum.Delete;
         var result = XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteContent"), ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                          MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (result == DialogResult.OK)
         {
             if (treeList.FindNodeByKeyID(PrimaryKeyValue).HasChildren)
             {
                 ShowErrorDeleteParent();
             }
             else
             {
                 DeleteTree();
                 _audittingLogPresenter.Save();
                 XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteResult"),
                                     ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                     MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex) { XtraMessageBox.Show(ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error); }
     finally
     {
         LoadData();
         SetRowSelected();
     }
 }
コード例 #4
0
 private void btnLock_Click(object sender, EventArgs e)
 {
     if (dtReportPeriod.ToDate >= DateTime.Parse(GlobalVariable.DBStartDate))
     //if (dtExcuteDate.DateTime >= DateTime.Parse(GlobalVariable.DBStartDate))
     {
         IsLock     = 1;
         ActionMode = ActionModeEnum.Lock;
         _dbOptionsPresenter.Save();
         _audittingLogPresenter.Save();
         GlobalVariable.LockVoucherSeason   = LockDateSeason;
         GlobalVariable.LockVoucherDateFrom = LockDateFrom.ToLongDateString();
         GlobalVariable.LockVoucherDateTo   = LockDateTo.ToLongDateString();
         RefeshForm();
         XtraMessageBox.Show("Khóa sổ thành công!",
                             "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         btnLock.Enabled   = false;
         btnUnlock.Enabled = true;
     }
     else
     {
         XtraMessageBox.Show("Ngày khóa sổ không được nhỏ hơn ngày khởi tạo dữ liệu!",
                             "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
コード例 #5
0
        /// <summary>
        /// Có một lỗi hay xảy ra là trường hợp tên dữ liệu được lưu trong registry không đúng, không tồn tại
        /// dẫn đến việc phát sinh lỗi, không mở được dữ liệu. Phải can thiệp khó khăn
        /// Giải pháp là kiểm tra tên dữ liệu có tồn tại không, trước khi thực hiện các lệnh khác.
        ///
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidData())
                {
                    return;
                }

                // Kiểm tra thông tin tài khoản đăng nhập
                var userProfileLogin = _model.GetUserProfileByUserName(this.UserName);
                if (userProfileLogin == null || !MD5Helper.VerifyMd5Hash(this.Password, userProfileLogin.Password))
                {
                    XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResLoginFailded"), ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUserProfileName.Focus();
                    return;
                }

                if (PostLoginState != null)
                {
                    PostLoginState(this, true);
                }
                LoadOption();
                GlobalVariable.LoginName  = UserName;
                GlobalVariable.PostedDate = DateTime.Now.ToShortDateString();
                IModel model = new Model.Model();
                GlobalVariable.LockVoucherDateFrom = model.GetLock().LockDate.Substring(0, 10);
                GlobalVariable.LockVoucherDateTo   = model.GetLock().LockDate.Substring(11, 10);

                _audittingLogPresenter.Save();
                Close();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Focus();
            }
        }
コード例 #6
0
        /// <summary>
        /// Handles the ItemClick event of the barToolManager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraBars.ItemClickEventArgs"/> instance containing the event data.</param>
        private void barToolManager_ItemClick(object sender, ItemClickEventArgs e)
        {
            switch (e.Item.Name)
            {
            case "barButtonAddNewItem":
                AddData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonDuplicate":
                DuplicateData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonEditItem":
                if (PrimaryKeyValue == null)
                {
                    XtraMessageBox.Show("Bạn chưa chọn chứng từ cần sửa!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                EditData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonDeleteItem":
                var deleteSuccess = false;
                try
                {
                    if (PrimaryKeyValue == null)
                    {
                        XtraMessageBox.Show("Bạn chưa chọn chứng từ cần xóa!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (_lockPresenter.CheckLockDate(Int32.Parse(PrimaryKeyValue), (int)RefTypeId))
                    {
                        var result1 = XtraMessageBox.Show("Chứng từ đang khóa sổ. Bạn phải mở sổ để xóa", "Thông báo",
                                                          MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }


                    ActionMode = ActionModeVoucherEnum.Delete;
                    var result = XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteContent"),
                                                     ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                                     MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.OK)
                    {
                        DeleteGrid();
                        _audittingLogPresenter.Save();
                        deleteSuccess = true;     //LinhMC chạy đến đây là ok rồi
                        if (((IList)bindingSource.DataSource).Count == 0)
                        {
                            bindingSourceDetail = null;
                        }
                        if (RefTypeId != RefType.InwardStock)
                        {
                            XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteResult"),
                                                ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption"));
                }
                finally
                {
                    if (deleteSuccess)
                    {
                        LoadData();
                        SetRowSelected();
                        GetRowValueSelected();
                    }
                }
                break;

            case "barButtonRefeshItem":
                LoadData();
                SetRowSelected();
                GetRowValueSelected();
                break;

            case "barButtonPrintItem":
                PrintData();
                break;

            case "barButtonHelpItem":
                ActionMode = ActionModeVoucherEnum.None;
                ShowHelp();
                break;

            case "barButtonCalculatePriceItem":
                CalculatePriceOutwardStock();
                break;
            }
            RefreshToolbar();
        }
コード例 #7
0
        /// <summary>
        /// Handles the ItemClick event of the barToolManager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraBars.ItemClickEventArgs"/> instance containing the event data.</param>
        private void barToolManager_ItemClick(object sender, ItemClickEventArgs e)
        {
            switch (e.Item.Name)
            {
            case "barButtonAddNewItem":
                AddData();
                SetRowAfterUpdate();
                break;

            case "barButtonEditItem":
                EditData();
                SetRowAfterUpdate();
                break;

            case "barButtonDeleteItem":
                try
                {
                    if (PrimaryKeyValue == null)
                    {
                        XtraMessageBox.Show("Bạn chưa chọn danh mục cần xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    ActionMode = ActionModeEnum.Delete;
                    var result = XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteContent"), ResourceHelper.GetResourceValueByName("ResDeleteCaption"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.OK)
                    {
                        if (treeList.FindNodeByKeyID(int.Parse(PrimaryKeyValue)).HasChildren)
                        {
                            XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteTreeHasChild"), ResourceHelper.GetResourceValueByName("ResDeleteCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            DeleteTree();
                            _audittingLogPresenter.Save();
                            XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteResult"), ResourceHelper.GetResourceValueByName("ResDeleteCaption"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception ex) { XtraMessageBox.Show(ex.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint") ? "Ko thể xóa đối tượng, vì đã được tồn tại trong chứng từ hoặc danh mục" : ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption")); }
                finally
                {
                    LoadData();
                    SetRowSelected();
                }
                break;

            case "barButtonRefeshItem":
                LoadData();
                SetRowSelected();
                break;

            case "barButtonPrintItem":
                PrintData();
                break;

            case "barButtonHelpItem":
                ShowHelp();
                break;

            case "barButtonFindItem":
                treeList.ShowFindPanel();
                break;
            }
            RefreshToolbar();
        }
コード例 #8
0
 /// <summary>
 /// Saves the auditing log.
 /// LINHMC add 27/8/2015
 /// </summary>
 /// <returns></returns>
 protected virtual int SaveAuditingLog()
 {
     return(_audittingLogPresenter.Save());
 }
コード例 #9
0
        /// <summary>
        /// Handles the ItemClick event of the barToolManager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="ItemClickEventArgs"/> instance containing the event data.</param>
        private void barToolManager_ItemClick(object sender, ItemClickEventArgs e)
        {
            switch (e.Item.Name)
            {
            case "barButtonAddNewItem":
                AddData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonDuplicate":
                DuplicateData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonEditItem":
                EditData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonDeleteItem":
                try
                {
                    ActionMode = ActionModeVoucherEnum.Delete;
                    var result = XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteContent"),
                                                     ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                                     MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.OK)
                    {
                        DeleteGrid();
                        _audittingLogPresenter.Save();
                        //if (RefTypeId != RefType.InwardStock)
                        //{
                        //    XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteResult"),
                        //                        ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                        //                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //}
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption"));
                }
                finally
                {
                    LoadData();
                    SetRowSelected();
                    GetRowValueSelected();
                }
                break;

            case "barButtonRefeshItem":
                LoadData();
                SetRowSelected();
                GetRowValueSelected();
                break;

            case "barButtonPrintItem":
                PrintData();
                break;

            case "barButtonHelpItem":
                ActionMode = ActionModeVoucherEnum.None;
                ShowHelp();
                break;

            case "barButtonCalculatePriceItem":
                CalculatePriceOutwardStock();
                break;
            }
            RefreshToolbar();
        }
コード例 #10
0
        /// <summary>
        /// Handles the ItemClick event of the barToolManager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraBars.ItemClickEventArgs" /> instance containing the event data.</param>
        private void barToolManager_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            switch (e.Item.Name)
            {
            case "barButtonAddNewItem":
                AddData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonEditItem":

                if (PrimaryKeyValue == null)
                {
                    XtraMessageBox.Show("Bạn chưa chọn danh mục cần sửa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                EditData();
                SetRowAfterUpdate();
                GetRowValueSelected();
                break;

            case "barButtonDeleteItem":
                try
                {
                    if (PrimaryKeyValue == null)
                    {
                        XtraMessageBox.Show("Bạn chưa chọn danh mục cần xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    ActionMode = ActionModeEnum.Delete;
                    var result = XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteContent"), ResourceHelper.GetResourceValueByName("ResDeleteCaption"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (result == DialogResult.OK)
                    {
                        DeleteGrid();
                        _audittingLogPresenter.Save();
                        XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResDeleteResult"),
                                            ResourceHelper.GetResourceValueByName("ResDeleteCaption"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint") ? "Không thể xóa đối tượng, vì đã được sử dụng trong danh mục hoặc chứng từ" : ex.Message, ResourceHelper.GetResourceValueByName("ResExceptionCaption"));
                }
                finally
                {
                    LoadData();
                    SetRowSelected();
                    GetRowValueSelected();
                }
                break;

            case "barButtonRefeshItem":
                LoadData();
                SetRowSelected();
                GetRowValueSelected();
                break;

            case "barButtonPrintItem":
                PrintData();
                break;

            case "barButtonHelpItem":
                ActionMode = ActionModeEnum.None;
                ShowHelp();
                break;
            }
            RefreshToolbar();
        }