Ejemplo n.º 1
0
        internal bool Update(Entities.TourCostRule rule, Entities.TourCostRuleConstraint constraint)
        {
            bool res = false;

            try
            {
                this.query.Parameters.Clear();

                this.query.Parameters.Add(new SqlParameter("@RuleId", rule.Id));
                this.query.Parameters.Add(new SqlParameter("@ConstraintName", constraint.Name));
                this.query.Parameters.Add(new SqlParameter("@ConstraintTypeId", constraint.ConstraintType.Id));
                this.query.Parameters.Add(new SqlParameter("@ConstraintId", constraint.Id));


                int affected;
                res = this.query.ExecuteUpdateProc("TourCostRuleConstraintUpdateById", out affected);
            }
            catch (Exception ex)
            {
                try
                {
                    DomainModel.Application.Status.Update(
                        StatusController.Abstract.StatusTypes.Error,
                        "",
                        ex.Message);
                }
                catch { }
            }

            return(res);
        }
        public bool GetProperties(object displayObject, Entities.TourCostRuleConstraint con)
        {
            Entities.ConstraintTourTime time = (Entities.ConstraintTourTime)displayObject;
            con.Properties.Clear();

            Entities.TourCostRuleConstraintProperty property;

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.StartHour;
            property.Value  = time.StartTime.Hour;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.StartMinute;
            property.Value  = time.StartTime.Minute;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.EndHour;
            property.Value  = time.EndTime.Hour;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.EndMinute;
            property.Value  = time.EndTime.Minute;
            con.Properties.Add(property);

            con.Name = GenerateName(time);

            return(true);

            return(false);
        }
Ejemplo n.º 3
0
 public FrmRuleConstraintEditor(Entities.TourCostRule rule, Entities.TourCostRuleConstraint constraintToEdit)
     : this(rule)
 {
     this.editConstraint = constraintToEdit;
     this.editConstraint.CopyTo(this.constraint);
     PrepareForEdit();
 }
        internal bool Insert(Entities.TourCostRuleConstraint constraint, Entities.TourCostRuleConstraintProperty property)
        {
            bool res = false;

            try
            {
                this.query.Parameters.Clear();

                this.query.Parameters.Add(new SqlParameter("@ConstraintId", constraint.Id));
                this.query.Parameters.Add(new SqlParameter("@PropertyTypeId", property.TypeId));
                this.query.Parameters.Add(new SqlParameter("@PropertyValue", property.Value));

                int id;
                res         = this.query.ExecuteInsertProc("TourCostRuleConstraintPropertyAdd", out id);
                property.Id = id;
            }
            catch (Exception ex)
            {
                try
                {
                    DomainModel.Application.Status.Update(
                        StatusController.Abstract.StatusTypes.Error,
                        "",
                        ex.Message);
                }
                catch { }
            }

            return(res);
        }
        public bool LoadByConstraint(Entities.TourCostRuleConstraint Constraint)
        {
            bool res = false;

            try
            {
                this.query.Parameters.Clear();
                this.query.Parameters.Add(new SqlParameter("@ConstraintId", Constraint.Id));

                res = this.query.ExecuteReader("TourCostRuleConstraintPropertyGetByConstraintId", MapCostToObject, Constraint);
            }
            catch (Exception ex)
            {
                try
                {
                    DomainModel.Application.Status.Update(
                        StatusController.Abstract.StatusTypes.Error,
                        "",
                        ex.Message);
                }
                catch { }
            }

            return(res);
        }
Ejemplo n.º 6
0
        void btnConstraintsEdit_Click(object sender, EventArgs e)
        {
            Entities.TourCostRuleConstraint con =
                (Entities.TourCostRuleConstraint)
                this.fgvConstraints.SelectedItem;

            if (con != null)
            {
                Presentation.Controllers.TourFinance.EditConstraint(this.rule, con);
            }
        }
        protected void MapCostToObject(SqlDataReader reader, object userData)
        {
            Entities.TourCostRuleConstraintProperty prop = new
                                                           Entities.TourCostRuleConstraintProperty();

            prop.Id      = Utils.GetSafeInt32(reader, "PropertyId");
            prop.TypeId  = Utils.GetSafeInt32(reader, "PropertyTypeId");
            prop.Value   = Utils.GetSafeInt32(reader, "PropertyValue");
            prop.IsDirty = false;

            Entities.TourCostRuleConstraint Constraint = (Entities.TourCostRuleConstraint)userData;
            Constraint.Properties.Add(prop);
        }
