protected void ctlCurrencyForm_ItemUpdating(object sender, FormViewUpdateEventArgs e) { short currencyId = Convert.ToInt16(ctlCurrencyForm.DataKey.Value); TextBox ctlSymbol = (TextBox)ctlCurrencyForm.FindControl("ctlSymbol"); TextBox ctlComment = (TextBox)ctlCurrencyForm.FindControl("ctlComment"); CheckBox ctlActiveChk = (CheckBox)ctlCurrencyForm.FindControl("ctlActiveChk"); DbCurrency currency = DbCurrencyService.FindByIdentity(currencyId); currency.Symbol = ctlSymbol.Text; currency.Comment = ctlComment.Text; currency.Active = ctlActiveChk.Checked; currency.UpdBy = UserAccount.UserID; currency.UpdDate = DateTime.Now; currency.UpdPgm = ProgramCode; try { DbCurrencyService.UpdateCurrency(currency); ctlCurrencyGrid.DataCountAndBind(); ctlCurrencyForm.ChangeMode(FormViewMode.ReadOnly); CloseCurrencyPopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlCurrency_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex; if (e.CommandName.Equals("CurrencyEdit")) { rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; CurrencyId = UIHelper.ParseShort(ctlCurrencySetupGrid.DataKeys[rowIndex].Values["CurrencyID"].ToString()); ctlCurrencyEditor.Initialize(FlagEnum.EditFlag, CurrencyId); ctlCurrencyEditor.ShowPopUp(); } if (e.CommandName.Equals("CurrencyDelete")) { try { rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; CurrencyId = UIHelper.ParseShort(ctlCurrencySetupGrid.DataKeys[rowIndex].Value.ToString()); // delete by cascade on delete //IList<DbCurrencyLang> clang = SsDbQueryProvider.DbCurrencyLangQuery.FindCurrencyLangByCID(CurrencyId); //DbCurrencyLangService.DeleteCurrencyLang(clang); DbCurrency currency = SsDbQueryProvider.DbCurrencyQuery.FindCurrencyById(CurrencyId); DbCurrencyService.DeleteCurrency(currency); } 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); ctlCurrencySetupGrid.DataCountAndBind(); } } ctlCurrencySetupGrid.DataCountAndBind(); ctlCurrencySetupUpdatePanel.Update(); } }
protected void ctlAdd_Click(object sender, ImageClickEventArgs e) { DbCurrency currency; if (Mode.Equals(FlagEnum.EditFlag)) { currency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(CurrencyID); } else { currency = new DbCurrency(); } currency.Symbol = ctlSymbol.Text; currency.Active = ctlActive.Checked; currency.CreBy = UserAccount.UserID; currency.CreDate = DateTime.Now; currency.UpdBy = UserAccount.UserID; currency.UpdDate = DateTime.Now; currency.UpdPgm = UserAccount.CurrentProgramCode; currency.Comment = ctlComment.Text; currency.CurrencySymbol = ctlCurrencySymbol.Text; try { DbCurrencyService.SaveOrUpdate(currency); // save or update currencylang IList <DbCurrencyLang> list = new List <DbCurrencyLang>(); foreach (GridViewRow row in ctlCurrencyEditorGrid.Rows) { short languageId = UIHelper.ParseShort(ctlCurrencyEditorGrid.DataKeys[row.RowIndex]["LanguageID"].ToString()); TextBox ctrDescription = row.FindControl("ctrDescription") as TextBox; TextBox ctrComment = row.FindControl("ctrComment") as TextBox; CheckBox ctlActiveCl = row.FindControl("ctlActive") as CheckBox; TextBox ctlMainUnit = row.FindControl("ctlMainUnit") as TextBox; TextBox ctlSubUnit = row.FindControl("ctlSubUnit") as TextBox; if ((!string.IsNullOrEmpty(ctrDescription.Text)) || (!string.IsNullOrEmpty(ctrComment.Text))) { DbCurrencyLang currencyLang = new DbCurrencyLang(); currencyLang.Description = ctrDescription.Text; currencyLang.Comment = ctrComment.Text; currencyLang.Active = ctlActiveCl.Checked; currencyLang.Currency = currency; currencyLang.CreBy = UserAccount.UserID; currencyLang.CreDate = DateTime.Now; currencyLang.UpdBy = UserAccount.UserID; currencyLang.UpdDate = DateTime.Now; currencyLang.Language = new DbLanguage(languageId); currencyLang.UpdPgm = UserAccount.CurrentProgramCode; currencyLang.MainUnit = ctlMainUnit.Text; currencyLang.SubUnit = ctlSubUnit.Text; list.Add(currencyLang); } } if (Mode.Equals(FlagEnum.EditFlag)) { DbCurrencyLangService.UpdateCurrencyLang(list); } if (Mode.Equals(FlagEnum.NewFlag)) { DbCurrencyLangService.AddCurrencyLang(list); } Notify_Ok(sender, e); } catch (ServiceValidationException ex) { this.ValidationErrors.MergeErrors(ex.ValidationErrors); } }
protected void ctlCurrencyGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UserEdit") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; short currencyId = Convert.ToInt16(ctlCurrencyGrid.DataKeys[rowIndex].Value); ctlCurrencyForm.PageIndex = (ctlCurrencyGrid.PageIndex * ctlCurrencyGrid.PageSize) + rowIndex; ctlCurrencyForm.ChangeMode(FormViewMode.Edit); IList <DbCurrency> currencyList = new List <DbCurrency>(); DbCurrency currency = SsDbQueryProvider.DbCurrencyQuery.FindByIdentity(currencyId); currencyList.Add(currency); ctlCurrencyForm.DataSource = currencyList; ctlCurrencyForm.DataBind(); ctlCurrencyGrid.DataCountAndBind(); UpdatePanelCurrencyForm.Update(); ctlCurrencyModalPopupExtender.Show(); } if (e.CommandName == "UserEdit") { foreach (GridViewRow row in ctlCurrencyGrid.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelectChk")).Checked)) { try { short currencyId = UIHelper.ParseShort(ctlCurrencyGrid.DataKeys[row.RowIndex].Value.ToString()); DbCurrency currency = SsDbQueryProvider.DbCurrencyQuery.FindProxyByIdentity(currencyId); DbCurrencyService.Delete(currency); ExchangeRateGridViewFinish(); } 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); ctlCurrencyGrid.DataCountAndBind(); ctlCurrencyUpdatePanel.Update(); } } } } } if (e.CommandName == "Select") { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; string currencyId = ctlCurrencyGrid.DataKeys[rowIndex].Value.ToString();//UIHelper.ParseShort(ctlCurrencyGrid.DataKeys[rowIndex].Value.ToString()); ctlCurrencyIdHidden.Value = currencyId; ctlExchangeGrid.DataCountAndBind(); ctlExchangeButton.Visible = true; ctlExchangeGrid.Visible = true; ctlExchangeFds.Visible = true; //if (ctlExchangeGrid.Rows.Count <= 0) //{ // ctlExchangeGrid.EmptyDataText = "$No result.$"; // ctlExchangeGrid.DataBind(); //} ctlCurrencyGrid.DataCountAndBind(); ctlExchangeRateUpdatePanel.Update(); ctlCurrencyUpdatePanel.Update(); } }