Esempio n. 1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            var roleToDel = uowPrincipal.Repository.GetAll().Where(u => u.PrincipalCode == txtPrincipalCode.Text.Trim()).FirstOrDefault();

            if (roleToDel != null)
            {
                if (DialogResult.Yes == CommonMessageHelper.ConfirmDelete())
                {
                    uowPrincipal.Repository.Delete(roleToDel);
                    var res = uowPrincipal.Commit();
                    if (!res.Item1 && res.Item2 == "Expected")
                    {
                        CommonMessageHelper.ReferredDataCannotBeDeleted();
                    }

                    if (!res.Item1 && res.Item2 == "Unexpected")
                    {
                        CommonMessageHelper.ContactAdminError();
                    }
                    btnReload.PerformClick();
                }
            }
            else
            {
                CommonMessageHelper.DataNotFound(txtPrincipalCode.Text.Trim());
            }
        }
Esempio n. 2
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            var soToDel = _uow.Repository.GetById(txtSalesOrderId.Text.Trim());

            if (soToDel != null)
            {
                if (DialogResult.Yes == CommonMessageHelper.ConfirmDelete())
                {
                    // delete the sales order
                    soToDel.Status = Constant.RecordStatus.Inactive;
                    _uow.Repository.Update(soToDel);
                    var res = _uow.Commit();

                    if (!res.Item1 && res.Item2 == "Expected")
                    {
                        CommonMessageHelper.ReferredDataCannotBeDeleted();
                    }

                    if (!res.Item1 && res.Item2 == "Unexpected")
                    {
                        CommonMessageHelper.ContactAdminError();
                    }

                    LoadSalesOrderData(soToDel.SalesNo);
                }
            }
            else
            {
                CommonMessageHelper.DataNotFound(lblSalesNo.Text.Trim());
            }
        }
Esempio n. 3
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            var currentProductCode = GetCurrentProductCode();
            var prodToDel          = uowProduct.Repository.GetAll().Where(p => p.ProductCode == currentProductCode).FirstOrDefault();

            if (prodToDel != null)
            {
                if (DialogResult.Yes == CommonMessageHelper.ConfirmDelete())
                {
                    uowProduct.Repository.Delete(prodToDel);
                    var res = uowProduct.Commit();
                    if (!res.Item1 && res.Item2 == "Expected")
                    {
                        CommonMessageHelper.ReferredDataCannotBeDeleted();
                    }

                    if (!res.Item1 && res.Item2 == "Unexpected")
                    {
                        CommonMessageHelper.ContactAdminError();
                    }
                    btnReload.PerformClick();
                }
            }
            else
            {
                CommonMessageHelper.DataNotFound(GetCurrentProductCode());
            }
        }
Esempio n. 4
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            // Role SUPER cannot be deleted!
            if (txtRoleCode.Text.ToUpper().Trim() == "SUPER")
            {
                MessageBox.Show("Role SUPER tidak boleh dihapus."
                                , "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var roleToDel = uowRole.Repository.GetAll().Where(u => u.RoleCode == txtRoleCode.Text.Trim()).FirstOrDefault();

            if (roleToDel != null)
            {
                if (DialogResult.Yes == CommonMessageHelper.ConfirmDelete())
                {
                    uowRole.Repository.Delete(roleToDel);
                    var res = uowRole.Commit();
                    if (!res.Item1 && res.Item2 == "Expected")
                    {
                        CommonMessageHelper.ReferredDataCannotBeDeleted();
                    }

                    if (!res.Item1 && res.Item2 == "Unexpected")
                    {
                        CommonMessageHelper.ContactAdminError();
                    }
                    btnReload.PerformClick();
                }
            }
            else
            {
                CommonMessageHelper.DataNotFound(txtRoleCode.Text.Trim());
            }
        }
Esempio n. 5
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            var checkUser = uowUser.Repository.GetAll().Where(u => u.Username == txtUsername.Text.Trim()).FirstOrDefault();

            if (checkUser != null)
            {
                if (DialogResult.Yes == CommonMessageHelper.ConfirmDelete())
                {
                    using (var dbContextTransaction = dbContext.Database.BeginTransaction())
                    {
                        bool expectedError   = false;
                        bool unexpectedError = false;
                        var  uowUsrRole      = new UnitOfWork <UserRole>(dbContext);
                        var  usrRoleToDel    = uowUsrRole.Repository.GetAll().Where(u => u.Id == txtUserRoleId.Text.Trim()).FirstOrDefault();
                        uowUsrRole.Repository.Delete(usrRoleToDel);
                        var uRoleRes = uowUsrRole.Commit();
                        if (!uRoleRes.Item1 && uRoleRes.Item2 == "Expected")
                        {
                            expectedError = true;
                        }

                        if (!uRoleRes.Item1 && uRoleRes.Item2 == "Unexpected")
                        {
                            unexpectedError = true;
                        }

                        var uowUsr   = new UnitOfWork <User>(dbContext);
                        var usrToDel = uowUsr.Repository.GetAll().Where(u => u.Username == txtUsername.Text.Trim()).FirstOrDefault();
                        uowUsr.Repository.Delete(usrToDel);
                        var userRes = uowUsr.Commit();
                        if (!userRes.Item1 && userRes.Item2 == "Expected")
                        {
                            expectedError = true;
                        }

                        if (!userRes.Item1 && userRes.Item2 == "Unexpected")
                        {
                            unexpectedError = true;
                        }

                        if (expectedError)
                        {
                            CommonMessageHelper.ReferredDataCannotBeDeleted();
                        }
                        if (unexpectedError)
                        {
                            CommonMessageHelper.ContactAdminError();
                        }

                        dbContextTransaction.Commit();
                    }
                    btnReload.PerformClick();
                }
            }
            else
            {
                CommonMessageHelper.DataNotFound(txtUsername.Text.Trim());
            }
        }
