Example #1
0
    protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            e.KeepInInsertMode = true;
            ValidationUtility.ShowValidationErrors(this, e.Exception);
        }
        else
        {
            GXGridView1.TotalRecords = ViewOffer.SelectCountCached();
            GXGridView1.DataBind();

            string offerNumber = e.Values["OfferNumber"] as string;
            Offer  o           = Offer.GetByNumber(offerNumber);

            string DataKeyValue = o.ID.ToString();

            int intSelectedIndex = 0;
            int intPageIndex     = 0;
            int intGridViewPages = GXGridView1.PageCount;

            // Loop thru each page in the GridView
            for (int intPage = 0; intPage < intGridViewPages; intPage++)
            {
                // Set the current GridView page
                GXGridView1.PageIndex = intPage;
                // Bind the GridView to the current page
                GXGridView1.DataBind();
                // Loop thru each DataKey in the GridView
                for (int i = 0; i < GXGridView1.DataKeys.Count; i++)
                {
                    if (Convert.ToString(GXGridView1.DataKeys[i].Value) == DataKeyValue)
                    {
                        // If it is a match set the variables and exit
                        intSelectedIndex = i;
                        intPageIndex     = intPage;
                        break;
                    }
                }
            }

            // Set the GridView to the values found
            GXGridView1.PageIndex     = intPageIndex;
            GXGridView1.SelectedIndex = intSelectedIndex;
            GXGridView1.DataBind();

            int GXgvSelectedValue = o.ID;
            GXGridView1SelectedValue = GXgvSelectedValue;
            odsOfferPreview.SelectParameters.Clear();
            odsOfferPreview.SelectParameters.Add("id", GXgvSelectedValue.ToString());
            dvOfferPreview.DataBind();
            odsGridViewOfferItems.SelectParameters.Clear();
            odsGridViewOfferItems.SelectParameters.Add("offerID", GXgvSelectedValue.ToString());
            GridViewOfferItems.DataBind();

            mvMain.SetActiveView(viewOfferItems);
            mvOfferItems.SetActiveView(viewOfferItemsGrid);
        }
    }
Example #2
0
 protected void btnOfferItems_Click(object sender, EventArgs e)
 {
     if (GXGridView1.SelectedIndex != -1)
     {
         if (GXGridView1.SelectedDataKey != null)
         {
             int GXgvSelectedValue = Convert.ToInt32(GXGridView1.SelectedValue);
             odsOfferPreview.SelectParameters.Clear();
             odsOfferPreview.SelectParameters.Add("id", GXgvSelectedValue.ToString());
             dvOfferPreview.DataBind();
             odsGridViewOfferItems.SelectParameters.Clear();
             odsGridViewOfferItems.SelectParameters.Add("offerID", GXgvSelectedValue.ToString());
             GridViewOfferItems.DataBind();
         }
         else
         {
             int GXgvSelectedValue = GXGridView1SelectedValue;
             odsOfferPreview.SelectParameters.Clear();
             odsOfferPreview.SelectParameters.Add("id", GXgvSelectedValue.ToString());
             dvOfferPreview.DataBind();
             odsGridViewOfferItems.SelectParameters.Clear();
             odsGridViewOfferItems.SelectParameters.Add("offerID", GXgvSelectedValue.ToString());
             GridViewOfferItems.DataBind();
         }
         mvMain.SetActiveView(viewOfferItems);
         mvOfferItems.SetActiveView(viewOfferItemsGrid);
         btnNew.CssClass         = "novZapis";
         btnEdit.CssClass        = "izmeni";
         btnPreview.CssClass     = "osvezi";
         btnReport.CssClass      = "izvestaj";
         btnSearch.CssClass      = "prebaraj";
         btnAttachments.CssClass = "dokumenti";
         btnOfferItems.CssClass  = "stavki_Active";
     }
 }
Example #3
0
 protected void GXGridView1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "SingleClick")
     {
         btnEdit.Enabled        = true;
         btnOfferItems.Enabled  = true;
         btnAttachments.Enabled = true;
         btnPrint.Enabled       = true;
         int selIndex = Convert.ToInt32(e.CommandArgument);
         GXGridView1.SelectedIndex = selIndex;
         GXGridView1SelectedValue  = Convert.ToInt32(GXGridView1.SelectedValue);
         DetailsView1.DataBind();
         GridViewOfferItems.DataBind();
         dvOfferPreview.DataBind();
         dvOfferPreviewForAttachments.DataBind();
     }
     if (e.CommandName == "DoubleClick")
     {
         btnEdit.Enabled        = true;
         btnOfferItems.Enabled  = true;
         btnAttachments.Enabled = true;
         btnPrint.Enabled       = true;
         int selIndex = Convert.ToInt32(e.CommandArgument);
         GXGridView1.SelectedIndex = selIndex;
         mvMain.SetActiveView(viewOfferItems);
         mvOfferItems.SetActiveView(viewOfferItemsGrid);
         btnNew.CssClass          = "novZapis";
         btnEdit.CssClass         = "izmeni";
         btnPreview.CssClass      = "osvezi";
         btnReport.CssClass       = "izvestaj";
         btnSearch.CssClass       = "prebaraj";
         btnAttachments.CssClass  = "dokumenti";
         btnOfferItems.CssClass   = "stavki_Active";
         GXGridView1SelectedValue = Convert.ToInt32(GXGridView1.SelectedValue);
         DetailsView1.DataBind();
         GridViewOfferItems.DataBind();
         dvOfferPreview.DataBind();
         dvOfferPreviewForAttachments.DataBind();
     }
 }
Example #4
0
 protected void DetailsViewOfferItems_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
 {
     if (e.Exception != null)
     {
         e.ExceptionHandled = true;
         e.KeepInInsertMode = true;
         ValidationUtility.ShowValidationErrors(this, e.Exception);
     }
     else
     {
         int     offerID       = Convert.ToInt32(e.Values["OfferID"]);
         decimal offerItemCost = Convert.ToDecimal(e.Values["Cost"]);
         Offer   o             = Offer.Get(offerID);
         o.Cost += offerItemCost;
         Offer.Table.Context.SubmitChanges();
         odsOfferPreview.SelectParameters.Clear();
         odsOfferPreview.SelectParameters.Add("id", offerID.ToString());
         dvOfferPreview.DataBind();
         odsGridViewOfferItems.SelectParameters.Clear();
         odsGridViewOfferItems.SelectParameters.Add("offerID", offerID.ToString());
         GridViewOfferItems.DataBind();
         mvOfferItems.SetActiveView(viewOfferItemsGrid);
     }
 }