/// <summary> /// Method that adds new trim format to the duplicated print plant profile /// </summary> /// <returns></returns> public bool AddDuplicatedTrimFormats() { using (var context = new SGGSEntities()) { var trimFormat = new SGGS_SUPPORTED_TRIM_FORMATS { SUPPORTED_PAPER_TYPE_ID = SUPPORTED_PAPER_TYPE, SUPPORTED_BIND_TYPE_ID = SUPPORTED_BINDING_TYPE, PRINT_PLANT_PROFILE_ID = PRINT_PLANT_PROFILE_ID, TRIM_FORMAT_ID = TRIM_FORMAT_ID, TEXT_PAGE_COUNT_MAX = MAX_PAGES, TEXT_PAGE_COUNT_MIN = MIN_PAGES, TRIM_FORMAT_MIN_WIDTH = TRIM_FORMAT_MIN_WIDTH, TRIM_FORMAT_MAX_WIDTH = TRIM_FORMAT_MAX_WIDTH, TRIM_FORMAT_MAX_HEIGHT = TRIM_FORMAT_MAX_HEIGHT, TRIM_FORMAT_MIN_HEIGHT = TRIM_FORMAT_MIN_HEIGHT, OVERRIDE_AUTO_CALCULATION = OVERRIDE_AUTO_CALCULATION, SUPPORTED_PRINT_QUALITY = SUPPORTED_PRINT_QUALITY_ID }; context.SGGS_SUPPORTED_TRIM_FORMATS.AddObject(trimFormat); context.SaveChanges(); return(true); } }
/// <summary> /// Add a new pubisher group /// </summary> /// <param name="groupID"></param> /// <param name="PUBLISHER_ID"></param> /// <returns></returns> public bool AddGroupPublishers(long groupID, long PUBLISHER_ID) { try { using (SGGSEntities context = new SGGSEntities()) { var group = context.SGGS_GROUP_PUBLISHER.Where(x => x.GROUP_ID == groupID && x.PUBLISHER_ID == PUBLISHER_ID).FirstOrDefault(); if (group == null) { SGGS_GROUP_PUBLISHER newGroup = new SGGS_GROUP_PUBLISHER(); newGroup.PUBLISHER_ID = PUBLISHER_ID; newGroup.GROUP_ID = groupID; newGroup.DATE_ADDED = DateTime.Now; newGroup.DATE_UPDATED = DateTime.Now; context.SGGS_GROUP_PUBLISHER.AddObject(newGroup); context.SaveChanges(); return(true); } return(false); } } catch { return(false); } }
/// <summary> /// Method to insert record /// </summary> /// <returns></returns> public bool Add() { using (var context = new SGGSEntities()) { var trim = new SGGS_CODE_TRIM_FORMAT { DATE_ADDED = DateTime.Now, DATE_UPDATED = DateTime.Now, TRIM_FORMAT_HEIGHT_IN = TRIM_FORMAT_HEIGHT_IN, TRIM_FORMAT_HEIGHT_MM = TRIM_FORMAT_HEIGHT_MM, TRIM_FORMAT_NAME = TRIM_FORMAT_NAME, TRIM_FORMAT_NUMBER = TRIM_FORMAT_NUMBER, TRIM_FORMAT_WIDTH_IN = TRIM_FORMAT_WIDTH_IN, TRIM_FORMAT_WIDTH_MM = TRIM_FORMAT_WIDTH_MM, USAGE_HARDCOVER = USAGE_HARDCOVER, USAGE_PAPERBACK = USAGE_PAPERBACK, SOFT_COVER = SOFT_COVER, HARD_COVER = HARD_COVER }; context.SGGS_CODE_TRIM_FORMAT.AddObject(trim); context.SaveChanges(); TRIM_FORMAT_ID = trim.TRIM_FORMAT_ID; return(true); } }
/// <summary> /// Method to Delete Record /// </summary> /// <returns></returns> public Boolean Delete() { using (SGGSEntities context = new SGGSEntities()) { SGGS_GROUP group = context.SGGS_GROUP.Where(x => x.GROUP_ID == GROUP_ID).FirstOrDefault(); context.SGGS_GROUP.DeleteObject(group); context.SaveChanges(); return(true); } }
/// <summary> /// Method to Delete Record by SuptrimformatID /// </summary> /// <param name="suppTrimFormatID"></param> /// <returns></returns> public bool DeleteSupportTrimFormat(long suppTrimFormatID) { using (var context = new SGGSEntities()) { var suppTrim = context.SGGS_SUPPORTED_TRIM_FORMATS.FirstOrDefault(x => x.SUPPORTED_TRIM_FORMATS_ID == suppTrimFormatID); context.SGGS_SUPPORTED_TRIM_FORMATS.DeleteObject(suppTrim); context.SaveChanges(); return(true); } }
/// <summary> /// Method to Delete Record /// </summary> /// <returns></returns> public bool Delete() { using (var context = new SGGSEntities()) { var trim = context.SGGS_CODE_TRIM_FORMAT.FirstOrDefault(x => x.TRIM_FORMAT_ID == TRIM_FORMAT_ID); context.SGGS_CODE_TRIM_FORMAT.DeleteObject(trim); context.SaveChanges(); return(true); } }
/// <summary> /// Method to update a record /// </summary> /// <returns></returns> public Boolean Save() { using (SGGSEntities context = new SGGSEntities()) { SGGS_GROUP group = context.SGGS_GROUP.Where(x => x.GROUP_ID == GROUP_ID).FirstOrDefault(); group.DATE_UPDATED = DateTime.Now; group.DEFAULT_PUBLISHER_NUMBER = DEFAULT_PUBLISHER_NUMBER; group.GROUP_CODE = GROUP_CODE; group.GROUP_DESCRIPTION = GROUP_DESCRIPTION; group.GROUP_NAME = GROUP_NAME; context.SaveChanges(); return(true); } }
/// <summary> /// Inserts or update a new book into sggs /// </summary> /// <param name="publisherNumber"></param> /// <param name="title"></param> /// <param name="subtitle"></param> /// <param name="isbn"></param> /// <param name="edition"></param> /// <param name="copyRightYear"></param> /// <returns></returns> public SGGS_BOOK InsertUpdateBook(string publisherNumber, string title, string subtitle, string isbn, string edition, string copyRightYear) { using (SGGSEntities objSGGS = new SGGSEntities()) { SGGS_BOOK sggsBook = new SGGS_BOOK(); SGGS_PUBLISHER sggsPublisher = new SGGS_PUBLISHER(); var publisher = objSGGS.SGGS_PUBLISHER.Where(P => P.PUBLISHER_NUMBER == publisherNumber).FirstOrDefault(); /////// if (publisher != null) { sggsBook = (from B in objSGGS.SGGS_BOOK where B.BOOK_NUMBER == isbn && B.PUBLISHER_ID == publisher.PUBLISHER_ID select B).SingleOrDefault(); if (sggsBook == null) { sggsBook = new SGGS_BOOK(); sggsBook.BOOK_TITLE = title; sggsBook.DATE_UPDATED = System.DateTime.Now; sggsBook.PUBLISHER_ID = publisher.PUBLISHER_ID; sggsBook.BOOK_IDENTIFICATION_TYPE = "ISBN"; sggsBook.BOOK_NUMBER = isbn; sggsBook.IS_ENABLED = true; sggsBook.IS_NEW = true; sggsBook.DATE_ADDED = System.DateTime.Now; objSGGS.SGGS_BOOK.AddObject(sggsBook); objSGGS.SaveChanges(); } else if (sggsBook != null) { sggsBook.BOOK_TITLE = title; sggsBook.DATE_UPDATED = System.DateTime.Now; objSGGS.SaveChanges(); } } return(sggsBook); } }
/// <summary> /// Update a group publisher /// </summary> /// <param name="publisherNumber"></param> /// <param name="billToPublisherNumber"></param> /// <returns></returns> public bool UpdateGroupPublishers(string publisherNumber, string billToPublisherNumber) { using (SGGSEntities context = new SGGSEntities()) { SGGS_GROUP group = context.SGGS_GROUP.Where(x => x.GROUP_ID == this.GROUP_ID).FirstOrDefault(); if (group != null) { group.DEFAULT_PUBLISHER_NUMBER = publisherNumber; group.DEFAULT_BILL_TO_PUBLISHER_NUMBER = billToPublisherNumber; context.SaveChanges(); return(true); } return(false); } }
/// <summary> /// Remove a TrimFormat by trimFormatId /// </summary> /// <param name="trimFormatId"></param> /// <returns></returns> public string RemoveTrimFormat(long trimFormatId) { using (var context = new SGGSEntities()) { var trimFormat = context.SGGS_SUPPORTED_TRIM_FORMATS.FirstOrDefault(x => x.SUPPORTED_TRIM_FORMATS_ID == trimFormatId); if (trimFormat == null) { return("notRemoved"); } context.SGGS_SUPPORTED_TRIM_FORMATS.DeleteObject(trimFormat); context.SaveChanges(); return("removed"); } }
/// <summary> /// Method to insert record in Group Table /// </summary> /// <returns></returns> public Boolean Add() { using (SGGSEntities context = new SGGSEntities()) { SGGS_GROUP group = new SGGS_GROUP(); group.DATE_ADDED = DateTime.Now; group.DATE_UPDATED = DateTime.Now; group.DEFAULT_PUBLISHER_NUMBER = DEFAULT_PUBLISHER_NUMBER; group.GROUP_CODE = GROUP_CODE; group.GROUP_DESCRIPTION = GROUP_DESCRIPTION; group.GROUP_NAME = GROUP_NAME; context.SGGS_GROUP.AddObject(group); context.SaveChanges(); GROUP_ID = group.GROUP_ID; return(true); } }
/// <summary> /// Delete a publisher group /// </summary> /// <param name="groupID"></param> /// <param name="publisherID"></param> /// <returns></returns> public bool DeleteGroupPublisher(long groupID, long publisherID) { try { using (SGGSEntities context = new SGGSEntities()) { SGGS_GROUP_PUBLISHER group = context.SGGS_GROUP_PUBLISHER.Where(x => x.GROUP_ID == groupID && x.PUBLISHER_ID == publisherID).FirstOrDefault(); context.SGGS_GROUP_PUBLISHER.DeleteObject(group); context.SaveChanges(); return(true); } } catch { return(false); } }
/// <summary> /// Method to insert record /// </summary> /// <returns></returns> public bool Save() { using (var context = new SGGSEntities()) { var trim = context.SGGS_CODE_TRIM_FORMAT.FirstOrDefault(x => x.TRIM_FORMAT_ID == TRIM_FORMAT_ID); trim.DATE_UPDATED = DateTime.Now; trim.TRIM_FORMAT_HEIGHT_IN = TRIM_FORMAT_HEIGHT_IN; trim.TRIM_FORMAT_HEIGHT_MM = TRIM_FORMAT_HEIGHT_MM; trim.TRIM_FORMAT_NAME = TRIM_FORMAT_NAME; trim.TRIM_FORMAT_NUMBER = TRIM_FORMAT_NUMBER; trim.TRIM_FORMAT_WIDTH_IN = TRIM_FORMAT_WIDTH_IN; trim.TRIM_FORMAT_WIDTH_MM = TRIM_FORMAT_WIDTH_MM; trim.USAGE_HARDCOVER = USAGE_HARDCOVER; trim.USAGE_PAPERBACK = USAGE_PAPERBACK; trim.SOFT_COVER = SOFT_COVER; trim.HARD_COVER = HARD_COVER; context.SaveChanges(); return(true); } }
/// <summary> /// Method that adds new trim format to the print plant profile /// </summary> /// <param name="formats">New trim formats added</param> /// <returns></returns> public bool AddSupportedTrimFormats(IList <TrimFormat> formats, bool supportRanges) { if (formats.Count <= 0) { return(false); } using (var context = new SGGSEntities()) { foreach (var item in formats) { var sggsCodePrintQuality = context.SGGS_CODE_PRINT_QUALITY.FirstOrDefault(q => q.PRINT_QUALITY_NUMBER == item.SUPPORTED_PRINT_QUALITY); var trimFormat = new SGGS_SUPPORTED_TRIM_FORMATS { SUPPORTED_PAPER_TYPE_ID = item.SUPPORTED_PAPER_TYPE, SUPPORTED_BIND_TYPE_ID = item.SUPPORTED_BINDING_TYPE, PRINT_PLANT_PROFILE_ID = item.PRINT_PLANT_PROFILE_ID, TRIM_FORMAT_ID = item.TRIM_FORMAT_ID, TEXT_PAGE_COUNT_MAX = item.MAX_PAGES, TEXT_PAGE_COUNT_MIN = item.MIN_PAGES, TRIM_FORMAT_MAX_HEIGHT = item.TRIM_FORMAT_MAX_HEIGHT, TRIM_FORMAT_MIN_HEIGHT = item.TRIM_FORMAT_MIN_HEIGHT, TRIM_FORMAT_MIN_WIDTH = item.TRIM_FORMAT_MIN_WIDTH, TRIM_FORMAT_MAX_WIDTH = item.TRIM_FORMAT_MAX_WIDTH, OVERRIDE_AUTO_CALCULATION = item.OVERRIDE_AUTO_CALCULATION }; if (sggsCodePrintQuality != null) { trimFormat.SUPPORTED_PRINT_QUALITY = sggsCodePrintQuality.PRINT_QUALITY_ID; } if (!CheckTrimFormatIsValid(trimFormat, supportRanges)) { context.SGGS_SUPPORTED_TRIM_FORMATS.AddObject(trimFormat); } } context.SaveChanges(); return(true); } }
/// <summary> /// Update TrimFormat Update /// </summary> /// <param name="supportedTrimFormatId"></param> /// <param name="minPages"></param> /// <param name="maxPages"></param> /// <param name="minWidth"></param> /// <param name="maxWidth"></param> /// <param name="minHeight"></param> /// <param name="maxHeight"></param> /// <param name="overriding"></param> /// <returns></returns> public string Update(long supportedTrimFormatId, int?minPages, int?maxPages, decimal?minWidth, decimal?maxWidth, decimal?minHeight, decimal?maxHeight, bool overriding) { using (var context = new SGGSEntities()) { var trimFormats = context.SGGS_SUPPORTED_TRIM_FORMATS.FirstOrDefault(x => x.SUPPORTED_TRIM_FORMATS_ID == supportedTrimFormatId); if (trimFormats == null) { return("notSaved"); } trimFormats.TEXT_PAGE_COUNT_MIN = minPages; trimFormats.TEXT_PAGE_COUNT_MAX = maxPages; trimFormats.TRIM_FORMAT_MIN_WIDTH = minWidth; trimFormats.TRIM_FORMAT_MAX_WIDTH = maxWidth; trimFormats.TRIM_FORMAT_MIN_HEIGHT = minHeight; trimFormats.TRIM_FORMAT_MAX_HEIGHT = maxHeight; trimFormats.OVERRIDE_AUTO_CALCULATION = overriding; context.SaveChanges(); return("saved"); } }
/// <summary> /// Add Preferences to new Book /// </summary> /// <param name="bookId"></param> /// <param name="covertype"></param> /// <param name="unitOfMeasure"></param> /// <param name="BindingTypeNumber"></param> /// <param name="CoverPaper"></param> /// <param name="CoverFinish"></param> /// <param name="SpineWidth"></param> /// <param name="inner_pagecolor"></param> /// <param name="PrintQuality"></param> /// <param name="TextPaper"></param> /// <param name="pageTrimSize"></param> /// <returns></returns> public SGGS_BOOK_PREFERENCES AddBookPreference(long bookId , string covertype , string unitOfMeasure, string BindingTypeNumber, string CoverClothColor , string CoverPaper, string CoverFinish, string SpineWidth, string SpineStampLeft, string SpineStampCenter, string SpineStampRight , bool inner_pagecolor, string PrintQuality, string TextPaper , string pageTrimSize, long publisherId, long profileId, bool dustJacket, string DustJacketFinish) { decimal MMinInch = Convert.ToDecimal(25.4); SDSPortalApplication app = new SDSPortalApplication(); bool isnew = false; using (SGGSEntities objSGGS = new SGGSEntities()) { SGGS_BOOK_PREFERENCES _bookpreference = objSGGS.SGGS_BOOK_PREFERENCES.Where(P => P.BOOK_ID == bookId).FirstOrDefault(); //Get SLA_NUMBER_OF_PRODUCTION_DAYS by PUBLISHER_ID on SGGS_PUBLISHER_PREFRENCE SGGS_PUBLISHER_PREFRENCE _publisherPreference = objSGGS.SGGS_PUBLISHER_PREFRENCE.Where(PP => PP.PUBLISHER_ID == publisherId).FirstOrDefault(); SGGS_PRODUCTION_PLANT _productionPlan = (from pp in objSGGS.SGGS_PRODUCTION_PLANT join ppp in objSGGS.SGGS_PRINT_PLANT_PROFILE on pp.PRODUCTION_PLANT_ID equals ppp.PRODUCTION_PLANT_ID where ppp.PRINT_PLANT_PROFILE_ID == profileId select pp).FirstOrDefault(); if (_bookpreference == null) { _bookpreference = new SGGS_BOOK_PREFERENCES(); isnew = true; } CoverPaper = CoverPaper.Equals("-1") ? string.Empty : CoverPaper; CoverFinish = CoverFinish.Equals("-1") ? string.Empty : CoverFinish; _bookpreference.BOOK_ID = bookId; _bookpreference.BINDING_TYPE = BindingTypeNumber; _bookpreference.PRINT_QUALITY = PrintQuality; _bookpreference.COVER_CLOTH_COLOR = CoverClothColor.Equals("-1") ? string.Empty : CoverClothColor; _bookpreference.PROFILE_ID = profileId; _bookpreference.SPINE_STAMP_LEFT = SpineStampLeft; _bookpreference.SPINE_STAMP_CENTER = SpineStampCenter; _bookpreference.SPINE_STAMP_RIGHT = SpineStampRight; _bookpreference.POD_PAPER_COVER = CoverPaper; _bookpreference.COVER_FINISH = CoverFinish; _bookpreference.POD_PAPER_INNER_WORK = TextPaper; _bookpreference.ID_PAPER_COVER = CoverPaper; _bookpreference.ID_PAPER_INNER_WORK = TextPaper; _bookpreference.PRODUCTION_PLANT = _productionPlan.PRODUCTION_PLANT_NUMBER; _bookpreference.PRODUCTION_SITE = _publisherPreference.PRODUCTION_SITE; _bookpreference.DUST_JACKET_FINISH = DustJacketFinish; //SPINE_TYPE if (BindingTypeNumber.Equals("PB")) { _bookpreference.SPINE_TYPE = BindingTypeNumber; } else if (BindingTypeNumber.Equals("CF") || BindingTypeNumber.Equals("CL")) { _bookpreference.SPINE_TYPE = "SQ"; } //BARCODE_STRATEGY _bookpreference.BARCODE_STRATEGY = "XXX"; //SLA_NUMBER_OF_PRODUCTION_DAYS _bookpreference.SLA_NUMBER_OF_PRODUCTION_DAYS = _publisherPreference.SLA_NUMBER_OF_PRODUCTION_DAYS; //COVER TYPE if (covertype.Equals("soft")) { _bookpreference.COVER_TYPE = "SC"; } else if (covertype.Equals("hard")) { _bookpreference.COVER_TYPE = "HC"; } if (!string.IsNullOrEmpty(CoverPaper)) { var paperCover = objSGGS.SGGS_PAPER_TYPE.Where(o => o.PAPER_NUMBER == CoverPaper).Select(p => new { PAPER_WEIGHT_CWT = p.PAPER_WEIGHT_CWT, PAPER_WEIGHT_GSM = p.PAPER_WEIGHT_GSM }).FirstOrDefault(); if (paperCover != null) { //insert here the CWT and GSM of cover paper _bookpreference.POD_PAPER_COVER_WEIGHT_GSM = paperCover.PAPER_WEIGHT_GSM; _bookpreference.POD_PAPER_COVER_WEIGHT_CWT = paperCover.PAPER_WEIGHT_CWT; // OP/RP Cover Paper Stock _bookpreference.ID_PAPER_COVER_WEIGHT_GSM = paperCover.PAPER_WEIGHT_GSM; _bookpreference.ID_PAPER_COVER_WEIGHT_CWT = paperCover.PAPER_WEIGHT_CWT; } } if (!string.IsNullOrEmpty(TextPaper)) { var paperText = objSGGS.SGGS_PAPER_TYPE.Where(o => o.PAPER_NUMBER == TextPaper).Select(p => new { PAPER_WEIGHT_CWT = p.PAPER_WEIGHT_CWT, PAPER_WEIGHT_GSM = p.PAPER_WEIGHT_GSM }).FirstOrDefault(); if (paperText != null) { //insert here the CWT and GSM of Text Paper _bookpreference.POD_PAPER_INNER_WORK_WEIGHT_GSM = paperText.PAPER_WEIGHT_GSM; _bookpreference.POD_PAPER_INNER_WORK_WEIGHT_CWT = paperText.PAPER_WEIGHT_CWT; _bookpreference.FINANCIAL_SITE = objSGGS.SGGS_PUBLISHER_FINANCIAL_SITE.Where(p => p.PUBLISHER_ID == publisherId).Select(o => o.FINANCIAL_SITE_NUMBER).FirstOrDefault(); // OP/RP Text Paper Stock _bookpreference.ID_PAPER_INNER_WORK_WEIGHT_CWT = paperText.PAPER_WEIGHT_CWT; _bookpreference.ID_PAPER_INNER_WORK_WEIGHT_GSM = paperText.PAPER_WEIGHT_GSM; } } _bookpreference.DUST_JACKET = dustJacket; _bookpreference.SPINE_WIDTH_TOLERANCE = 3; _bookpreference.TRIM_SIZE_HEIGHT_MM_TOLERANCE = 1; _bookpreference.TRIM_SIZE_WIDTH_MM_TOLERANCE = 1; if (unitOfMeasure.Equals("inch")) { _bookpreference.UNIT_MEASURE = "in"; } else { _bookpreference.UNIT_MEASURE = unitOfMeasure; } if (unitOfMeasure.Equals("mm")) { string[] trimSizeSplit = pageTrimSize.Split('X'); _bookpreference.TRIM_FORMAT = trimSizeSplit[0].Trim() + trimSizeSplit[1].Trim(); _bookpreference.TRIM_FORMAT_WIDTH_MM = Convert.ToDecimal(trimSizeSplit[0].Trim()); _bookpreference.TRIM_FORMAT_HEIGHT_MM = Convert.ToDecimal(trimSizeSplit[1].Trim()); _bookpreference.SPINE_TYPE_WIDTH_MM = Convert.ToDecimal(SpineWidth); _bookpreference.TRIM_FORMAT_WIDTH_IN = Math.Round(Convert.ToDecimal(trimSizeSplit[0].Trim()) / MMinInch, 4); _bookpreference.TRIM_FORMAT_HEIGHT_IN = Math.Round(Convert.ToDecimal(trimSizeSplit[1].Trim()) / MMinInch, 4); _bookpreference.SPINE_TYPE_WIDTH_IN = Math.Round(Convert.ToDecimal(SpineWidth) / MMinInch, 4); } else { string[] trimSizeSplit = pageTrimSize.Split('X'); _bookpreference.TRIM_FORMAT_WIDTH_IN = Convert.ToDecimal(trimSizeSplit[0].Trim()); _bookpreference.TRIM_FORMAT_HEIGHT_IN = Convert.ToDecimal(trimSizeSplit[1].Trim()); _bookpreference.SPINE_TYPE_WIDTH_IN = Convert.ToDecimal(SpineWidth); _bookpreference.TRIM_FORMAT_WIDTH_MM = Math.Round(Convert.ToDecimal(trimSizeSplit[0].Trim()) * MMinInch, 0); _bookpreference.TRIM_FORMAT_HEIGHT_MM = Math.Round(Convert.ToDecimal(trimSizeSplit[1].Trim()) * MMinInch, 0); _bookpreference.SPINE_TYPE_WIDTH_MM = Math.Round(Convert.ToDecimal(SpineWidth) * MMinInch, 0); _bookpreference.TRIM_FORMAT = _bookpreference.TRIM_FORMAT_WIDTH_MM.ToString() + _bookpreference.TRIM_FORMAT_HEIGHT_MM.ToString(); } if (!isnew) { _bookpreference.DATE_UPDATED = DateTime.Now; objSGGS.SaveChanges(); } else { _bookpreference.DATE_ADDED = DateTime.Now; _bookpreference.DATE_UPDATED = DateTime.Now; objSGGS.SGGS_BOOK_PREFERENCES.AddObject(_bookpreference); objSGGS.SaveChanges(); } return(_bookpreference); } }