Beispiel #1
0
        private void RadButton_Save_Click(object sender, RoutedEventArgs e)
        {
            decimal       qty = 1;
            decimal       price = 0;
            int           pagid, templateid;
            string        extradesc, internaldesc;
            bool          ok  = true;
            Grid          gd  = ((RadButton)e.OriginalSource).Parent as Grid;
            RadTabControl tab = gd.Parent.FindChildByType <RadTabControl>();

            //try
            //{
            //    qty = decimal.Parse(((TextBox)gd.FindName("txtQuantity")).Text);
            //}
            //catch (Exception ex)
            //{
            //    RadWindow.Alert("Please enter a valid quantity.");
            //    ok = false;
            //}
            //try
            //{
            //    price = decimal.Parse(((TextBox)gd.FindName("txtPrice")).Text);
            //}
            //catch (Exception ex)
            //{
            //    RadWindow.Alert("Please enter a valid price.");
            //    ok = false;
            //}

            //if (ok)
            //{
            pagid        = int.Parse(((TextBlock)gd.FindName("txtPAGID")).Text);
            templateid   = int.Parse(((TextBlock)gd.FindName("txttemplateID")).Text);
            extradesc    = ((TextBox)tab.FindName("txtDesc")).Text;
            internaldesc = ((TextBox)tab.FindName("txtInternalDesc")).Text;
            //               ((NotesTemplateViewModel)LayoutRoot.DataContext).UpdateNoteTemplateItem(templateid.ToString(), pagid.ToString(), qty, price, extradesc, (App.Current as App).CurrentUserId);
            //}
        }
Beispiel #2
0
        private void OptionsGrid_RowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
        {
            if (e.Visibility == Visibility.Visible)
            {
                GridViewRow row = e.Row as GridViewRow;

                if (row != null)
                {
                    SimplePAG ed          = row.DataContext as SimplePAG;
                    decimal   retailprice = 0;

                    if (row != null && ed != null)
                    {
                        StackPanel    panel       = (StackPanel)e.DetailsElement;
                        RadTabControl rtc         = (RadTabControl)panel.FindName("tabDesc");
                        CheckBox      chksitework = (CheckBox)panel.FindName("chkSitework");

                        RadTabItem im      = (RadTabItem)rtc.FindName("tabstandarddesc");
                        TextBox    txtdesc = (TextBox)im.Content;

                        RadTabItem imadd         = (RadTabItem)rtc.FindName("tabadditionaldesc");
                        Image      addionalimage = (Image)imadd.FindName("imgAdditional");

                        if (ed.AdditionalNotes.Trim() != "")
                        {
                            addionalimage.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            addionalimage.Visibility = Visibility.Collapsed;
                        }

                        RadTabItem imextra    = (RadTabItem)rtc.FindName("tabextradesc");
                        Image      extraimage = (Image)imadd.FindName("imgExtra");

                        if (ed.ExtraDescription.Trim() != "")
                        {
                            extraimage.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            extraimage.Visibility = Visibility.Collapsed;
                        }

                        RadTabItem iminternal    = (RadTabItem)rtc.FindName("tabinternaldesc");
                        Image      internalimage = (Image)imadd.FindName("imgInternal");

                        if (ed.InternalDescription.Trim() != "")
                        {
                            internalimage.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            internalimage.Visibility = Visibility.Collapsed;
                        }

                        RadComboBox cmbcategory = (RadComboBox)panel.FindName("cmbCategory");
                        GetNonStandardAreas(cmbcategory, ed.AreaID);

                        RadComboBox cmbPriceDisplay = (RadComboBox)panel.FindName("cmbPriceDisplay");
                        cmbPriceDisplay.ItemsSource   = ((AddOptionViewModel)LayoutRoot.DataContext).EstimateNonStandardPriceDisplayCode;
                        cmbPriceDisplay.SelectedValue = ed.PriceDisplayCodeId;

                        RadComboBox cmbgroup = (RadComboBox)panel.FindName("cmbGroup");
                        GetNonStandardGroups(ed.AreaID, cmbgroup, ed.GroupID);

                        if (ed.ItemAllowToChangeDisplayCode)
                        {
                            TextBlock txtPriceDisplay = (TextBlock)panel.FindName("txtPriceDisplay");
                            txtPriceDisplay.Visibility = System.Windows.Visibility.Collapsed;
                            cmbPriceDisplay.Visibility = System.Windows.Visibility.Visible;
                        }
                        else
                        {
                            TextBlock txtPriceDisplay = (TextBlock)panel.FindName("txtPriceDisplay");
                            txtPriceDisplay.Visibility = System.Windows.Visibility.Visible;
                            cmbPriceDisplay.Visibility = System.Windows.Visibility.Collapsed;
                        }

                        if (ed.AreaName.ToUpper().Contains("NON STANDARD REQUEST"))
                        {
                            cmbcategory.IsEnabled = true;
                            cmbgroup.IsEnabled    = true;
                            if (txtdesc != null)
                            {
                                txtdesc.IsReadOnly = false;
                            }
                            chksitework.IsEnabled = true;
                        }
                        else
                        {
                            cmbcategory.IsEnabled = false;
                            chksitework.IsEnabled = false;
                            cmbgroup.IsEnabled    = false;
                        }

                        if (ed.ItemAllowToChangeDescription)
                        {
                            txtdesc.IsReadOnly = false;
                        }
                        else
                        {
                            if (txtdesc != null)
                            {
                                txtdesc.IsReadOnly = true;
                            }
                        }

                        TextBox txtPrice = (TextBox)panel.FindName("txtPrice");
                        retailprice = decimal.Parse(txtPrice.Text);
                        if (!ed.ItemAllowToChangePrice)
                        {
                            txtPrice.IsReadOnly = true;
                        }
                        else
                        {
                            txtPrice.IsReadOnly = false;
                        }

                        TextBox txtQty = (TextBox)panel.FindName("txtQuantity");
                        if (!ed.ItemAllowToChangeQuantity)
                        {
                            txtQty.IsReadOnly = true;
                        }
                        else
                        {
                            txtQty.IsReadOnly = false;
                        }

                        TextBox   txtCost = (TextBox)panel.FindName("txtCostExcGST");
                        TextBlock lblCost = (TextBlock)panel.FindName("lblcost");

                        TextBox   txtMargin = (TextBox)panel.FindName("txtMargin");
                        TextBlock lblMargin = (TextBlock)panel.FindName("lblmargin");

                        if ((App.Current as App).CurrentRoleAccessModule.AccessMarginModule && ed.ItemAllowToChangePrice)// only sales estimator can change cost
                        {
                            txtCost.IsReadOnly  = false;
                            txtMargin.IsEnabled = true;
                        }
                        else
                        {
                            txtCost.IsReadOnly  = true;
                            txtMargin.IsEnabled = false;
                        }


                        CheckBox  derivedcost    = (CheckBox)panel.FindName("chkDerivedCost");
                        TextBlock lblderivedcost = (TextBlock)panel.FindName("lblderivedcost");

                        if (((App)App.Current).CurrentRoleAccessModule.AccessMarginModule)
                        {
                            if (ed.Margin.Trim() != "" && retailprice >= 0)
                            {
                                txtMargin.Text = ed.Margin.ToString() + "%";
                            }
                            else
                            {
                                txtMargin.Text = "";
                            }

                            lblMargin.Visibility      = Visibility.Visible;
                            txtMargin.Visibility      = Visibility.Visible;
                            lblCost.Visibility        = Visibility.Visible;
                            txtCost.Visibility        = Visibility.Visible;
                            lblderivedcost.Visibility = Visibility.Visible;
                            derivedcost.Visibility    = Visibility.Visible;
                        }
                        else
                        {
                            lblMargin.Visibility      = Visibility.Collapsed;
                            txtMargin.Visibility      = Visibility.Collapsed;
                            lblCost.Visibility        = Visibility.Collapsed;
                            txtCost.Visibility        = Visibility.Collapsed;
                            lblderivedcost.Visibility = Visibility.Collapsed;
                            derivedcost.Visibility    = Visibility.Collapsed;
                        }

                        TextBox txtSubtotal = (TextBox)panel.FindName("txtSubtotal");
                        txtSubtotal.IsReadOnly = true;

                        CheckBox chkAccepted = (CheckBox)panel.FindName("chkAccepted");

                        if (!EstimateList.revisiontypepermission.ReadOnly && (App.Current as App).SelectedEstimateAllowToAcceptItem)
                        {
                            chkAccepted.IsEnabled = true;
                        }
                        else
                        {
                            chkAccepted.IsEnabled = false;
                        }
                    }
                }
            }
        }