예제 #1
0
        public static void DeleteResellerGroupById(int id)
        {
            CanonDataContext db = Cdb.Instance;
            ResellerGroup    rg = db.ResellerGroups.FirstOrDefault(r => r.ID == id);

            if (rg.Resellers.Count > 0)
            {
                throw new ResellerAssignedException(rg.FileAs, rg.Resellers.Count);
            }

            db.ResellerGroups.DeleteOnSubmit(rg);
            db.SubmitChanges();
        }
예제 #2
0
        public List<ImportErrorMessage> InsertImportResellerRecord()
        {
            List<ImportErrorMessage> warnings = new List<ImportErrorMessage>();

            CanonDataContext db = Cdb.Instance;

            // create reseller group if it doesn't exist yet
            ResellerGroup resellerGroup = db.ResellerGroups.FirstOrDefault(rg => rg.Code == this.ResellerGroupCode);
            if (resellerGroup == null)
            {
                resellerGroup = new ResellerGroup();
                resellerGroup.Code = this.ResellerGroupCode;
                resellerGroup.FileAs = "Nová_" + this.ResellerGroupCode;

                db.ResellerGroups.InsertOnSubmit(resellerGroup);
            }

            // update Reseller
            Reseller reseller = db.Resellers.FirstOrDefault(r => r.IdentificationNumber == this.IdentificationNumber);
            if (reseller == null)
            {
                reseller = new Reseller();

                db.Resellers.InsertOnSubmit(reseller);
            }

            reseller.IdentificationNumber = this.IdentificationNumber;
            reseller.FileAs = this.FileAs;
            reseller.ResellerGroup = resellerGroup;
            reseller.IDCountry = int.Parse(this.CountryCode);
            reseller.Code = string.Empty;

            // insert ImportReseller
            ImportResellerRecord record = new ImportResellerRecord();
            record.CountryCode = this.CountryCode;
            record.FileAs = this.FileAs;
            record.IdentificationNumber = this.IdentificationNumber;
            record.IDImportReseller = this.ImportReseller.ID;
            record.ResellerGroupCode = this.ResellerGroupCode;

            db.ImportResellerRecords.InsertOnSubmit(record);
            db.SubmitChanges();

            return warnings;
        }
예제 #3
0
        public static void InsertOrUpdateResellerGroup(CanonResellerGroup newValue)
        {
            CanonDataContext db = Cdb.Instance;
            ResellerGroup rg = null;

            if (newValue.ID == -1)
            {
                rg = new ResellerGroup();
                db.ResellerGroups.InsertOnSubmit(rg);
            }
            else
            {
                rg = db.ResellerGroups.FirstOrDefault(r => r.ID == newValue.ID);
            }

            rg.FileAs = newValue.FileAs;
            rg.Code = newValue.Code;

            db.SubmitChanges();
        }
예제 #4
0
        public static void InsertOrUpdateResellerGroup(CanonResellerGroup newValue)
        {
            CanonDataContext db = Cdb.Instance;
            ResellerGroup    rg = null;

            if (newValue.ID == -1)
            {
                rg = new ResellerGroup();
                db.ResellerGroups.InsertOnSubmit(rg);
            }
            else
            {
                rg = db.ResellerGroups.FirstOrDefault(r => r.ID == newValue.ID);
            }

            rg.FileAs = newValue.FileAs;
            rg.Code   = newValue.Code;

            db.SubmitChanges();
        }