Example #1
0
        public IHttpActionResult views(int id, string query)
        {
            string       json      = HttpUtility.UrlDecode(query);
            SearchParams reqParams = Tools.JsonDeserialize <SearchParams>(json);

            return(Ok(ExtendModule.ViewArticles(id, reqParams)));
        }
Example #2
0
        public IHttpActionResult MultDelete(int[] ids)
        {
            var query = Dbctx.GgcmsArticles.Where(x => ids.Contains(x.Id));

            foreach (GgcmsArticles item in query.ToList())
            {
                //删除关联附件
                var attalist = Dbctx.GgcmsAttachments.Where(x => x.Articles_Id == item.Id);
                Dbctx.GgcmsAttachments.RemoveRange(attalist);
                //删除关联模型数据
                var category = dbHelper.Categories(Math.Abs(item.Category_Id));
                if (category != null)
                {
                    if (category.ExtModelId > 0)
                    {
                        ExtendModule.Delete(item.Id, category.ExtModelId);
                    }
                    updateArticleNumber(item.Category_Id, -1);
                }
                //删除关联分页
                Dbctx.GgcmsArticlePages.RemoveRange(Dbctx.GgcmsArticlePages.Where(x => x.Article_Id == item.Id));
            }
            Dbctx.GgcmsArticles.RemoveRange(query);
            int c = Dbctx.SaveChanges();

            ClearCache();
            CacheHelper.RemoveAllCache(CacheTypeNames.Categorys);
            return(Ok(c));
        }
Example #3
0
        public void Bind(ExtendModule.InstrumentAndConsumables mvaluables)
        {
            EquipPhoto.ImageUrl = "~/Equipment/PicShow.aspx?ID=" + mvaluables.ID;
            tbInstrumentNum.Text = mvaluables.Numbers;
            tbKindNum.Text = mvaluables.ClassNumber;
            tbInstrumentName.Text = mvaluables.Name;
            tbStandards.Text = mvaluables.Standards;
            tbModel.Text = mvaluables.Model;
            tbCountryCode.Text = mvaluables.CountryCode;
            tbAmount.Text = mvaluables.Quantity.ToString();
            tbUnitPrice.Text = mvaluables.UnitPrice;
            tbFactoryCode.Text = mvaluables.FactoryCode;
            tbDocuments.Text = mvaluables.Documents;
            tbMeasurement.Text = mvaluables.Measurement;
            try
            {
                tbProductionDate.Text = mvaluables.ProductionDate.Value.ToShortDateString();
                tbPurchaseDate.Text = mvaluables.PurchaseDate.Value.ToShortDateString();
                tbOpeningTime.Text = mvaluables.OpeningTime.Value.ToShortDateString();
                tbCreatedDate.Text = mvaluables.CreatedDate.Value.ToShortDateString();
            }
            catch { }

            tbResponesoblePerson.Text = mvaluables.ResponesoblePerson;
            tbContactPhone.Text = mvaluables.ContactPhone;
            tbCharges.Text = mvaluables.Charges;
            tbZipCode.Text = mvaluables.ZipCode;
            tbMailingAddress.Text = mvaluables.MailingAddress;
            tbPurpose.Text = mvaluables.Purpose;
        }
Example #4
0
        // DELETE: api/GgcmsCategories/5
        public IHttpActionResult Delete(int id)
        {
            GgcmsArticles info = Dbctx.GgcmsArticles.Find(id);

            if (info == null)
            {
                return(BadRequest("信息不存在"));
            }

            //删除关联模型数据
            var category = dbHelper.Categories(Math.Abs(info.Category_Id));

            if (category != null)
            {
                if (category.ExtModelId > 0)
                {
                    ExtendModule.Delete(info.Id, category.ExtModelId);
                }
                updateArticleNumber(info.Category_Id, -1);
            }
            Dbctx.GgcmsArticles.Remove(info);
            //删除关联附件
            Dbctx.GgcmsAttachments.RemoveRange(Dbctx.GgcmsAttachments.Where(x => x.Articles_Id == info.Id));
            //删除关联分页
            Dbctx.GgcmsArticlePages.RemoveRange(Dbctx.GgcmsArticlePages.Where(x => x.Article_Id == info.Id));
            Dbctx.SaveChanges();
            ClearCache();
            CacheHelper.RemoveAllCache(CacheTypeNames.Categorys);
            return(Ok(info));
        }
