예제 #1
0
 /// <summary>
 /// Handles the Click event of the btnCalculatePrice 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 btnCalculatePrice_Click(object sender, EventArgs e)
 {
     // check chứng từ xuất kho
     if (!_iNInwardOutwardsPresenter.CheckExistVoucher(dateTimeRangeV1.FromDate, dateTimeRangeV1.ToDate,
                                                       InventoryItems))
     {
         XtraMessageBox.Show("Không có chứng từ xuất kho vật tư nào trong khoảng thời gian bạn chọn!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         IModel model = new Model.Model();
         string message;
         var    lockCheck = model.GetLock();
         if (lockCheck.IsLock && ((dateTimeRangeV1.FromDate >= Convert.ToDateTime(GlobalVariable.LockVoucherDateFrom) && dateTimeRangeV1.ToDate <= Convert.ToDateTime(GlobalVariable.LockVoucherDateTo))))
         {
             XtraMessageBox.Show("Không thể thực hiện tính giá trong kỳ khóa sổ! Vui lòng chọn khoảng thời gian ngoài kỳ khóa sổ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         else
         {
             message = new InventoryItemPresenter(null).CalculateOutwardPrice(dateTimeRangeV1.FromDate, dateTimeRangeV1.ToDate, InventoryItems);
             if (message == null)
             {
                 XtraMessageBox.Show("Tính giá thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Dispose();
             }
             else
             {
                 XtraMessageBox.Show("Tính giá không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
예제 #2
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();
            }
        }