Ejemplo n.º 8
0
        public FrmRuleConstraintEditor()
        {
            this.clients    = new List <UserControl>();
            this.constraint = new Entities.TourCostRuleConstraint();

            this.clients.Add(new RuleConstraintTypeSelector(this.constraint));

            this.ctrlTourTime = new RuleConstraintTourTime(this.constraint);
            this.ctrlTourDate = new RuleConstraintTourDate(this.constraint);

            InitializeComponent();

            MoveClientForm(0);
        }
Ejemplo n.º 9
0
        protected void MapConstraintToObject(SqlDataReader reader, object userData)
        {
            Entities.TourCostRuleConstraint con = new Entities.TourCostRuleConstraint();

            con.Id             = Utils.GetSafeInt32(reader, "ConstraintId");
            con.Name           = Utils.GetSafeString(reader, "ConstraintName");
            con.ConstraintType = DomainModel.TourCostConstraintTypes.GetById(
                Utils.GetSafeInt32(reader, "ConstraintTypeId"));
            con.IsDirty = false;

            Entities.TourCostRule rule =
                (Entities.TourCostRule)userData;

            rule.Constraints.Add(con);
        }
Ejemplo n.º 10
0
        void btnConstraintsDelete_Click(object sender, EventArgs e)
        {
            Entities.TourCostRuleConstraint con =
                (Entities.TourCostRuleConstraint)
                this.fgvConstraints.SelectedItem;

            if (con != null)
            {
                if (con.Id >= 0)
                {
                    this.rule.DeletedConstraints.Add(con);
                }

                this.rule.Constraints.Remove(con);
            }
        }
Ejemplo n.º 11
0
        public bool GetProperties(object displayObject, Entities.TourCostRuleConstraint con)
        {
            Entities.ConstraintTourDate date = (Entities.ConstraintTourDate)displayObject;
            con.Properties.Clear();

            Entities.TourCostRuleConstraintProperty property;

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.StartYear;
            property.Value  = date.StartDate.Year;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.StartMonth;
            property.Value  = date.StartDate.Month;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.StartDay;
            property.Value  = date.StartDate.Day;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.EndYear;
            property.Value  = date.EndDate.Year;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.EndMonth;
            property.Value  = date.EndDate.Month;
            con.Properties.Add(property);

            property        = new Entities.TourCostRuleConstraintProperty();
            property.TypeId = (int)TypeIds.EndDay;
            property.Value  = date.EndDate.Day;
            con.Properties.Add(property);

            con.Name = GenerateName(date);

            return(true);

            return(false);
        }