Example #5
0
        // POST: api/GgcmsCategories
        public IHttpActionResult Add(GgcmsArticles info)
        {
            //提交除附加模型外的文件-标题图,内容中的图
            UpFileClass.FileSave(info, info.files.FindAll(x => x.fileType != 3));
            info.CreateTime = DateTime.Now;
            updateArticleNumber(info.Category_Id, 1);
            CacheHelper.RemoveAllCache(CacheTypeNames.Categorys);
            if (info.ModuleInfo != null && info.ModuleInfo.Id > 0)
            {
                info.ExtModelId = info.ModuleInfo.Id;
            }
            info.pagesCount = info.pages.Count + 1;
            var result = Dbctx.GgcmsArticles.Add(info);

            Dbctx.SaveChanges();
            //附件
            using (GgcmsDB db = new GgcmsDB())
            {
                foreach (GgcmsAttachments attach in info.attachments)
                {
                    attach.Articles_Id = info.Id;
                    attach.CreateTime  = DateTime.Now;
                    db.GgcmsAttachments.Add(attach);
                }
                db.SaveChanges();
            }
            //数据模型
            if (info.ModuleInfo != null && info.ModuleInfo.Id > 0)
            {
                foreach (var file in info.files.FindAll(x => x.fileType == 3))
                {
                    foreach (var item in info.ModuleInfo.Columns)
                    {
                        if (item.ColName == file.propertyName)
                        {
                            item.Value = UpFileClass.FileSave(file.filePath.ToString(), item.Value.ToString(), (int)file.fileType);
                        }
                    }
                }
                ExtendModule.SaveData(info.Id, info.ModuleInfo);
            }

            //分页保存
            if (info.pages.Count > 0)
            {
                foreach (var page in info.pages)
                {
                    UpFileClass.FileSave(page, page.files);
                    page.Article_Id = info.Id;
                    Dbctx.GgcmsArticlePages.Add(page);
                }
                Dbctx.SaveChanges();
            }
            ClearCache();
            return(Ok(result));
        }
Example #6
0
        // GET: api/GgcmsCategories/5
        public IHttpActionResult GetInfo(int id)
        {
            GgcmsModules module = ExtendModule.GetGgcmsModule(id);

            if (module != null)
            {
                return(Ok(module));
            }

            return(BadRequest("信息不存在"));
        }
Example #7
0
        public IHttpActionResult Delete(int id)
        {
            ExtendModule.TableDelete(id);
            GgcmsModules module = Dbctx.GgcmsModules.Where(x => x.Id == id).FirstOrDefault();

            if (module != null)
            {
                Dbctx.GgcmsModules.Remove(module);
                Dbctx.SaveChanges();
            }
            ClearCache();
            return(Ok(id));
        }
Example #8
0
        // POST: api/GgcmsCategories
        public IHttpActionResult Add(GgcmsModules module)
        {
            if (!ExtendModule.ColumnsCheck(module))
            {
                return(BadRequest("字段关键字重复"));
            }
            var result = Dbctx.GgcmsModules.Add(module);

            Dbctx.SaveChanges();
            result.TableName = "moduleTab_" + result.Id.ToString();
            result.ViewName  = "moduleView_" + result.Id.ToString();
            ExtendModule.TableCreate(module);
            Dbctx.SaveChanges();
            ClearCache();
            return(Ok(result));
        }
Example #9
0
 // PUT: api/GgcmsCategories/5
 public IHttpActionResult Edit(GgcmsModules module)
 {
     if (!ExtendModule.ColumnsCheck(module))
     {
         return(BadRequest("字段关键字重复"));
     }
     if (module.Columns != null)
     {
         GgcmsModules oldModule = ExtendModule.GetGgcmsModule(module.Id);
         module.TableName = oldModule.TableName;
         module.ViewName  = oldModule.ViewName;
         ExtendModule.TableChange(module, oldModule);
     }
     Dbctx.SaveChanges();
     ClearCache();
     return(Ok(module));
 }
Example #10
0
        public void Bind(ExtendModule.GoodsMaintain mgoods)
        {
            tbLabNum.Text = mgoods.LabName.ToString();
            tbManager.Text = mgoods.AssetManagers.ToString();

            try
            {
                tbReportTime.Text = mgoods.ReportedTime.Value.ToShortDateString();
            }
            catch { }

            tbTelNum.Text = mgoods.Tel.ToString();
            tbStoreAdd.Text = mgoods.StorageSites.ToString();
            tbLowname.Text = mgoods.Name.ToString();
            tbLowNum.Text = mgoods.Numbers.ToString();
            tbApplyer.Text = mgoods.Applicant.ToString();
            isInTime.SelectedValue = mgoods.Guarantee.ToString();
            tbDescription.Text = mgoods.Describe.ToString();
        }
