Beispiel #1
0
        /// <summary>
        /// Add a new Resource to the database
        /// </summary>
        public virtual Int32 Add(Model.Resource newResource)
        {
            try
            {
                Trace.WriteVerbose("({0})", Trace.GetMethodName(), CLASSNAME, newResource.ToString());
                var         helper  = Database.GetDbHelper();
                DbParameter IdParam = helper.CreateOutputParam("@Id", DbType.Int32);

                int recordsAffected = helper.ExecuteSPNonQuery(_storedProcedure_Add,
                                                               IdParam,
                                                               helper.CreateInputParam("@Code", newResource.Code),
                                                               helper.CreateInputParam("@Description", newResource.Description));

                if (recordsAffected == 0)
                {
                    throw new DalNothingUpdatedException("Unable to add Resource with Id={0}", newResource);
                }

                return((Int32)IdParam.Value);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, newResource.ToString());
                throw DbHelper.TranslateException(ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get a Resource by id from the database
        /// </summary>
        public virtual Model.Resource GetById(Int32 id)
        {
            DbDataReader reader = null;

            try
            {
                var helper = Database.GetDbHelper();

                reader = helper.ExecuteSPReader(_storedProcedure_GetById,
                                                helper.CreateInputParam("@Id", id));

                Model.Resource result = null;

                if (reader.Read())
                {
                    result = CreateResource(reader);
                }

                return(result);
            }
            catch (Exception ex)
            {
                Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, id);
                throw DbHelper.TranslateException(ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
        /// <summary>
        /// Delete the given Resource from the database
        /// </summary>
        public virtual void Delete(Model.Resource delResource)
        {
            try
            {
                Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, delResource);

                //Begin Checks
                if (!Exists(delResource))
                {
                    throw new BusinessException(string.Format("There is no Resource with this id. ({0})", delResource));
                }

                DataAccess.Resources resources = new DataAccess.Resources();
                resources.Delete(delResource);
            }
            catch (DalForeignKeyException ex_fk)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, delResource);
                throw new BusinessException(string.Format("The Resource is still used by {0}", ex_fk.Table), ex_fk);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, delResource);
                throw;
            }
        }
Beispiel #4
0
        public ModifyControler(View.ResEditor resed)
        {
            re  = resed;
            res = makeRes();
            if (res != null)
            {
                for (int i = 0; i < GlowingEarth.getInstance().getMaster().getResources().Count; i++)
                {
                    if (res.getMark().Equals(GlowingEarth.getInstance().getMaster().getResources()[i].getMark()))
                    {
                        GlowingEarth.getInstance().getMaster().getResources()[i] = res;
                        break;
                    }
                }
            }
            else
            {
                success = false;
                return;
            }

            foreach (Model.MapItem mi in GlowingEarth.getInstance().getMaster().getMapItems())
            {
                if (mi.getID().Equals(res.getMark()))
                {
                    mi.setName(res.getName());
                    mi.setPath(res.getIco());
                }
            }
            success = true;
            GlowingEarth.getInstance().getMaster().notifyChange();
        }
        private void OnAppointmentsFetch(object sender, FetchAppointmentsEventArgs e)
        {
            DateTime start = e.Interval.Start;
            DateTime end   = e.Interval.End;

            if (isDirty || !lastFetchedInterval.Contains(e.Interval) || lastFetchedResource != Filter.Current.User)
            {
                isDirty = false;

                lastFetchedInterval = new TimeInterval(
                    start - TimeSpan.FromDays(7),
                    end + TimeSpan.FromDays(7));

                lastFetchedResource = Filter.Current.User;

                schedulerControl.Enabled = false;
                dateNavigator.Enabled    = false;
                gridControl.Enabled      = false;

                try {
                    Fill(lastFetchedInterval, Filter.Current.User, Program.Service);
                } finally {
                    schedulerControl.Enabled = true;
                    dateNavigator.Enabled    = true;
                    gridControl.Enabled      = true;
                }
            }
        }
 /// <summary>
 /// Equals function to compare class
 /// </summary>
 public virtual bool Exists(Model.Resource resource)
 {
     try
     {
         return(this.GetById(resource.Id) != null);
     }
     catch (Exception ex)
     {
         Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, resource);
         throw;
     }
 }
