Beispiel #1
0
        //protected void ctlCurrencyDelete_Click(object sender, ImageClickEventArgs e)
        //{
        //    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();
        //                }
        //            }
        //        }
        //    }
        //    ctlCurrencyGrid.DataCountAndBind();
        //    ctlCurrencyUpdatePanel.Update();
        //}

        protected void ctlAddNew_Click(object sender, ImageClickEventArgs e)
        {
            ctlCurrencyModalPopupExtender.Show();
            ctlCurrencyForm.ChangeMode(FormViewMode.Insert);
            ctlCurrencyGrid.DataCountAndBind();
            UpdatePanelCurrencyForm.Update();
        }
Beispiel #2
0
        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();
            }
        }