Example #11
0
        public void bindDDL(ExtendModule.InstrumentAndConsumables instrument)
        {
            ExtendBLL.Dictionary eDictionary = new ExtendBLL.Dictionary();
            List<Model.Dictionary> listCClass = new List<LabMS.Model.Dictionary>();
            tbCreatedDate.Text = DateTime.Today.ToLongDateString();
            listCClass = eDictionary.GetItemListByDClass("haocaileibie");
            ddlCClass.DataSource = listCClass;
            ddlCClass.DataTextField = "Name";
            ddlCClass.DataValueField = "Code";
            ddlCClass.DataBind();

            listCClass = eDictionary.GetItemListByDClass("shebeilaiyuan");
            ddlSource.DataSource = listCClass;
            ddlSource.DataTextField = "Name";
            ddlSource.DataValueField = "Code";
            ddlSource.DataBind();

            listCClass = eDictionary.GetItemListByDClass("shiyongfangxiang");
            ddlArrow.DataSource = listCClass;
            ddlArrow.DataTextField = "Name";
            ddlArrow.DataValueField = "Code";
            ddlArrow.DataBind();

            listCClass = eDictionary.GetItemListByDClass("jingfeikemu");
            ddlFundsSubject.DataSource = listCClass;
            ddlFundsSubject.DataTextField = "Name";
            ddlFundsSubject.DataValueField = "Code";
            ddlFundsSubject.DataBind();

            listCClass = eDictionary.GetItemListByDClass("dangwei");
            ddlModle.DataSource = listCClass;
            ddlModle.DataTextField = "Name";
            ddlModle.DataValueField = "Code";
            ddlModle.DataBind();

            ExtendBLL.InstrumentAndConsumables eConsum = new ExtendBLL.InstrumentAndConsumables();
            int iMaxCID = eConsum.GetMaxId();
            MaxCID.Value = iMaxCID.ToString("D10");
            tbInstrumentNum.Text = iMaxCID.ToString("D10");

            tbLocation.Text = instrument.LabName;
            tbLocationCode.Text = instrument.StockLocation;
        }
Example #12
0
        public void bindDDL(ExtendModule.InstrumentAndConsumables mconsum)
        {
            labelCreatDate.Text = DateTime.Today.ToShortDateString();
            ExtendBLL.Dictionary eDictionary = new ExtendBLL.Dictionary();
            List<Model.Dictionary> listCClass = new List<LabMS.Model.Dictionary>();
            listCClass = eDictionary.GetItemListByDClass("haocaileibie");
            ddlCClass.DataSource = listCClass;
            ddlCClass.DataTextField = "Name";
            ddlCClass.DataValueField = "Code";
            ddlCClass.DataBind();
            ddlCClass.SelectedValue = mconsum.ClassNumber;

            listCClass = eDictionary.GetItemListByDClass("shebeilaiyuan");
            ddlComeFrom.DataSource = listCClass;
            ddlComeFrom.DataTextField = "Name";
            ddlComeFrom.DataValueField = "Code";
            ddlComeFrom.DataBind();
            ddlComeFrom.SelectedValue = mconsum.Source;

            listCClass = eDictionary.GetItemListByDClass("shiyongfangxiang");
            ddlArrow.DataSource = listCClass;
            ddlArrow.DataTextField = "Name";
            ddlArrow.DataValueField = "Code";
            ddlArrow.DataBind();
            ddlArrow.SelectedValue = mconsum.Arrow;

            listCClass = eDictionary.GetItemListByDClass("jingfeikemu");
            ddlFundsSubject.DataSource = listCClass;
            ddlFundsSubject.DataTextField = "Name";
            ddlFundsSubject.DataValueField = "Code";
            ddlFundsSubject.DataBind();
            ddlFundsSubject.SelectedValue = mconsum.FundsSubject;

            listCClass = eDictionary.GetItemListByDClass("dangwei");
            ddlModle.DataSource = listCClass;
            ddlModle.DataTextField = "Name";
            ddlModle.DataValueField = "Code";
            ddlModle.DataBind();
            ddlModle.SelectedValue = mconsum.Measurement;

            tbLocation.Text = mconsum.LabName;
            tbLocationCode.Text  = mconsum.StockLocation;
        }
