protected void Expense_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex;

            if (e.CommandName.Equals("Company"))
            {
                rowIndex  = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                AccountID = UIHelper.ParseShort(ctlExpenseInfoGrid.DataKeys[rowIndex].Values["AccountID"].ToString());
                ctlExpenseInfoGrid.SelectedIndex = rowIndex;
                ctlCompanyInfoEditor.Initialize(AccountID);
                ctlCompanyInfoEditor.ShowDetail();
            }
            if (e.CommandName.Equals("ExpenseInfoEdit"))
            {
                rowIndex       = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                ExpenseGroupID = UIHelper.ParseShort(ctlExpenseInfoGrid.DataKeys[rowIndex].Values["ExpenseGroupID"].ToString());
                AccountID      = UIHelper.ParseShort(ctlExpenseInfoGrid.DataKeys[rowIndex].Values["AccountID"].ToString());
                ctlAccountLangEditor.Initialize(FlagEnum.EditFlag, AccountID, ExpenseGroupID);
                ctlAccountLangEditor.ShowPopUp();
            }
            if (e.CommandName.Equals("ExpenseInfoDelete"))
            {
                try
                {
                    rowIndex       = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex;
                    ExpenseGroupID = UIHelper.ParseShort(ctlExpenseInfoGrid.DataKeys[rowIndex].Values["ExpenseGroupID"].ToString());
                    AccountID      = UIHelper.ParseShort(ctlExpenseInfoGrid.DataKeys[rowIndex].Values["AccountID"].ToString());
                    DbAccount ac = ScgDbQueryProvider.DbAccountQuery.FindAccountByEGroupIDAID(ExpenseGroupID, AccountID);
                    DbAccountService.DeleteAccount(ac);
                    ctlCompanyInfoEditor.HideDetail();
                }
                catch (Exception ex)
                {
                    if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                                "alert('This data is now in use.');", true);
                        ctlExpenseInfoGrid.DataCountAndBind();
                    }
                }

                ctlExpenseInfoGrid.DataCountAndBind();
                ctlExpenseInfoUpdatePanel.Update();
            }
        }
Пример #2
0
        protected void ctlAdd_Click(object sender, ImageClickEventArgs e)
        {
            DbAccount account = new DbAccount();

            if (Mode.Equals(FlagEnum.EditFlag))
            {
                account.AccountID = AcountID;
            }
            account.AccountCode            = ctlExpenseCode.Text;
            account.Active                 = ctlActive.Checked;
            account.CreBy                  = UserAccount.UserID;
            account.CreDate                = DateTime.Now;
            account.DomesticRecommend      = ctlDomesticRecommend.Checked;
            account.ExpenseGroupID         = ExpenseGroupID;
            account.ForeignRecommend       = ctlForeignRecommend.Checked;
            account.SaveAsDebtor           = ctlSaveAsDebtor.Checked;
            account.SaveAsVendor           = ctlSaveAsVendor.Checked;
            account.SAPSpecialGL           = ctlspecialGL.Text;
            account.SAPSpecialGLAssignment = ctlSAPSpecialGLAssignment.Text;
            account.TaxCode                = Convert.ToInt32(ctlTaxCode.SelectedValue);
            account.CostCenter             = Convert.ToInt32(ctlCostCenter.SelectedValue);
            account.InternalOrder          = Convert.ToInt32(ctlInternalOrder.SelectedValue);
            account.SaleOrder              = Convert.ToInt32(ctlSaleOrder.SelectedValue);
            account.UpdBy                  = UserAccount.UserID;
            account.UpdDate                = DateTime.Now;
            account.UpdPgm                 = UserAccount.CurrentProgramCode;

            #region check for exception

            #endregion
            try
            {
                // save or update PB
                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    DbAccountService.UpdateAccount(account);
                }
                else
                {
                    account.AccountID = DbAccountService.AddNewAccount(account);
                }

                // save or update PBlang
                IList <DbAccountLang> list = new List <DbAccountLang>();

                foreach (GridViewRow row in ctlAccountLangGrid.Rows)
                {
                    short languageId = UIHelper.ParseShort(ctlAccountLangGrid.DataKeys[row.RowIndex]["LanguageID"].ToString());

                    TextBox  Description = row.FindControl("ctrDescription") as TextBox;
                    TextBox  Comment     = (TextBox)row.FindControl("ctrComment") as TextBox;
                    CheckBox Active      = (CheckBox)row.FindControl("ctlActive") as CheckBox;

                    if ((!string.IsNullOrEmpty(Description.Text)))
                    {
                        DbAccountLang accountLang = new DbAccountLang();
                        accountLang.Active      = Active.Checked;
                        accountLang.CreBy       = UserAccount.UserID;
                        accountLang.CreDate     = DateTime.Now;
                        accountLang.AccountName = Description.Text;
                        accountLang.Comment     = Comment.Text;
                        accountLang.LanguageID  = new DbLanguage(languageId);
                        accountLang.Account     = account;
                        accountLang.UpdBy       = UserAccount.UserID;
                        accountLang.UpdDate     = DateTime.Now;
                        accountLang.UpdPgm      = UserAccount.CurrentLanguageCode;
                        list.Add(accountLang);
                    }
                }

                if (Mode.Equals(FlagEnum.EditFlag))
                {
                    DbAccountLangService.UpdateListAccountLang(list);
                }
                if (Mode.Equals(FlagEnum.NewFlag))
                {
                    DbAccountLangService.AddListAccountLang(list);
                }

                Notify_Ok(sender, e);
            }
            catch (ServiceValidationException ex)
            {
                this.ValidationErrors.MergeErrors(ex.ValidationErrors);
            }
        }
Пример #3
0
        public static string GetAccountCodeExpMapping(string accountCode, string expenseGroupType)
        {
            DbAccountService service = new DbAccountService();

            return(service.GetAccountCodeExpMapping(accountCode, expenseGroupType));
        }