コード例 #1
0
        public static bool put_CUS_Version(AppEntities db, int PartnerID, int ID, DTO_CUS_Version item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_CUS_Version.Find(ID);

            if (dbitem != null)
            {
                dbitem.Code        = item.Code;
                dbitem.Name        = item.Name;
                dbitem.Remark      = item.Remark;
                dbitem.Sort        = item.Sort;
                dbitem.IsDisabled  = item.IsDisabled;
                dbitem.IsDeleted   = item.IsDeleted;
                dbitem.VersionDate = item.VersionDate;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_Version", dbitem.ModifiedDate, Username);


                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_CUS_Version", e);
                    result = false;
                }
            }
            return(result);
        }
コード例 #2
0
        public static DTO_CUS_Version post_CUS_Version(AppEntities db, int PartnerID, DTO_CUS_Version item, string Username)
        {
            tbl_CUS_Version dbitem = new tbl_CUS_Version();

            if (item != null)
            {
                dbitem.Code        = item.Code;
                dbitem.Name        = item.Name;
                dbitem.Remark      = item.Remark;
                dbitem.Sort        = item.Sort;
                dbitem.IsDisabled  = item.IsDisabled;
                dbitem.IsDeleted   = item.IsDeleted;
                dbitem.VersionDate = item.VersionDate;

                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                dbitem.IDPartner = PartnerID;


                try
                {
                    db.tbl_CUS_Version.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_Version", dbitem.ModifiedDate, Username);



                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;

                    item.IDPartner = dbitem.IDPartner;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_CUS_Version", e);
                    item = null;
                }
            }
            return(item);
        }