Example #13
0
 public IHttpActionResult MultDelete(int[] ids)
 {
     try
     {
         var query = Dbctx.GgcmsModules.Where(x => ids.Contains(x.Id));
         foreach (var item in query.ToList())
         {
             GgcmsModules module = item as GgcmsModules;
             ExtendModule.TableDelete(module.Id);
         }
         Dbctx.GgcmsModules.RemoveRange(query);
         int c = Dbctx.SaveChanges();
         ClearCache();
         return(Ok(c));
     } catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Example #14
0
        public void bindDDL(ExtendModule.InstrumentAndConsumables mvaluables)
        {
            tbCreatedDate.Text = DateTime.Today.ToShortDateString();
            ExtendBLL.Dictionary eDictionary = new ExtendBLL.Dictionary();
            List<Model.Dictionary> listCClass = new List<LabMS.Model.Dictionary>();

            listCClass = eDictionary.GetItemListByDClass("shebeilaiyuan");
            ddlSource.DataSource = listCClass;
            ddlSource.DataTextField = "Name";
            ddlSource.DataValueField = "Code";
            ddlSource.DataBind();
            ddlSource.SelectedValue = mvaluables.Source;

            listCClass = eDictionary.GetItemListByDClass("shiyongfangxiang");
            ddlArrow.DataSource = listCClass;
            ddlArrow.DataTextField = "Name";
            ddlArrow.DataValueField = "Code";
            ddlArrow.DataBind();
            ddlArrow.SelectedValue = mvaluables.Arrow;

            listCClass = eDictionary.GetItemListByDClass("shebeizhuangtai");
            ddlPresentSituation.DataSource = listCClass;
            ddlPresentSituation.DataTextField = "Name";
            ddlPresentSituation.DataValueField = "Code";
            ddlPresentSituation.DataBind();
            ddlPresentSituation.SelectedValue = mvaluables.ResponesoblePerson;

            listCClass = eDictionary.GetItemListByDClass("jingfeikemu");
            ddlFundsSubject.DataSource = listCClass;
            ddlFundsSubject.DataTextField = "Name";
            ddlFundsSubject.DataValueField = "Code";
            ddlFundsSubject.DataBind();
            ddlFundsSubject.SelectedValue = mvaluables.FundsSubject;

            tbLocation.Text = mvaluables.LabName;
            tbLocationCode.Text = mvaluables.StockLocation;
        }
Example #15
0
        void bind(ExtendModule.InstrumentAndConsumables mconsum)
        {
            EquipPhoto.ImageUrl = "~/Equipment/PicShow.aspx?ID=" + mconsum.ID;
            lbClassNub.Text = mconsum.ClassNumber.ToString();
            lbCName.Text = mconsum.Name;
            lbCNub.Text = mconsum.Numbers;
            lbCountry.Text = mconsum.CountryCode;

            lbDocuments.Text = mconsum.Documents.ToString();
            lbFNub.Text = mconsum.FactoryCode.ToString();
            lbNub.Text = mconsum.Quantity.ToString();
            lbPrice.Text = mconsum.UnitPrice;
            lbPurpose.Text = mconsum.Purpose;
            try
            {
                lbProduceDate.Text = mconsum.ProductionDate.Value.ToShortDateString();
            }
            catch { }
            try
            {
                lbCreatDate.Text = mconsum.CreatedDate.Value.ToShortDateString();
            }
            catch { }
            try
            {
                lbBuyDate.Text = mconsum.PurchaseDate.Value.ToShortDateString();
            }
            catch { }

            lbTypeNub.Text = mconsum.Model;
            lbVENDOR.Text = "";//应加上
        }
Example #16
0
 public IHttpActionResult GetGgcmsModuleValue(int aid, int mid)
 {
     return(Ok(ExtendModule.GetModuleToDict(aid, mid)));
 }
Example #17
0
        // PUT: api/GgcmsCategories/5
        public IHttpActionResult Edit(GgcmsArticles info)
        {
            if (Dbctx.GgcmsArticles.Where(x => x.Id == info.Id).Count() == 0)
            {
                return(BadRequest("信息不存在"));
            }
            //Dbctx.GgcmsArticles.Attach(info);
            //Dbctx.Entry(info).Property("goods_name").IsModified = true;
            var ent = Dbctx.Entry(info);

            ent.State       = EntityState.Modified;
            info.pagesCount = info.pages.Where(x => x.state != EntityState.Deleted).Count() + 1;
            UpFileClass.FileSave(info, info.files.FindAll(x => x.fileType != 3));
            var old = Dbctx.GgcmsArticles.Find(info.Id);

            if (old.Category_Id != info.Category_Id)
            {
                updateArticleNumber(info.Category_Id, 1);
                updateArticleNumber(old.Category_Id, -1);
                CacheHelper.RemoveAllCache(CacheTypeNames.Categorys);
            }
            var list = Dbctx.GgcmsAttachments.Where(x => x.Articles_Id == info.Id).ToList();

            //附件
            foreach (GgcmsAttachments attach in list)
            {
                var item = info.attachments.Find(x => x.Id == attach.Id);
                if (item == null)
                {
                    Dbctx.GgcmsAttachments.Remove(attach);
                }
                else
                {
                    attach.AttaUrl    = item.AttaUrl;
                    attach.AttaTitle  = item.AttaTitle;
                    attach.Describe   = item.Describe;
                    attach.CreateTime = DateTime.Now;
                    attach.RealName   = item.RealName;
                }
            }
            foreach (GgcmsAttachments attach in info.attachments)
            {
                if (attach.Id == 0)
                {
                    attach.Articles_Id = info.Id;
                    attach.CreateTime  = DateTime.Now;
                    Dbctx.GgcmsAttachments.Add(attach);
                }
            }
            if (info.ModuleInfo != null)
            {
                info.ExtModelId = info.ModuleInfo.Id;
                if (old.ExtModelId > 0 && info.ExtModelId != old.ExtModelId)
                {
                    ExtendModule.Delete(info.Id, old.ExtModelId);
                }
                foreach (var file in info.files.FindAll(x => x.fileType == 3))
                {
                    foreach (var item in info.ModuleInfo.Columns)
                    {
                        if (item.ColName == file.propertyName)
                        {
                            item.Value = UpFileClass.FileSave(file.filePath.ToString(), item.Value.ToString(), (int)file.fileType);
                        }
                    }
                }
                ExtendModule.SaveData(info.Id, info.ModuleInfo);
            }
            else if (old.ExtModelId > 0)
            {
                ExtendModule.Delete(info.Id, old.ExtModelId);
            }
            //分页保存
            if (info.pages.Count > 0)
            {
                foreach (var page in info.pages)
                {
                    UpFileClass.FileSave(page, page.files);
                    if (page.state == EntityState.Added)
                    {
                        page.Article_Id = info.Id;
                        Dbctx.GgcmsArticlePages.Add(page);
                    }
                    else if (page.state == EntityState.Modified)
                    {
                        var pageEnt = Dbctx.Entry(page);
                        pageEnt.State = EntityState.Modified;
                    }
                    else if (page.state == EntityState.Deleted)
                    {
                        var p = Dbctx.GgcmsArticlePages.Find(page.Id);
                        if (p != null)
                        {
                            Dbctx.GgcmsArticlePages.Remove(p);
                        }
                    }
                    //只更新分页信息
                    else if (page.state == EntityState.Unchanged)
                    {
                        Dbctx.GgcmsArticlePages.Attach(page);
                        Dbctx.Entry(info).Property("OrderId").IsModified = true;
                    }
                }
            }
            Dbctx.SaveChanges();
            ClearCache();
            return(Ok(info));
        }
Example #18
0
        void bind(ExtendModule.InstrumentAndConsumables instrument)
        {
            EquipPhoto.ImageUrl = "~/Equipment/PicShow.aspx?ID=" + instrument.ID;
            tbStandards.Text = instrument.Standards;
            tbContactPhone.Text = instrument.ContactPhone.ToString();
            tbResponesoblePerson.Text = instrument.ResponesoblePerson;
            tbPurpose.Text = instrument.Purpose;
            tbModel.Text = instrument.Model;
            tbKindNum.Text = instrument.ClassNumber.ToString();
            tbInstrumentName.Text = instrument.Name;
            tbInstrumentNum.Text = instrument.Numbers;
            tbCountry.Text = instrument.CountryCode;

            tbDocuments.Text = instrument.Documents.ToString();
            tbFactoryCode.Text = instrument.FactoryCode.ToString();
            tbAmount.Text = instrument.Quantity.ToString();
            tbUnitPrice.Text = instrument.UnitPrice;
            try
            {
                tbProductionDate.Text = instrument.ProductionDate.Value.ToShortDateString();
            }
            catch { }
            try
            {
                tbCreatedDate.Text = instrument.CreatedDate.Value.ToShortDateString();
            }
            catch { }
            try
            {
                tbPurchaseDate.Text = instrument.PurchaseDate.Value.ToShortDateString();
            }
            catch { }

            //tbVENDOR.Text = "";//应加上
        }