Пример #1
0
        public Resource GetResource()
        {
            Resource res = new Resource();

            res.ID          = txtId.Text;
            res.Name        = txtName.Text;
            res.Description = txtDescription.Text;
            res.Important   = chbImportant.Checked;
            res.Renewable   = chbRenewable.Checked;
            res.Accessable  = chbExploatable.Checked;
            res.Unit        = Resource.StringToUnit(cmbUnit.Text);
            if (rbtFrequent.Checked)
            {
                res.Frequency = Frequency.FREQUENT;
            }
            else if (rbtRare.Checked)
            {
                res.Frequency = Frequency.RARE;
            }
            else
            {
                res.Frequency = Frequency.UNIVERSAL;
            }
            res.Cost       = double.Parse(txtCost.Text);
            res.Discovered = dateTimePicker.Value;
            res.Tags       = tags;

            return(res);
        }
Пример #2
0
        public Resource GetResource()
        {
            Resource res = new Resource();

            int i = 0;

            res.ID = edit ? ID : txtId.Text;
            if (!edit && MainForm.resources.ContainsKey(res.ID))
            {
                do
                {
                    i++;
                } while (MainForm.resources.ContainsKey(res.ID + i));
                res.ID += i++;
            }

            res.SecondID    = txtId.Text;
            res.Name        = txtName.Text;
            res.Description = txtDescription.Text;
            res.Important   = chbImportant.Checked;
            res.Renewable   = chbRenewable.Checked;
            res.Exploatable = chbExploatable.Checked;
            res.Unit        = Resource.StringToUnit(cmbUnit.Text);
            if (rbtFrequent.Checked)
            {
                res.Frequency = Frequency.FREQUENT;
            }
            else if (rbtRare.Checked)
            {
                res.Frequency = Frequency.RARE;
            }
            else
            {
                res.Frequency = Frequency.UNIVERSAL;
            }
            res.Cost = double.Parse(txtCost.Text);
            if (rbtDate.Checked)
            {
                res.Discovered       = dateTimePicker.Value;
                res.ApproxDiscovered = null;
            }
            else
            {
                res.Discovered       = dateTimePicker.Value;
                res.ApproxDiscovered = getApproxDate();
            }
            //res.Discovered = dateTimePicker.Value;
            //res.ApproxDiscovered = approxDate;
            res.Tags = tags;
            res.Type = type;
            try
            {
                File.Copy(fullFileName, "..\\..\\images\\" + fname);
            }
            catch
            {
                Console.WriteLine("File allready exists");
            }
            res.IconFileName = "..\\..\\images\\" + fname;

            return(res);
        }
        public Resource GetResource()
        {
            Resource res = new Resource();

            res.ID          = txtId.Text;
            res.Name        = txtName.Text;
            res.Description = txtDescription.Text;
            res.Important   = chbImportant.Checked;
            res.Renewable   = chbRenewable.Checked;
            res.Exploatable = chbExploatable.Checked;
            res.Unit        = Resource.StringToUnit(cmbUnit.Text);
            if (rbtFrequent.Checked)
            {
                res.Frequency = Frequency.FREQUENT;
            }
            else if (rbtRare.Checked)
            {
                res.Frequency = Frequency.RARE;
            }
            else
            {
                res.Frequency = Frequency.UNIVERSAL;
            }
            res.Cost = double.Parse(txtCost.Text);
            if (rbtDate.Checked)
            {
                res.Discovered       = dateTimePicker.Value;
                res.ApproxDiscovered = null;
            }
            else
            {
                res.Discovered       = DateTime.MaxValue;
                res.ApproxDiscovered = approxDate;
            }
            //res.Discovered = dateTimePicker.Value;
            //res.ApproxDiscovered = approxDate;
            res.Tags = tags;
            if (!fname.Equals(""))
            {
                try
                {
                    File.Copy(fullFileName, "..\\..\\images\\" + fname);
                }
                catch
                {
                    Console.WriteLine("File allready exists");
                }
                res.IconFileName = "..\\..\\images\\" + fname;
            }
            else
            {
                res.IconFileName = fullFileName;
            }
            res.Type = type;
            if (cmbType.SelectedItem != null)
            {
                string typeID = cmbType.SelectedItem.ToString();
                foreach (Type t in MainForm.types.Values)
                {
                    if (t.ID == typeID)
                    {
                        res.Type = t;
                    }
                }
            }

            return(res);
        }