Beispiel #7
0
        public ModifyControler(View.TypeEditor resed)
        {
            te = resed;

            if ((type = makeType()) != null)
            {
                for (int i = 0; i < GlowingEarth.getInstance().getMaster().getTypes().Count; i++)
                {
                    if (type.getMark().Equals(GlowingEarth.getInstance().getMaster().getTypes()[i].getMark()))
                    {
                        GlowingEarth.getInstance().getMaster().getTypes()[i] = type;
                        break;
                    }
                }
            }
            else
            {
                success = false;
                return;
            }

            GlowingEarth.getInstance().itemList.Items.Refresh();

            ObservableCollection <Model.Resource> temp = GlowingEarth.getInstance().getMaster().getResources();

            for (int i = 0; i < temp.Count; i++)
            {
                if (GlowingEarth.getInstance().getMaster().getResources()[i].getType().getMark().Equals(type.getMark()))
                {
                    Model.Resource r = temp[i];
                    r.setType(type);
                    if (r.getHasTypeImg())
                    {
                        r.setIcon(type.getImg());
                    }
                    ObservableCollection <Model.MapItem> mapitems = GlowingEarth.getInstance().getMaster().getMapItems();
                    for (int j = 0; j < mapitems.Count; j++)
                    {
                        if (mapitems[j].getID().Equals(r.getMark()))
                        {
                            mapitems[j].setPath(r.getIco());
                        }
                    }
                    GlowingEarth.getInstance().getMaster().setMapItems(mapitems);
                }
            }
            GlowingEarth.getInstance().getMaster().setResources(temp);
            success = true;
            GlowingEarth.getInstance().map.Items.Refresh();
            GlowingEarth.getInstance().getMaster().notifyChange();
        }
 /// <summary>
 /// Get a Resource by id from the database
 /// </summary>
 public virtual Model.Resource GetById(Int32 id)
 {
     try
     {
         DataAccess.Resources resources = new DataAccess.Resources();
         Model.Resource       result    = resources.GetById(id);
         return(result);
     }
     catch (Exception ex)
     {
         Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, id);
         throw;
     }
 }
Beispiel #9
0
        /// <summary>
        /// Delete the given Resource from the database
        /// </summary>
        public virtual void Delete(Model.Resource resource)
        {
            try
            {
                Trace.WriteVerbose("({0})", Trace.GetMethodName(), CLASSNAME, resource.ToString());

                var helper = Database.GetDbHelper();
                helper.ExecuteSPNonQuery(_storedProcedure_Delete,
                                         helper.CreateInputParam("@Id", resource.Id));
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, resource.ToString());
                throw DbHelper.TranslateException(ex);
            }
        }
Beispiel #10
0
        public void TestSerializeDeserialize()
        {
            var m = new Model.Document();

            m.FileName = "xxx";
            m.SHA1     = "0123456789abcdef";
            var f1 = new Model.Format()
            {
                Code = "P4"
            };

            f1.Parameters.Add(new Model.Parameter()
            {
                Name = "a", Value = "1"
            });
            f1.Parameters.Add(new Model.Parameter()
            {
                Name = "b", Value = "2"
            });
            var r1 = new Model.Resource()
            {
                Name   = "res1",
                Offset = 1000,
                Format = f1
            };

            m.Resources.Add(r1);
            Model.Helper.Save(m, "test.xml");
            var zm = Model.Helper.Load <Model.Document>("test.xml");

            Assert.IsNotNull(zm);
            Assert.AreEqual(m.FileName, zm.FileName);
            Assert.AreEqual(m.Resources.Count, zm.Resources.Count);
            for (int i = 0; i < m.Resources.Count; i++)
            {
                var mr  = m.Resources[i];
                var zmr = zm.Resources[i];
                Assert.AreEqual(mr.Name, zmr.Name);
                Assert.AreEqual(mr.Offset, zmr.Offset);
                Assert.AreEqual(mr.Format.Code, zmr.Format.Code);
                for (int j = 0; j < mr.Format.Parameters.Count; j++)
                {
                    Assert.AreEqual(mr.Format.Parameters[j].Name, zmr.Format.Parameters[j].Name);
                    Assert.AreEqual(mr.Format.Parameters[j].Value, zmr.Format.Parameters[j].Value);
                }
            }
        }
Beispiel #11
0
 /// <summary>
 /// Create a Model.Resource
 /// </summary>
 protected virtual Model.Resource CreateResource(DbDataReader reader)
 {
     try
     {
         Model.Resource result = new Model.Resource(
             (Int32)reader["Id"],
             (String)reader["Code"],
             (String)reader["Description"]
             );
         return(result);
     }
     catch (Exception ex)
     {
         Trace.WriteError("", Trace.GetMethodName(), CLASSNAME, ex);
         throw DbHelper.TranslateException(ex);
     }
 }
        void DoFilterUserChanged(object sender, bool bRefreshDataSource)
        {
            schedulerControl.BeginUpdate();
            schedulerStorage.BeginUpdate();

            try {
                gridControl.BeginUpdate();
                try {
                    Model.Resource user = sender as Model.Resource;

                    if (user != null)
                    {
                        schedulerControl.Views.DayView.ResourcesPerPage      = 1;
                        schedulerControl.Views.MonthView.ResourcesPerPage    = 1;
                        schedulerControl.Views.TimelineView.ResourcesPerPage = 1;
                        schedulerControl.Views.WeekView.ResourcesPerPage     = 1;
                        schedulerControl.Views.WorkWeekView.ResourcesPerPage = 1;
                        schedulerControl.GroupType   = SchedulerGroupType.None;
                        gridColumnAssignedTo.Visible = false;
                        gridColumnAssignedTo.OptionsColumn.ShowInCustomizationForm = false;
                    }
                    else
                    {
                        schedulerControl.GroupType = SchedulerGroupType.Resource;
                        schedulerControl.Views.DayView.ResourcesPerPage      = 5;
                        schedulerControl.Views.MonthView.ResourcesPerPage    = 5;
                        schedulerControl.Views.TimelineView.ResourcesPerPage = 5;
                        schedulerControl.Views.WeekView.ResourcesPerPage     = 5;
                        schedulerControl.Views.WorkWeekView.ResourcesPerPage = 5;
                        gridColumnAssignedTo.Visible = true;
                        gridColumnAssignedTo.OptionsColumn.ShowInCustomizationForm = true;
                    }

                    if (bRefreshDataSource)
                    {
                        schedulerControl.RefreshData();
                    }
                } finally {
                    gridControl.EndUpdate();
                }
            } finally {
                schedulerStorage.EndUpdate();
                schedulerControl.EndUpdate();
            }
        }
        /*KRAJ VALIDACIJE PRICEBOXA*/

        private void typeBox_Copy_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ObservableCollection <Model.Resource> resez = new ObservableCollection <Model.Resource>();

            _selectedResource = null;
            picpath           = "";
            filt = (Model.Type)filter.SelectedItem;
            if (filt != null && (searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources...")))
            {
                foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources())
                {
                    if (r.getType().getMark().Equals(filt.getMark()))
                    {
                        resez.Add(r);
                    }
                }
                res.Clear();
                foreach (Model.Resource r in resez)
                {
                    res.Add(r);
                }
            }
            else if (filt != null && !(searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources...")))
            {
                foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources())
                {
                    if (r.getType().getMark().Equals(filt.getMark()) && r.getMark().Equals(searchBox.Text))
                    {
                        resez.Add(r);
                    }
                }
                res.Clear();
                foreach (Model.Resource r in resez)
                {
                    res.Add(r);
                }
            }
            else
            {
                restartResez();
            }
        }
        public DeleteControler(Model.Resource r)
        {
            foreach (Model.Resource d in GlowingEarth.getInstance().getMaster().getResources())
            {
                if (d.getMark().Equals(r.getMark()))
                {
                    GlowingEarth.getInstance().getMaster().getResources().Remove(d);
                    break;
                }
            }
            ObservableCollection <Model.MapItem> mati = new ObservableCollection <Model.MapItem>();

            foreach (Model.MapItem mi in GlowingEarth.getInstance().getMaster().getMapItems())
            {
                if (!mi.getID().Equals(r.getMark()))
                {
                    mati.Add(mi);
                }
            }
            GlowingEarth.getInstance().getMaster().setMapItems(mati);
            success = true;
        }
        /// <summary>
        /// Add a new Resource to the database
        /// </summary>
        public virtual Int32 Add(Model.Resource newResource)
        {
            try
            {
                Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, newResource);

                CheckConstraints(newResource);
                DataAccess.Resources resources = new DataAccess.Resources();

                return(resources.Add(newResource));
            }
            catch (DalForeignKeyException ex_fk)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, newResource);
                throw new BusinessException(string.Format("No related object found in {0}", ex_fk.Table), ex_fk);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, newResource);
                throw;
            }
        }
Beispiel #16
0
        /// <summary>
        /// Modify the given Resource in the database
        /// </summary>
        public virtual void Modify(Model.Resource modifiedResource)
        {
            try
            {
                Trace.WriteVerbose("({0})", Trace.GetMethodName(), CLASSNAME, modifiedResource.ToString());

                var helper          = Database.GetDbHelper();
                int recordsAffected = helper.ExecuteSPNonQuery(_storedProcedure_Modify,
                                                               helper.CreateInputParam("@Id", modifiedResource.Id),
                                                               helper.CreateInputParam("@Code", modifiedResource.Code),
                                                               helper.CreateInputParam("@Description", modifiedResource.Description));

                if (recordsAffected == 0)
                {
                    throw new DalNothingUpdatedException("No records were updated (Table: Resources). Resource=" + modifiedResource.ToString());
                }
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, modifiedResource.ToString());
                throw DbHelper.TranslateException(ex);
            }
        }
        /// <summary>
        /// Check Datafield constraints
        /// </summary>
        protected virtual void CheckConstraints(Model.Resource resource)
        {
            //Range checks, etc checks go here
            if (resource.Code == null)
            {
                throw new BusinessException(string.Format("Code may not be NULL. ({0})", resource.Code));
            }

            if (resource.Code.Length > 50)
            {
                throw new BusinessException(string.Format("Code may not be longer than 50 characters. ({0})", resource.Code));
            }

            if (resource.Description == null)
            {
                throw new BusinessException(string.Format("Description may not be NULL. ({0})", resource.Description));
            }

            if (resource.Description.Length > 50)
            {
                throw new BusinessException(string.Format("Description may not be longer than 50 characters. ({0})", resource.Description));
            }
        }
        /// <summary>
        /// Modify the given Resource in the database
        /// </summary>
        public virtual void Modify(Model.Resource modifiedResource)
        {
            try
            {
                Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, modifiedResource);

                //Begin Checks
                CheckConstraints(modifiedResource);

                if (!Exists(modifiedResource))
                {
                    throw new BusinessException(string.Format("There is no Resource with this id. ({0})", modifiedResource));
                }

                DataAccess.Resources resources = new DataAccess.Resources();
                resources.Modify(modifiedResource);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, modifiedResource);
                throw;
            }
        }
        public DeleteControler(Model.Type e)
        {
            foreach (Model.Type d in GlowingEarth.getInstance().getMaster().getTypes())
            {
                if (d.getMark().Equals(e.getMark()))
                {
                    GlowingEarth.getInstance().getMaster().getTypes().Remove(d);
                    break;
                }
            }
            ObservableCollection <Model.Resource> temp = new ObservableCollection <Model.Resource>();

            foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().resources)
            {
                temp.Add(r);
            }
            for (int i = 0; i < temp.Count; i++)
            {
                if (e.getMark().Equals(temp[i].getType().getMark()))
                {
                    Model.Resource rz = temp[i];
                    ObservableCollection <Model.MapItem> mati = new ObservableCollection <Model.MapItem>();

                    foreach (Model.MapItem mi in GlowingEarth.getInstance().getMaster().getMapItems())
                    {
                        if (!mi.getID().Equals(rz.getMark()))
                        {
                            mati.Add(mi);
                        }
                    }
                    GlowingEarth.getInstance().getMaster().setMapItems(mati);
                    GlowingEarth.getInstance().getMaster().getResources().Remove(temp[i]);
                }
            }

            success = true;
        }
        private void OnCustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column == gridColumnIsCompleted)
            {
                return;
            }

            Model.Appointment obj = e.Column.View.GetRow(e.RowHandle) as Model.Appointment;

            if (e.Column == gridColumnAssignedTo)
            {
                string displayText = string.Empty;


                if (obj != null)
                {
                    Model.Resource resource = obj.AssignedTo.HasValue
                        ? FindResourceByID(obj.AssignedTo.Value) : null;

                    if (resource != null)
                    {
                        displayText = resource.DisplayText;
                    }
                }

                e.DisplayText = displayText;
            }

            Color     fontColor = e.Appearance.ForeColor;
            FontStyle fontStyle = e.Appearance.Font.Style;

            if (obj != null)
            {
                if (obj.CompletionStatus >= 0 && obj.Finish <= DateTime.Now

                    && !obj.IsAllDay)
                {
                    fontColor = Color.FromArgb(0xCF, 0x45, 0x55);
                    fontStyle = FontStyle.Bold;
                }
                else if (obj.CompletionStatus >= 0 && obj.IsAllDay

                         /* All day appointments today are not yet overdue */
                         && obj.Finish < DateTime.Now.Date)
                {
                    fontColor = Color.FromArgb(0xCF, 0x45, 0x55);
                    fontStyle = FontStyle.Bold;
                }
                else if (obj.CompletionStatus < 0)
                {
                    fontColor = Color.Silver;
                    fontStyle = FontStyle.Strikeout;
                }
            }

            e.Cache.FillRectangle(e.Appearance.GetBackBrush(e.Cache), e.Bounds);

            Rectangle rect = e.Bounds;

            if (e.Appearance.HAlignment == HorzAlignment.Near)
            {
                rect.Offset(2, 0);
            }

            e.Cache.DrawString(e.DisplayText, e.Cache.GetFont(e.Appearance.Font, fontStyle),
                               e.Cache.GetSolidBrush(fontColor),
                               rect, e.Appearance.GetStringFormat());

            e.Handled = true;
        }
Beispiel #21
0
 private T Resolve <T>(Uri uri) where T : Model.Resource
 {
     loader.Locate(uri);
     Model.Resource resource = source.ReadResourceArtifact(uri);
     return((T)resource);
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     modify.IsEnabled  = false;
     delete.IsEnabled  = false;
     _selectedResource = null;
 }
        private void searchBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            ObservableCollection <Model.Resource> resez = new ObservableCollection <Model.Resource>();

            _selectedResource = null;
            picpath           = "";
            if ((searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources...")) && filt == null && res != null && copy != null)
            {
                foreach (Model.Resource r in copy)
                {
                    res.Add(r);
                }
                return;
            }
            else if (filt != null && (searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources...")))
            {
                foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources())
                {
                    if (r.getMark().Contains(searchBox.Text) && r.getType().getMark().Equals(filt.getMark()))
                    {
                        resez.Add(r);
                    }
                }
                res.Clear();
                foreach (Model.Resource re in resez)
                {
                    res.Add(re);
                }
            }
            else if (filt == null && !(searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources...")))
            {
                foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources())
                {
                    if (r.getMark().Contains(searchBox.Text))
                    {
                        resez.Add(r);
                    }
                }
                res.Clear();
                foreach (Model.Resource re in resez)
                {
                    res.Add(re);
                }
            }
            else if (filt == null && (searchBox.Text.Equals("") || searchBox.Text.Equals("Search for resources...")))
            {
                restartResez();
            }
            else
            {
                foreach (Model.Resource r in GlowingEarth.getInstance().getMaster().getResources())
                {
                    if (r.getMark().Contains(searchBox.Text) && r.getType().getMark().Equals(filt.getMark()))
                    {
                        resez.Add(r);
                    }
                }
                res.Clear();
                foreach (Model.Resource re in resez)
                {
                    res.Add(re);
                }
            }
        }
        public void Fill(
            TimeInterval e,
            Model.Resource resource, Uri uri)
        {
#if DEBUG
            Debug.WriteLine(e);
#endif

            BindingList <Model.Appointment> schedulerDataSource

                = schedulerStorage.Appointments.DataSource as BindingList <Model.Appointment>;

            if (schedulerDataSource == null)
            {
                return;
            }

            lock (schedulerDataSource) {
                DevExpress.Calendar.Model.Service service
                    = new DevExpress.Calendar.Model.Service(uri);

                DateTime now = DateTime.UtcNow;

                DateTime start = e.Start.ToUniversalTime();
                DateTime end   = e.End.ToUniversalTime();

                DateTime weekStart = now.AddDays(-7);
                DateTime weekEnd   = now.AddDays(7);

                DataServiceQuery <Model.Appointment> query;

                if (resource == null)
                {
                    query = (DataServiceQuery <Model.Appointment>)service.Appointments.Where(s =>

                                                                                             /* always include incomplete items */
                                                                                             (s.Finish <= now && s.CompletionStatus >= 0)

                                                                                             ||

                                                                                             /* always include recurrence templates */
                                                                                             (s.AppointmentType == (int)AppointmentType.Pattern)

                                                                                             ||

                                                                                             ((s.Start >= start && s.Start <= end) || (s.Finish >= start && s.Finish <= end))

                                                                                             ||

                                                                                             /* always include todays */
                                                                                             ((s.Start >= weekStart && s.Start <= weekEnd) || (s.Finish >= weekStart && s.Finish <= weekEnd))

                                                                                             );
                }
                else
                {
                    query

                        = (DataServiceQuery <Model.Appointment>)service.Appointments.Where(s =>

                                                                                           (
                                                                                               s.Resource.ID == resource.ID
                                                                                           )

                                                                                           &&

                                                                                           (
                                                                                               /* always include recurrence templates */
                                                                                               (s.AppointmentType == (int)AppointmentType.Pattern)

                                                                                               ||

                                                                                               /* always include incomplete items */
                                                                                               (s.Finish <= now && s.CompletionStatus >= 0)

                                                                                               ||

                                                                                               ((s.Start >= start && s.Start <= end) || (s.Finish >= start && s.Finish <= end))

                                                                                               ||

                                                                                               /* always include todays */
                                                                                               ((s.Start >= weekStart && s.Start <= weekEnd) || (s.Finish >= weekStart && s.Finish <= weekEnd))

                                                                                           )

                                                                                           );
                }

                using (new WaitCursor()) {
                    SuspendLayout();

                    schedulerControl.BeginUpdate();
                    schedulerStorage.BeginUpdate();

                    gridControl.BeginUpdate();
                    gridView.BeginUpdate();

                    try {
                        BindingList <Model.Appointment> taskDataSource = gridControl.DataSource as BindingList <Model.Appointment>;

                        schedulerDataSource.Clear();

                        if (taskDataSource != null)
                        {
                            taskDataSource.Clear();
                        }

                        if (query != null)
                        {
                            foreach (DevExpress.Calendar.Model.Appointment s in query)
                            {
                                DevExpress.Calendar.Model.Appointment local = s.Clone(DateTimeKind.Local);

                                schedulerDataSource.Add(local);

                                if (taskDataSource != null)
                                {
                                    if (local.AppointmentType == (int)AppointmentType.Normal)
                                    {
                                        taskDataSource.Add(local);
                                    }
                                }
                            }
                        }
                    } finally {
                        gridView.EndUpdate();
                        gridControl.EndUpdate();

                        schedulerStorage.EndUpdate();
                        schedulerControl.EndUpdate();

                        ResumeLayout();
                    }
                }
            }
        }
Beispiel #25
0
        public Model.Resource makeRes()
        {
            res = new Model.Resource();
            if (contAddRes())
            {
                res.setName(re.nameBox.Text.Trim(' '));
                res.setMark(re.IDBox.Text);
                res.setDesc(re.descBox.Text);
                if (re.radioFreq.IsChecked == true)
                {
                    res.setFreq(Model.Resource.FreqType.FREQUENT);
                }
                else if (re.radioRare.IsChecked == true)
                {
                    res.setFreq(Model.Resource.FreqType.RARE);
                }
                else if (re.radioUniv.IsChecked == true)
                {
                    res.setFreq(Model.Resource.FreqType.UNIVERSAL);
                }

                res.setType((Model.Type)re.typeBox.SelectedItem);
                res.setPrice(Double.Parse(re.priceBox.Text));
                if (re.radioScoop.IsChecked == true)
                {
                    res.setUnit(Model.Resource.Units.SCOOP);
                }
                else if (re.radioBarrel.IsChecked == true)
                {
                    res.setUnit(Model.Resource.Units.BAREL);
                }
                else if (re.radioT.IsChecked == true)
                {
                    res.setUnit(Model.Resource.Units.T);
                }
                else if (re.radioKG.IsChecked == true)
                {
                    res.setUnit(Model.Resource.Units.KG);
                }
                res.setOb(re.ren.IsChecked.Value);
                res.setStr(re.Strt.IsChecked.Value);
                res.setExp(re.exp.IsChecked.Value);
                res.setDate(re.Date.SelectedDate.Value);
                res.setHasTypeImg(re.selectedResource.getHasTypeImg());

                bool this_is_type = false;
                foreach (Model.Type t in re.types)
                {
                    if (t.getImg().Equals(re.picpath))
                    {
                        this_is_type = true;
                        break;
                    }
                }

                if (re.icoPath.Text.Equals("") || (res.getHasTypeImg()))
                {
                    bool novo = false;
                    foreach (Model.Type t in GlowingEarth.getInstance().getMaster().types)
                    {
                        String path = t.getImg();
                        if ((path.Equals(((Model.Type)re.typeBox.SelectedItem).getImg()) || path.Equals("")) && this_is_type)
                        {
                            res.setIcon(res.getType().getImg());
                            res.setHasTypeImg(true);
                            novo = true;
                            break;
                        }
                    }
                    if (!novo)
                    {
                        res.setIcon(re.icoPath.Text);
                        res.setHasTypeImg(false);
                    }
                }
                else
                {
                    res.setIcon(re.icoPath.Text);
                    res.setHasTypeImg(false);
                }


                bool dontModify           = true;
                List <Model.Etiquette> et = new List <Model.Etiquette>();
                foreach (Model.Etiquette e in re.tags)
                {
                    if (e.isPartOfRes)
                    {
                        dontModify = false;
                        et.Add(e);
                    }
                }

                bool dontAdd = false;
                if (!dontModify)
                {
                    foreach (Model.Etiquette e in GlowingEarth.getInstance().getMaster().getTags())
                    {
                        if (e.isPartOfRes)
                        {
                            List <Model.Etiquette> etz = re.selectedResource.getTags();
                            foreach (Model.Etiquette z in etz)
                            {
                                if (z.getID().Equals(e.getID()))
                                {
                                    dontAdd = true;
                                    break;
                                }
                            }
                            if (!dontAdd)
                            {
                                et.Add(e);
                            }
                        }
                    }
                    res.setTags(et);
                }
            }
            else
            {
                success = false;
                return(null);
            }
            return(res);
        }
Beispiel #26
0
        public AddRessControler(View.NewRes refer)
        {
            wind = refer;
            res  = new Resource();
            if (contAdd())
            {
                foreach (Model.Etiquette b in wind.tagovi)
                {
                    if (b.isPartOfRes)
                    {
                        res.taglist.Add(b);
                    }
                }
                res.setName(wind.nameBox.Text.Trim(' '));
                res.setMark(wind.IDBox.Text);
                res.setDesc(wind.descBox.Text);
                if (wind.radioFreq.IsChecked == true)
                {
                    res.setFreq(Resource.FreqType.FREQUENT);
                }
                else if (wind.radioRare.IsChecked == true)
                {
                    res.setFreq(Resource.FreqType.RARE);
                }
                else if (wind.radioUniv.IsChecked == true)
                {
                    res.setFreq(Resource.FreqType.UNIVERSAL);
                }

                res.setType((Model.Type)wind.typeBox.SelectedItem);
                res.setPrice(Double.Parse(wind.priceBox.Text));
                if (wind.radioScoop.IsChecked == true)
                {
                    res.setUnit(Resource.Units.SCOOP);
                }
                else if (wind.radioBarrel.IsChecked == true)
                {
                    res.setUnit(Resource.Units.BAREL);
                }
                else if (wind.radioT.IsChecked == true)
                {
                    res.setUnit(Resource.Units.T);
                }
                else if (wind.radioKG.IsChecked == true)
                {
                    res.setUnit(Resource.Units.KG);
                }
                res.setOb(wind.ren.IsChecked.Value);
                res.setStr(wind.Strt.IsChecked.Value);
                res.setExp(wind.exp.IsChecked.Value);
                res.setDate(wind.Date.SelectedDate.Value);
                if (wind.icoPath.Text.Equals(""))
                {
                    res.setIcon(res.getType().getImg());
                    res.setHasTypeImg(true);
                }
                else
                {
                    res.setIcon(wind.icoPath.Text);
                    res.setHasTypeImg(false);
                }
            }
            else
            {
                success = false;
                return;
            }
            //Resource created <-----------------------------------
            if (chckRes())
            {
                addRes();
                GlowingEarth.getInstance().getMaster().notifyChange();
                success = true;
            }
            else
            {
                wind.Error.Content = "Resource with this ID already exists";
                success            = false;
            }
        }