protected void ctlExchangeDelete_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow row in ctlExchangeGrid.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelectChk")).Checked)) { try { short exchangeId = UIHelper.ParseShort(ctlExchangeGrid.DataKeys[row.RowIndex].Value.ToString()); DbExchangeRate exchangeRate = SsDbQueryProvider.DbExchangeRateQuery.FindProxyByIdentity(exchangeId); DbExchangeRateService.Delete(exchangeRate); } 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); ctlExchangeGrid.DataCountAndBind(); ctlExchangeRateUpdatePanel.Update(); } } } } ctlExchangeGrid.DataCountAndBind(); ctlExchangeRateUpdatePanel.Update(); }
protected void ctlExchangeGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UserEdit") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; short ExchangeRateId = Convert.ToInt16(ctlExchangeGrid.DataKeys[rowIndex].Value); ctlExchangeForm.PageIndex = (ctlExchangeGrid.PageIndex * ctlExchangeGrid.PageSize) + rowIndex; ctlExchangeForm.ChangeMode(FormViewMode.Edit); IList <DbExchangeRate> exchangeRateList = new List <DbExchangeRate>(); DbExchangeRate exchangeRate = SsDbQueryProvider.DbExchangeRateQuery.FindByIdentity(ExchangeRateId); exchangeRateList.Add(exchangeRate); ctlExchangeForm.DataSource = exchangeRateList; ctlExchangeForm.DataBind(); UpdatePanelExchangeForm.Update(); ctlExchangeModalPopupExtender.Show(); } }
protected void ctlExchangeForm_ItemUpdating(object sender, FormViewUpdateEventArgs e) { short exchangeRateId = Convert.ToInt16(ctlExchangeForm.DataKey.Value); //modify by tom 28/01/2009 //SCG.eAccounting.Web.UserControls.Calendar ctlFromDateCalendar = ctlExchangeForm.FindControl("Calendar1") as SCG.eAccounting.Web.UserControls.Calendar; //SCG.eAccounting.Web.UserControls.Calendar ctlToDateCalendar = ctlExchangeForm.FindControl("Calendar2") as SCG.eAccounting.Web.UserControls.Calendar; UserControls.Calendar ctlFromDateCalendar = ctlExchangeForm.FindControl("Calendar1") as UserControls.Calendar; UserControls.Calendar ctlToDateCalendar = ctlExchangeForm.FindControl("Calendar2") as UserControls.Calendar; TextBox ctlFromDate = ctlFromDateCalendar.FindControl("txtDate") as TextBox; TextBox ctlToDate = ctlToDateCalendar.FindControl("txtDate") as TextBox; TextBox ctlBuyRate = (TextBox)ctlExchangeForm.FindControl("ctlBuyRate"); TextBox ctlSellRate = (TextBox)ctlExchangeForm.FindControl("ctlSellRate"); TextBox ctlComment = (TextBox)ctlExchangeForm.FindControl("ctlComment"); CheckBox ctlActiveChk = (CheckBox)ctlExchangeForm.FindControl("ctlActiveChk"); DateTime NewDate = new DateTime(); float newFloat = new float(); DbExchangeRate exchangeRate = DbExchangeRateService.FindByIdentity(exchangeRateId); if (!string.IsNullOrEmpty(ctlFromDate.Text)) { //exchangeRate.FromDate = UIHelper.ParseDate(ctlFromDateCalendar.DateValue, UserCulture).Value; //UIHelper.ParseDate("12-Jan-2009").Value; } else { exchangeRate.FromDate = NewDate; } if (!string.IsNullOrEmpty(ctlToDate.Text)) { //exchangeRate.ToDate = UIHelper.ParseDate(ctlToDateCalendar.DateValue, UserCulture).Value; //UIHelper.ParseDate("12-Jan-2009").Value; } else { exchangeRate.ToDate = NewDate; } if (!string.IsNullOrEmpty(ctlBuyRate.Text)) { try { exchangeRate.BuyRate = Convert.ToSingle(ctlBuyRate.Text); } catch (FormatException) { ValidationErrors.AddError("Currency.Error", new Spring.Validation.ErrorMessage("BuyrateFormat")); } } else { exchangeRate.BuyRate = newFloat; } if (!string.IsNullOrEmpty(ctlSellRate.Text)) { try { exchangeRate.SellRate = Convert.ToSingle(ctlSellRate.Text); } catch (FormatException) { ValidationErrors.AddError("Currency.Error", new Spring.Validation.ErrorMessage("SellrateFormat")); } } else { exchangeRate.SellRate = newFloat; } exchangeRate.Comment = ctlComment.Text; exchangeRate.Active = ctlActiveChk.Checked; exchangeRate.UpdBy = UserAccount.UserID; exchangeRate.UpdDate = DateTime.Now; exchangeRate.UpdPgm = ProgramCode; try { DbExchangeRateService.UpdateExchangeRate(exchangeRate); ctlExchangeGrid.DataCountAndBind(); ctlExchangeForm.ChangeMode(FormViewMode.ReadOnly); CloseExchangePopUp(); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } }