예제 #1
0
        private void LoadInsideFields()
        {
            if (QuoteItem != null)
            {
                txtQuantity.Value = QuoteItem.Quantity;
                if (QuoteItem.SaleCondition != null)
                {
                    ddlIncoterm.Value = QuoteItem.SaleCondition.ID;
                }
                ddlDeliveryTime.Value = QuoteItem.DeliveryTime;
                if (QuoteItem.DeliveryTerm != null)
                {
                    ddlDeliveryTerm.Value = QuoteItem.DeliveryTerm.ID;
                }

                txtListPrice.Value = QuoteItem.LastPrice.ToString("0.##");
                lblTP.Value        = QuoteItem.PriceCurrency.Description + " " + QuoteItem.PriceBase.PricePurchase.ToString("0.##");
                lblGrp.Text        = QuoteItem.PriceCurrency.Description + " " + QuoteItem.PriceBase.PriceSuggest.ToString("0.##");

                lblcurrency.Value = QuoteItem.PriceCurrency.Description;
                lblTpNum.Value    = QuoteItem.PriceBase.PricePurchase.ToString();
                lblGrpNum.Value   = QuoteItem.PriceBase.PriceSuggest.ToString();

                //Rango para el PL
                QuoteRange plRange = ControllerManager.QuoteRange.GetRange();
                hidMaxPL.Value = plRange.Maximum.ToString();
                hidMinPL.Value = plRange.Minimum.ToString();

                //rangos para index y ctr
                hidMinCtr.Value   = ControllerManager.QuoteRange.GetQuoteMinimumCtr();
                hidMinIndex.Value = ControllerManager.QuoteRange.GetQuoteMinimumIndex();

                hidOriginalPl.Value = QuoteItem.LastPrice.ToString("#.##");
            }
        }
예제 #2
0
        private bool AlreadyExists(string title, QuoteRange qr)
        {
            IList <QuoteRange> lst = repository.GetAll();

            lst.Remove(qr);

            return(AlreadyExists(title, lst));
        }
예제 #3
0
        public void Delete(int id)
        {
            QuoteRange qr = repository.GetById(id);

            PermissionManager.RemovePermission(qr.GetType(), qr.Title);
            repository.Delete(qr);
            repository.CommitChange();
        }
예제 #4
0
        private QuoteRange Update(QuoteRange qr, string title, Int32 max, Int32 min)
        {
            qr.Title   = title;
            qr.Maximum = max;
            qr.Minimum = min;

            repository.Save(qr);

            return(qr);
        }
예제 #5
0
        protected void LoadFields()
        {
            if (RangeId != 0)
            {
                QuoteRange qr = ControllerManager.QuoteRange.GetById(RangeId);

                txtTitle.Text   = qr.Title;
                txtMaximum.Text = qr.Maximum.ToString();
                txtMinimum.Text = qr.Minimum.ToString();
            }
        }
예제 #6
0
 public QuoteRange Create(string title, Int32 max, Int32 min)
 {
     if (!AlreadyExists(title))
     {
         QuoteRange qr = new QuoteRange();
         PermissionManager.AddEntityPermision(qr.GetType(), title);
         return(Update(qr, title, max, min));
     }
     else
     {
         throw new Exception("Title already exists.");
     }
 }
예제 #7
0
        public QuoteRange Edit(int id, string title, Int32 max, Int32 min)
        {
            QuoteRange qr = repository.GetById(id);

            if (!AlreadyExists(title, qr))
            {
                PermissionManager.UpdateEntityPermission(qr.GetType(), qr.Title, title);
                return(Update(qr, title, max, min));
            }
            else
            {
                throw new Exception("Title already exists.");
            }
        }
예제 #8
0
        private QuoteRange GetBestRange(IList <QuoteRange> lst)
        {
            Int32      amplitude = 0;
            QuoteRange bestQr    = null;

            foreach (QuoteRange qr in lst)
            {
                if (amplitude <= (qr.Maximum - qr.Minimum))
                {
                    amplitude = qr.Maximum - qr.Minimum;
                    bestQr    = qr;
                }
            }
            return(bestQr);
        }
예제 #9
0
        private bool AlreadyExists(string title, IList <QuoteRange> lstQr)
        {
            List <QuoteRange> lst = new List <QuoteRange>(lstQr);
            QuoteRange        qr  = lst.Find(delegate(QuoteRange record)
            {
                if (record.Title == title)
                {
                    return(true);
                }

                return(false);
            });

            if (qr != null)
            {
                return(true);
            }

            return(false);
        }
예제 #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            if (Convert.ToInt32(txtMaximum.Value) <= Convert.ToInt32(txtMinimum.Value))
            {
                Utils.ShowMessageInAjax(this.Page, "El Maximo debe ser mayor al Minimo.", Utils.MessageType.Error);
                return;
            }

            if (Mode == EditionMode.Edit)
            {
                try
                {
                    ControllerManager.QuoteRange.Edit(RangeId, txtTitle.Value.ToString(), Convert.ToInt32(txtMaximum.Value), Convert.ToInt32(txtMinimum.Value));
                    Mode = EditionMode.View;
                    SetVisibility();
                }
                catch (Exception)
                {
                    Utils.ShowMessageInAjax(this.Page, "Ya existe un rango con ese titulo.", Utils.MessageType.Error);
                }
            }
            else
            {
                try
                {
                    QuoteRange qr = ControllerManager.QuoteRange.Create(txtTitle.Value.ToString(), Convert.ToInt32(txtMaximum.Value), Convert.ToInt32(txtMinimum.Value));
                    RangeId = qr.ID;
                    Mode    = EditionMode.View;
                    SetVisibility();
                }
                catch (Exception)
                {
                    Utils.ShowMessageInAjax(this.Page, "Ya existe un rango con ese titulo.", Utils.MessageType.Error);
                }
            }
        }