Example #1
0
        public static void AddNewTypeC(SQLiteConnectionUser cn, string c, Color cl, string namelist, string t, string sn = "")
        {
            string[] list = namelist.Split(';');

            foreach (string name in list)
            {
                if (name.Length > 0)   // just in case a semicolon slips thru
                {
                    string fdname = EDDiscovery.Tools.FDName(name);

                    MaterialCommodities mc = GetCatFDName(null, fdname, cn);

                    if (mc == null)
                    {
                        mc = new MaterialCommodities(0, c, name, fdname, t, sn, cl, 0);
                        mc.Add(cn);
                    }               // don't change any user changed fields
                    else if (mc.flags == 0 && (!mc.name.Equals(name) && !mc.shortname.Equals(sn) || !mc.category.Equals(c) || !mc.type.Equals(t) || mc.colour.ToArgb() != cl.ToArgb()))
                    {
                        mc.name      = name;
                        mc.shortname = sn;          // So, name is there, update the others
                        mc.category  = c;
                        mc.type      = t;
                        mc.colour    = cl;
                        mc.Update(cn);
                    }
                }
            }
        }
Example #2
0
        // ifnorecatonsearch is used if you don't know if its a material or commodity.. for future use.

        private MaterialCommodities EnsurePresent(string cat, string fdname, SQLiteConnectionUser conn, bool ignorecatonsearch = false)
        {
            MaterialCommodities mc = list.Find(x => x.fdname.Equals(fdname, StringComparison.InvariantCultureIgnoreCase) && (ignorecatonsearch || x.category.Equals(cat, StringComparison.InvariantCultureIgnoreCase)));

            if (mc == null)
            {
                MaterialCommodities mcdb = MaterialCommodities.GetCatFDName(cat, fdname, conn); // look up in DB and see if we have a record of this type of item

                if (mcdb == null)                                                               // no record of this, add as Unknown to db
                {
                    mcdb = new MaterialCommodities(0, cat, fdname, fdname, "", "", Color.Green, 0);
                    mcdb.Add();                 // and add to data base
                }

                mc = new MaterialCommodities(0, mcdb.category, mcdb.name, mcdb.fdname, mcdb.type, mcdb.shortname, mcdb.colour, 0);        // make a new entry
                list.Add(mc);
            }

            return(mc);
        }