Пример #1
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());
            }
        }
Пример #2
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());
            }
        }
Пример #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());
            }
        }
Пример #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());
            }
        }
Пример #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());
            }
        }
Пример #6
0
        private void LoadSalesOrderData(string salesNo)
        {
            SalesOrder queryResult;

            queryResult = _uow.Repository.GetAll().Where(s => s.SalesNo == salesNo).FirstOrDefault();
            if (queryResult == null)
            {
                CommonMessageHelper.DataNotFound(txtSalesNo.Text.Trim());
                return;
            }
            LoadDataItem(queryResult);
        }
Пример #7
0
        private void btnReload_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(lblSalesNo.Text))
            {
                btnClear.PerformClick();
                return;
            }

            SalesOrder queryResult;

            queryResult = _uow.Repository.GetById(txtSalesOrderId.Text.Trim());
            if (queryResult == null)
            {
                CommonMessageHelper.DataNotFound(lblSalesNo.Text.Trim());
                return;
            }
            LoadDataItem(queryResult);
        }