Esempio n. 6
0
        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (string.IsNullOrEmpty(exceptionMessage))
            {
                MessageBox.Show("Proses export Data Rekapitulasi telah selesai.", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtFileLocation.Text = $"{fileLoc}.xls";
            }
            else
            {
                CommonMessageHelper.ContactAdminError();
                Logger logger = LogManager.GetCurrentClassLogger();
                logger.Error(exceptionMessage);
            }
            pnlDateRange.Enabled = true;
            pbExport.Value       = 0;

            SetUiPanel(false);
        }
Esempio n. 7
0
        private void manualBookToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Logger logger = LogManager.GetCurrentClassLogger();

            try
            {
                var path = Directory.GetCurrentDirectory();
                System.Diagnostics.Process.Start(Path.Combine(path, @"Resources\CisPosManual.pdf"));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Unexpected");
                CommonMessageHelper.ContactAdminError();
            }
            finally
            {
                LogManager.Shutdown();
            }
        }
Esempio n. 8
0
        private void NavigateRecord(RecordNavigation navigation)
        {
            SalesOrder queryResult;
            var        currSalesNo     = 1;
            var        expectedSalesNo = string.Empty;

            if (string.IsNullOrEmpty(lblSalesNo.Text))
            {
                if (navigation == RecordNavigation.First || navigation == RecordNavigation.Previous || navigation == RecordNavigation.Next)
                {
                    navigation = RecordNavigation.First;
                }
                else
                {
                    navigation = RecordNavigation.Last;
                }
            }
            else
            {
                currSalesNo = Convert.ToInt32(lblSalesNo.Text.Substring(lblSalesNo.Text.Trim().Length - 6));
            }

            switch (navigation)
            {
            case RecordNavigation.First:
                queryResult = _uow.Repository.GetAll().OrderBy(s => s.SalesNo).FirstOrDefault();
                break;

            case RecordNavigation.Previous:
                queryResult = null;
                if (currSalesNo > 1)
                {
                    expectedSalesNo = string.Concat("SO-", (currSalesNo - 1).ToString().PadLeft(6, '0'));
                    queryResult     = _uow.Repository.GetAll().Where(s => s.SalesNo == expectedSalesNo).FirstOrDefault();
                }
                break;

            case RecordNavigation.Next:
                queryResult = null;
                var lastRec = _uow.Repository.GetAll().OrderByDescending(s => s.SalesNo).FirstOrDefault();
                if (lastRec.Id != txtSalesOrderId.Text.Trim())
                {
                    expectedSalesNo = string.Concat("SO-", (currSalesNo + 1).ToString().PadLeft(6, '0'));
                    queryResult     = _uow.Repository.GetAll().Where(s => s.SalesNo == expectedSalesNo).FirstOrDefault();
                }
                break;

            case RecordNavigation.Last:
                queryResult = _uow.Repository.GetAll().OrderByDescending(s => s.SalesNo).FirstOrDefault();
                break;

            default:
                CommonMessageHelper.ContactAdminError();
                return;
            }

            if (queryResult != null)
            {
                LoadDataItem(queryResult);
            }

            SetUIButtonGroup();
        }