Ejemplo n.º 12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.constraint != null)
            {
                this.constraint = this.currentClient.Constraint;

                if (this.editConstraint == null)
                {
                    this.rule.Constraints.Add(this.constraint);
                }
                else
                {
                    this.constraint.CopyTo(this.editConstraint);
                }
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Ejemplo n.º 13
0
 public RuleConstraintBaseUserControl(Entities.TourCostRuleConstraint constraint)
     : base()
 {
     this.Dock       = DockStyle.Fill;
     this.constraint = constraint;
 }
Ejemplo n.º 14
0
        public bool Matches(Entities.Tour tour, ITourService service, Entities.TourCostDetail detail, Entities.TourCostRuleConstraint constraint)
        {
            bool res = false;

            Entities.ConstraintTourTime time =
                (Entities.ConstraintTourTime) this.mapper.GetDisplayObject(constraint.Properties);

            if (time != null)
            {
                if (time.StartTime.Hour >= 0)
                {
                    if (tour.Time.Time.Hour < time.StartTime.Hour)
                    {
                        // Hour value of tour is
                        // less than min of the rule
                        return(res);
                    }
                    else if (tour.Time.Time.Hour == time.StartTime.Hour)
                    {
                        if (time.StartTime.Minute >= 0 &&
                            time.StartTime.Minute > tour.Time.Time.Minute)
                        {
                            // hours value are equal but
                            // minutes value of tour is
                            // less than min of rule
                            return(res);
                        }
                    }
                }
                else if (time.StartTime.Minute >= 0)
                {
                    if (time.StartTime.Minute > tour.Time.Time.Minute)
                    {
                        // hours value are equal but
                        // minutes value of tour is
                        // less than min of rule
                        return(res);
                    }
                }

                if (time.EndTime.Hour >= 0)
                {
                    if (tour.Time.Time.Hour > time.EndTime.Hour)
                    {
                        // Hour value of tour is
                        // after max of the rule
                        return(res);
                    }
                    else if (tour.Time.Time.Hour == time.EndTime.Hour)
                    {
                        if (time.EndTime.Minute >= 0 &&
                            time.EndTime.Minute > tour.Time.Time.Minute)
                        {
                            // hours value are equal but
                            // minutes value of tour is
                            // less than min of rule
                            return(res);
                        }
                    }
                }
                else if (time.EndTime.Minute >= 0)
                {
                    if (time.EndTime.Minute > tour.Time.Time.Minute)
                    {
                        // hours value are equal but
                        // minutes value of tour is
                        // less than min of rule
                        return(res);
                    }
                }

                res = true;
            }

            return(res);
        }
Ejemplo n.º 15
0
        public bool Matches(Entities.Tour tour, ITourService service, Entities.TourCostDetail detail, Entities.TourCostRuleConstraint constraint)
        {
            bool res = false;

            Entities.ConstraintTourDate date =
                (Entities.ConstraintTourDate) this.mapper.GetDisplayObject(constraint.Properties);

            if (date != null)
            {
                if (date.StartDate.Year >= 0)
                {
                    if (tour.Time.Date.Year < date.StartDate.Year)
                    {
                        // Hour value of tour is
                        // less than min of the rule
                        return(res);
                    }
                    else if (tour.Time.Date.Year == date.StartDate.Year)
                    {
                        if (date.StartDate.Month >= 0)
                        {
                            if (date.StartDate.Month > tour.Time.Date.Month)
                            {
                                return(res);
                            }
                            else if (date.StartDate.Month == tour.Time.Date.Month)
                            {
                                if (date.StartDate.Day >= 0 &&
                                    date.StartDate.Day > tour.Time.Date.Day)
                                {
                                    return(res);
                                }
                            }/*
                              * else if (date.StartDate.Day >= 0 &&
                              *     date.StartDate.Day > tour.Time.Date.Day)
                              * {
                              * return res;
                              * }*/
                        }
                        else if (date.StartDate.Day >= 0 &&
                                 date.StartDate.Day > tour.Time.Date.Day)
                        {
                            return(res);
                        }
                    }
                }
                else if (date.StartDate.Month >= 0)
                {
                    if (date.StartDate.Month > tour.Time.Date.Month)
                    {
                        return(res);
                    }
                    else if (date.StartDate.Month == tour.Time.Date.Month)
                    {
                        if (date.StartDate.Day >= 0 &&
                            date.StartDate.Day > tour.Time.Date.Day)
                        {
                            return(res);
                        }
                    }
                }
                else if (date.StartDate.Day >= 0 &&
                         date.StartDate.Day > tour.Time.Date.Day)
                {
                    return(res);
                }


                if (date.EndDate.Year >= 0)
                {
                    if (tour.Time.Date.Year > date.EndDate.Year)
                    {
                        return(res);
                    }
                    else if (tour.Time.Date.Year == date.EndDate.Year)
                    {
                        if (date.EndDate.Month >= 0)
                        {
                            if (date.EndDate.Month < tour.Time.Date.Month)
                            {
                                return(res);
                            }
                            else if (date.EndDate.Month == tour.Time.Date.Month)
                            {
                                if (date.EndDate.Day >= 0 &&
                                    date.EndDate.Day < tour.Time.Date.Day)
                                {
                                    return(res);
                                }
                            }
                        }
                        else if (date.EndDate.Day >= 0 &&
                                 date.EndDate.Day < tour.Time.Date.Day)
                        {
                            return(res);
                        }
                    }
                }
                else if (date.EndDate.Month >= 0)
                {
                    if (date.EndDate.Month < tour.Time.Date.Month)
                    {
                        return(res);
                    }
                    else if (date.EndDate.Month == tour.Time.Date.Month)
                    {
                        if (date.EndDate.Day >= 0 &&
                            date.EndDate.Day < tour.Time.Date.Day)
                        {
                            return(res);
                        }
                    }
                }
                else if (date.EndDate.Day >= 0 &&
                         date.EndDate.Day < tour.Time.Date.Day)
                {
                    return(res);
                }

                res = true;
            }

            return(res);
        }