Пример #1
0
        public List <DrugCategory> SearchDrugCategory(string searchCond, IDbConnection conn)
        {
            string sql = @"select 
            ID,DrugCategoryCode,DrugCategoryName,Actived,Remark 
            from MD_DrugCategory
            where DrugCategoryCode like @DrugCategoryCode 
            or DrugCategoryName like @DrugCategoryName
            ";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@DrugCategoryCode", string.Format("%{0}%", searchCond)));
            paramList.Add(new SqlParameter("@DrugCategoryName", string.Format("%{0}%", searchCond)));
            SqlDataReader       reader       = DataAccessUtil.ExecuteReader(sql, paramList, (SqlConnection)conn);
            List <DrugCategory> categoryList = new List <DrugCategory>();

            while (reader.Read())
            {
                DrugCategory category = new DrugCategory();
                category.ID      = reader.GetInt32(0);
                category.Code    = reader.GetString(1);
                category.Name    = reader.GetString(2);
                category.Actived = reader.GetBoolean(3);
                if (!reader.IsDBNull(4))
                {
                    category.Remark = reader.GetString(4);
                }
                categoryList.Add(category);
            }
            reader.Close();
            return(categoryList);
        }
Пример #2
0
        public IngestiblePropertiesStats(IngestibleProperties p)
        {
            this.maxNumToIngestAtOnce = p.maxNumToIngestAtOnce;
            this.baseIngestTicks      = p.baseIngestTicks;
            this.chairSearchRadius    = p.chairSearchRadius;
            this.useEatingSpeedStat   = p.useEatingSpeedStat;
            //this.ingestCommandString = p.ingestCommandString;
            //this.ingestReportString = p.ingestReportString;
            //this.ingestReportStringEat = p.ingestReportStringEat;
            this.ingestHoldUsesTable = p.ingestHoldUsesTable;
            this.foodType            = p.foodType;
            this.joy           = p.joy;
            this.preferability = p.preferability;
            this.nurseable     = p.nurseable;
            this.optimalityOffsetHumanlikes     = p.optimalityOffsetHumanlikes;
            this.optimalityOffsetFeedingAnimals = p.optimalityOffsetFeedingAnimals;
            this.drugCategory = p.drugCategory;

            if (p.ingestHoldOffsetStanding != null)
            {
                this.ingestHoldOffsetStanding = new HoldOffsetSetStats(p.ingestHoldOffsetStanding);
            }

            //Util.AssignDefStat(p.parent, out this.parent);
            Util.AssignDefStat(p.joyKind, out this.joyKind);
            Util.AssignDefStat(p.sourceDef, out this.sourceDef);
            Util.AssignDefStat(p.tasteThought, out this.tasteThought);
            Util.AssignDefStat(p.specialThoughtDirect, out this.specialThoughtDirect);
            Util.AssignDefStat(p.specialThoughtAsIngredient, out this.specialThoughtAsIngredient);
            Util.AssignDefStat(p.ingestEffect, out this.ingestEffect);
            Util.AssignDefStat(p.ingestEffectEat, out this.ingestEffectEat);
            Util.AssignDefStat(p.ingestSound, out this.ingestSound);
        }
Пример #3
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.

        public async Task <IActionResult> OnPostAsync(string[] selectedCategories)
        {
            var newDrug = new Drug();

            if (selectedCategories != null)
            {
                newDrug.DrugCategories = new List <DrugCategory>();
                foreach (var cat in selectedCategories)
                {
                    var catToAdd = new DrugCategory
                    {
                        CategoryID = int.Parse(cat)
                    };
                    newDrug.DrugCategories.Add(catToAdd);
                }
            }
            if (await TryUpdateModelAsync <Drug>(
                    newDrug,
                    "Drug",
                    i => i.Name, i => i.Producer,
                    i => i.Price, i => i.PublishingDate, i => i.PartnerID))
            {
                _context.Drug.Add(newDrug);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateAssignedCategoryData(_context, newDrug);
            return(Page());
        }
Пример #4
0
        public static bool CanBingeOnNow(Pawn pawn, ChemicalDef chemical, DrugCategory drugCategory)
        {
            if (!chemical.canBinge)
            {
                return(false);
            }
            if (!pawn.Spawned)
            {
                return(false);
            }
            List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Drug);

            for (int i = 0; i < list.Count; i++)
            {
                if (!list[i].Position.Fogged(list[i].Map) && (drugCategory == DrugCategory.Any || list[i].def.ingestible.drugCategory == drugCategory))
                {
                    CompDrug compDrug = list[i].TryGetComp <CompDrug>();
                    if (compDrug.Props.chemical == chemical && (list[i].Position.Roofed(list[i].Map) || list[i].Position.InHorDistOf(pawn.Position, 45f)) && pawn.CanReach(list[i], PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #5
0
        public DrugCategory SelectDrugCategory(int id, IDbConnection conn)
        {
            string sql = @"
            select ID,DrugCategoryCode,DrugCategoryName,Actived,Remark
            from MD_DrugCategory where ID=@ID";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@ID", id));
            SqlDataReader reader   = DataAccessUtil.ExecuteReader(sql, paramList, (SqlConnection)conn);
            DrugCategory  category = null;

            while (reader.Read())
            {
                category         = new DrugCategory();
                category.ID      = reader.GetInt32(0);
                category.Code    = reader.GetString(1);
                category.Name    = reader.GetString(2);
                category.Actived = reader.GetBoolean(3);
                if (!reader.IsDBNull(4))
                {
                    category.Remark = reader.GetString(4);
                }
            }
            reader.Close();
            return(category);
        }
Пример #6
0
        protected override Thing BestIngestTarget(Pawn pawn)
        {
            ChemicalDef  chemical     = this.GetChemical(pawn);
            DrugCategory drugCategory = this.GetDrugCategory(pawn);

            if (chemical == null)
            {
                Log.ErrorOnce("Tried to binge on null chemical.", 1393746152, false);
                return(null);
            }
            Hediff            overdose  = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.DrugOverdose, false);
            Predicate <Thing> predicate = delegate(Thing t)
            {
                if (!this.IgnoreForbid(pawn) && t.IsForbidden(pawn))
                {
                    return(false);
                }
                if (!pawn.CanReserve(t, 1, -1, null, false))
                {
                    return(false);
                }
                CompDrug compDrug = t.TryGetComp <CompDrug>();
                return(compDrug.Props.chemical == chemical && (overdose == null || !compDrug.Props.CanCauseOverdose || overdose.Severity + compDrug.Props.overdoseSeverityOffset.max < 0.786f) && (pawn.Position.InHorDistOf(t.Position, 60f) || t.Position.Roofed(t.Map) || pawn.Map.areaManager.Home[t.Position] || t.GetSlotGroup() != null) && t.def.ingestible.drugCategory.IncludedIn(drugCategory));
            };
            IntVec3           position       = pawn.Position;
            Map               map            = pawn.Map;
            ThingRequest      thingReq       = ThingRequest.ForGroup(ThingRequestGroup.Drug);
            PathEndMode       peMode         = PathEndMode.OnCell;
            TraverseParms     traverseParams = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false);
            Predicate <Thing> validator      = predicate;

            return(GenClosest.ClosestThingReachable(position, map, thingReq, peMode, traverseParams, 9999f, validator, null, 0, -1, false, RegionType.Set_Passable, false));
        }
Пример #7
0
 /// <summary>
 /// 删除一条药品种类
 /// </summary>
 /// <param name="category"></param>
 /// <param name="deleter"></param>
 public void DeleteDrugCategory(DrugCategory category, string deleter)
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IDrugCategoryDAO dao = DAOFactory.Instance.CreateDrugCategoryDAO();
         dao.DeleteDrugCategory(category.ID, conn);
     }
 }
Пример #8
0
 /// <summary>
 /// 保存修改的药品种类
 /// </summary>
 /// <param name="category"></param>
 /// <param name="modifier"></param>
 public void SaveDrugCategory(DrugCategory category, string modifier)
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IDrugCategoryDAO dao = DAOFactory.Instance.CreateDrugCategoryDAO();
         dao.UpdateDrugCategory(category, conn);
     }
 }
Пример #9
0
 /// <summary>
 /// 增加一个药品种类
 /// </summary>
 /// <param name="category"></param>
 /// <param name="creator"></param>
 public void CreateDrugCategory(DrugCategory category, string creator)
 {
     using (IDbConnection conn = DAOFactory.Instance.OpenConnection())
     {
         IDrugCategoryDAO dao = DAOFactory.Instance.CreateDrugCategoryDAO();
         dao.InsertDrugCategory(category, conn);
     }
 }
Пример #10
0
 /// <summary>
 /// 用于修改
 /// </summary>
 /// <param name="model"></param>
 public FrmDrugCategory(DrugCategory model)
 {
     InitializeComponent();
     this.Text               = string.Format(this.Text, "修改药品类别");
     this.Model              = model;
     this.txtCode.Text       = model.Code;
     this.txtName.Text       = model.Name;
     this.ckbActived.Checked = model.Actived;
     this.txtRemark.Text     = model.Remark;
 }
Пример #11
0
        public FormDrugCategory()
        {
            InitializeComponent();

            unit               = new DrugCategory();
            _formSate          = FormOperation.Empty;
            selectId           = string.Empty;
            selectRow          = -1;
            afterStateChanged += new AfterStateChanged(OnAfterStateChanged);
        }
Пример #12
0
 public Task <int> SaveDrugCategory(DrugCategory category)
 {
     if (category.ID != 0)
     {
         return(Database.UpdateAsync(category));
     }
     else
     {
         return(Database.InsertAsync(category));
     }
 }
Пример #13
0
        public void InsertDrugCategory(DrugCategory category, IDbConnection conn, IDbTransaction trans)
        {
            string sql = @"
            Insert into MD_DrugCategory(DrugCategoryCode,DrugCategoryName,Actived,Remark) 
            values(@DrugCategoryCode,@DrugCategoryName,@Actived,@Remark)  ";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@DrugCategoryCode", category.Code));
            paramList.Add(new SqlParameter("@DrugCategoryName", category.Name));
            paramList.Add(new SqlParameter("@Actived", category.Actived));
            paramList.Add(new SqlParameter("@Remark", category.Remark));
            DataAccessUtil.ExecuteNonQuery(sql, paramList, (SqlTransaction)trans);
        }
        public bool CanBingeOnNow(Pawn pawn, ChemicalDef chemical, DrugCategory drugCategory)
        {
            List <Thing> thingList = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Drug);

            for (int index = 0; index < thingList.Count; ++index)
            {
                if (!thingList[index].Position.Fogged(thingList[index].Map) && (drugCategory == DrugCategory.Any || thingList[index].def.ingestible.drugCategory == drugCategory) && thingList[index].TryGetComp <CompDrug>().Props.chemical == chemical && (thingList[index].Position.Roofed(thingList[index].Map) || thingList[index].Position.InHorDistOf(pawn.Position, 45f)) && pawn.CanReach((LocalTargetInfo)thingList[index], PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #15
0
        public void UpdateDrugCategory(DrugCategory category, IDbConnection conn, IDbTransaction trans)
        {
            string sql = @"
            Update MD_DrugCategory set 
                DrugCategoryCode=@DrugCategoryCode,DrugCategoryName=@DrugCategoryName,Actived=@Actived,Remark=@Remark
            where ID=@ID";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("@DrugCategoryCode", category.Code));
            paramList.Add(new SqlParameter("@DrugCategoryName", category.Name));
            paramList.Add(new SqlParameter("@Actived", category.Actived));
            paramList.Add(new SqlParameter("@Remark", category.Remark));
            paramList.Add(new SqlParameter("@ID", category.ID));
            DataAccessUtil.ExecuteNonQuery(sql, paramList, (SqlTransaction)trans);
        }
        private void ChooseRandomChemical()
        {
            MentalState_BingingDrug.addictions.Clear();
            List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs;

            for (int i = 0; i < hediffs.Count; i++)
            {
                Hediff_Addiction hediff_Addiction = hediffs[i] as Hediff_Addiction;
                if (hediff_Addiction != null && AddictionUtility.CanBingeOnNow(this.pawn, hediff_Addiction.Chemical, DrugCategory.Any))
                {
                    MentalState_BingingDrug.addictions.Add(hediff_Addiction.Chemical);
                }
            }
            if (MentalState_BingingDrug.addictions.Count > 0)
            {
                this.chemical     = MentalState_BingingDrug.addictions.RandomElement <ChemicalDef>();
                this.drugCategory = DrugCategory.Any;
                MentalState_BingingDrug.addictions.Clear();
            }
            else
            {
                this.chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading
                                 where AddictionUtility.CanBingeOnNow(this.pawn, x, this.def.drugCategory)
                                 select x).RandomElementWithFallback(null);
                if (this.chemical != null)
                {
                    this.drugCategory = this.def.drugCategory;
                }
                else
                {
                    this.chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading
                                     where AddictionUtility.CanBingeOnNow(this.pawn, x, DrugCategory.Any)
                                     select x).RandomElementWithFallback(null);
                    if (this.chemical != null)
                    {
                        this.drugCategory = DrugCategory.Any;
                    }
                    else
                    {
                        this.chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.RandomElement <ChemicalDef>();

                        this.drugCategory = DrugCategory.Any;
                    }
                }
            }
        }
Пример #17
0
        public List <FacilityDrug> GetInventoryDrugs(Facility facility, DrugCategory category, string filter = "")
        {
            List <FacilityDrug> FacilityDrug = new List <FacilityDrug>();
            SqlServerConnection conn         = new SqlServerConnection();

            string query = conn.GetQueryString(filter, "drg_initial+'-'+drg_name+'-'+dc_name+'-'+df_name+'-'+df_dosage", "fd_idnt>0");

            if (!(facility is null))
            {
                query += " AND fd_facility=" + facility.Id;
            }
            if (!(category is null))
            {
                query += " AND dc_idnt=" + category.Id;
            }

            SqlDataReader dr = conn.SqlServerConnect("SELECT fd_idnt, fd_reorder, ISNULL(avls,0)fd_avls, drg_idnt, drg_initial, drg_name, dc_idnt, dc_name, df_idnt, df_name, df_dosage FROM InventoryFacilityDrug INNER JOIN InventoryDrug ON fd_drug=drg_idnt INNER JOIN InventoryDrugCategory ON drg_category=dc_idnt INNER JOIN InventoryDrugFormulation ON drg_formulation=df_idnt LEFT OUTER JOIN vDrugsSummary ON fac=fd_facility AND drg=fd_drug " + query + " ORDER BY drg_name");

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    FacilityDrug.Add(new FacilityDrug {
                        Id        = Convert.ToInt64(dr[0]),
                        Reorder   = Convert.ToInt64(dr[1]),
                        Available = Convert.ToInt64(dr[2]),
                        Drug      = new Drug {
                            Id       = Convert.ToInt64(dr[3]),
                            Initial  = dr[4].ToString(),
                            Name     = dr[5].ToString(),
                            Category = new DrugCategory {
                                Id   = Convert.ToInt64(dr[6]),
                                Name = dr[7].ToString()
                            },
                            Formulation = new DrugFormulation {
                                Id     = Convert.ToInt64(dr[8]),
                                Name   = dr[9].ToString(),
                                Dosage = dr[10].ToString(),
                            }
                        },
                    });
                }
            }

            return(FacilityDrug);
        }
        protected override Thing BestIngestTarget(Pawn pawn)
        {
            ChemicalDef  chemical     = GetChemical(pawn);
            DrugCategory drugCategory = GetDrugCategory(pawn);

            if (chemical == null)
            {
                Log.ErrorOnce("Tried to binge on null chemical.", 1393746152);
                return(null);
            }

            Hediff            overdose  = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.DrugOverdose);
            Predicate <Thing> validator = delegate(Thing t)
            {
                if (!IgnoreForbid(pawn) && t.IsForbidden(pawn))
                {
                    return(false);
                }
                if (!pawn.CanReserve(t))
                {
                    return(false);
                }
                var compDrug = t.TryGetComp <CompDrug>();
                if (compDrug.Props.chemical != chemical)
                {
                    return(false);
                }
                if (overdose != null &&
                    compDrug.Props.CanCauseOverdose &&
                    overdose.Severity + compDrug.Props.overdoseSeverityOffset.max >= 0.786f)
                {
                    return(false);
                }
                if (!pawn.Position.InHorDistOf(t.Position, 60f) &&
                    !t.Position.Roofed(t.Map) &&
                    !pawn.Map.areaManager.Home[t.Position] &&
                    t.GetSlotGroup() == null)
                {
                    return(false);
                }
                return(t.def.ingestible.drugCategory.IncludedIn(drugCategory) ? true : false);
            };

            return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.Drug),
                                                    PathEndMode.OnCell, TraverseParms.For(pawn), 9999f, validator));
        }
Пример #19
0
        private void ChooseRandomChemical()
        {
            addictions.Clear();
            List <Hediff> hediffs = pawn.health.hediffSet.hediffs;

            for (int i = 0; i < hediffs.Count; i++)
            {
                Hediff_Addiction hediff_Addiction = hediffs[i] as Hediff_Addiction;
                if (hediff_Addiction != null && AddictionUtility.CanBingeOnNow(pawn, hediff_Addiction.Chemical, DrugCategory.Any))
                {
                    addictions.Add(hediff_Addiction.Chemical);
                }
            }
            if (addictions.Count > 0)
            {
                chemical     = addictions.RandomElement();
                drugCategory = DrugCategory.Any;
                addictions.Clear();
            }
            else
            {
                chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading
                            where AddictionUtility.CanBingeOnNow(pawn, x, def.drugCategory)
                            select x).RandomElementWithFallback();
                if (chemical != null)
                {
                    drugCategory = def.drugCategory;
                }
                else
                {
                    chemical = (from x in DefDatabase <ChemicalDef> .AllDefsListForReading
                                where AddictionUtility.CanBingeOnNow(pawn, x, DrugCategory.Any)
                                select x).RandomElementWithFallback();
                    if (chemical != null)
                    {
                        drugCategory = DrugCategory.Any;
                    }
                    else
                    {
                        chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.RandomElement();

                        drugCategory = DrugCategory.Any;
                    }
                }
            }
        }
Пример #20
0
        /// <summary>
        /// The create drug category.
        /// </summary>
        /// <param name="category">
        /// The category.
        /// </param>
        public void CreateDrugCategory(IDrugCategory category)
        {
            var cat = new DrugCategory
            {
                IsActive    = true,
                Code        = category.Code,
                CreatedBy   = category.CreatedBy ?? Thread.CurrentPrincipal.Identity.Name,
                CreatedOn   = DateTime.UtcNow,
                Description = category.Description,
                Name        = category.Name,
                Status      = (int)EntityStatusType.Current,
                SortOrder   = category.SortOrder,
                Directions  = category.Directions
            };

            _context.DrugCategories.Add(cat);
        }
Пример #21
0
        private List <DrugCategory> GetSelectModelList()
        {
            List <DrugCategory> selectedModelList = new List <DrugCategory>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)row.Cells[0];
                if (cell.EditedFormattedValue != null && (bool)cell.EditedFormattedValue == true)
                {
                    DrugCategory selectedModel = (DrugCategory)row.Tag;
                    selectedModelList.Add(selectedModel);
                }
            }
            if (selectedModelList.Count == 0)
            {
                throw new ApplicationException("请选择要操作的内容。");
            }
            return(selectedModelList);
        }
Пример #22
0
        public async Task <ActionResult> AddDrugCategory(string categoryName)
        {
            if (string.IsNullOrEmpty(categoryName))
            {
                TempData["Error"] = "لطفا نام دسته را وارد نمایید";
                return(RedirectToAction("ManageDrugsCategory"));
            }
            var category = new DrugCategory()
            {
                Name = categoryName
            };

            await _db.DrugCategories.AddAsync(category);

            await _db.SaveChangesAsync();

            TempData["Success"] = "دسته جدید با موفقیت افزوده شد";
            return(RedirectToAction("ManageDrugsCategory"));
        }
Пример #23
0
        private void ChooseRandomChemical()
        {
            addictions.Clear();
            List <Hediff> hediffs = pawn.health.hediffSet.hediffs;

            for (var i = 0; i < hediffs.Count; i++)
            {
                var hediff_Addiction = hediffs[i] as Hediff_Addiction;
                if (hediff_Addiction != null && AddictionUtility.CanBingeOnNow(pawn, hediff_Addiction.Chemical, DrugCategory.Any))
                {
                    addictions.Add(hediff_Addiction.Chemical);
                }
            }

            if (addictions.Count > 0)
            {
                chemical     = addictions.RandomElement();
                drugCategory = DrugCategory.Any;
                addictions.Clear();
                return;
            }

            chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.Where(IsValidChemical).RandomElementWithFallback();

            if (chemical != null)
            {
                drugCategory = def.drugCategory;
                return;
            }

            chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.Where(IsValidChemical).RandomElementWithFallback();

            if (chemical != null)
            {
                drugCategory = DrugCategory.Any;
                return;
            }

            chemical = DefDatabase <ChemicalDef> .AllDefsListForReading.RandomElement();

            drugCategory = DrugCategory.Any;
        }
        public JsonResult GetExpiredDrugBatches(long facl, long catg = 0, string filter = "")
        {
            Facility     facility = null;
            DrugCategory category = null;

            if (!facl.Equals(0))
            {
                facility = new Facility(facl);
            }
            if (!catg.Equals(0))
            {
                category = new DrugCategory(catg);
            }
            if (string.IsNullOrEmpty(filter))
            {
                filter = "";
            }

            return(Json(new DrugService().GetDrugBatches(facility, category, DateTime.Now, true, false, filter)));
        }
        public JsonResult GetDrugReceiptDetails(long facl, long catg = 0, string filter = "")
        {
            Facility     facility = null;
            DrugCategory category = null;

            if (!facl.Equals(0))
            {
                facility = new Facility(facl);
            }
            if (!catg.Equals(0))
            {
                category = new DrugCategory(catg);
            }
            if (string.IsNullOrEmpty(filter))
            {
                filter = "";
            }

            return(Json(new DrugService().GetDrugReceiptDetails(facility, category, null, null, filter)));
        }
Пример #26
0
        // Token: 0x06000055 RID: 85 RVA: 0x000058A0 File Offset: 0x00003AA0
        public static List <ThingDef> MaladyDrugs()
        {
            List <RecipeDef> recipelist = DefDatabase <RecipeDef> .AllDefsListForReading;

            if (Current.ProgramState != ProgramState.Playing && DRSettings.ShowResearched)
            {
                Messages.Message(Translator.Translate("MSPainless.Warning"), LookTargets.Invalid, MessageTypeDefOf.CautionInput, false);
            }
            List <ThingDef> list    = new List <ThingDef>();
            List <ThingDef> chkList = DefDatabase <ThingDef> .AllDefsListForReading;

            if (chkList.Count > 0)
            {
                foreach (ThingDef chkDef in chkList)
                {
                    if (chkDef.IsIngestible && chkDef != null)
                    {
                        IngestibleProperties ingestible    = chkDef.ingestible;
                        DrugCategory?        drugCategory  = (ingestible != null) ? new DrugCategory?(ingestible.drugCategory) : null;
                        DrugCategory         drugCategory2 = DrugCategory.Medical;
                        if (drugCategory.GetValueOrDefault() == drugCategory2 & drugCategory != null)
                        {
                            if (DRSettings.ShowResearched)
                            {
                                if (MSPainDrug.IsResearchCompleted(chkDef, recipelist))
                                {
                                    GenCollection.AddDistinct <ThingDef>(list, chkDef);
                                }
                            }
                            else
                            {
                                GenCollection.AddDistinct <ThingDef>(list, chkDef);
                            }
                        }
                    }
                }
            }
            return((from td in list
                    orderby td.label
                    select td).ToList <ThingDef>());
        }
Пример #27
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         //Verify
         if (string.IsNullOrEmpty(this.txtCode.Text.Trim()))
         {
             throw new ApplicationException("编码不能为空");
         }
         if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
         {
             throw new ApplicationException("名称不能为空");
         }
         //save
         ModelService modelService = new ModelService();
         if (this.Model == null)//新建
         {
             DrugCategory model = new DrugCategory();
             model.Code    = this.txtCode.Text.Trim();
             model.Name    = this.txtName.Text.Trim();
             model.Actived = this.ckbActived.Checked;
             model.Remark  = this.txtRemark.Text.Trim();
             modelService.CreateDrugCategory(model, PermissionService.GetCurrentUser().Name);
         }
         else//修改
         {
             this.Model.Code    = this.txtCode.Text.Trim();
             this.Model.Name    = this.txtName.Text.Trim();
             this.Model.Actived = this.ckbActived.Checked;
             this.Model.Remark  = this.txtRemark.Text.Trim();
             modelService.SaveDrugCategory(this.Model, PermissionService.GetCurrentUser().Name);
         }
         //close diaglog
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         ErrorHandler.OnError(ex);
     }
 }
Пример #28
0
        public static List <DrugCategory> GetAll()
        {
            List <DrugCategory> lstStore = new List <DrugCategory>();

            object[] value      = null;
            var      connection = new SQLCommand(ConstValue.ConnectionString);
            var      result     = connection.Select("DrugCategory_Getall", value);

            if (connection.errorCode == 0 && result.Rows.Count > 0)
            {
                foreach (DataRow dr in result.Rows)
                {
                    DrugCategory store = new DrugCategory()
                    {
                        categoryId   = int.Parse(dr["categoryId"].ToString()),
                        categoryName = dr["categoryName"].ToString(),
                    };
                    lstStore.Add(store);
                }
            }
            return(lstStore);
        }
Пример #29
0
        public List <DrugCategory> SelectAllDrugCategory(IDbConnection conn)
        {
            string              sql          = @"select ID,DrugCategoryCode,DrugCategoryName,Actived,Remark from MD_DrugCategory";
            SqlDataReader       reader       = DataAccessUtil.ExecuteReader(sql, new List <SqlParameter>(), (SqlConnection)conn);
            List <DrugCategory> categoryList = new List <DrugCategory>();

            while (reader.Read())
            {
                DrugCategory category = new DrugCategory();
                category.ID      = reader.GetInt32(0);
                category.Code    = reader.GetString(1);
                category.Name    = reader.GetString(2);
                category.Actived = reader.GetBoolean(3);
                if (!reader.IsDBNull(4))
                {
                    category.Remark = reader.GetString(4);
                }
                categoryList.Add(category);
            }
            reader.Close();
            return(categoryList);
        }
Пример #30
0
    public static void AddNewDrugToPolicy(DrugPolicy dp, ThingDef newdrug, DrugCategory DC)
    {
        var drugPolicyEntry = new DrugPolicyEntry
        {
            drug = newdrug, allowedForAddiction = false, allowedForJoy = false, allowScheduled = false
        };

        if (dp.label == "SocialDrugs".Translate())
        {
            if (DC == DrugCategory.Social)
            {
                drugPolicyEntry.allowedForJoy = true;
            }
        }
        else if (dp.label == "Unrestricted".Translate())
        {
            if (newdrug.IsPleasureDrug)
            {
                drugPolicyEntry.allowedForJoy = true;
            }
        }
        else if (dp.label == "OneDrinkPerDay".Translate() &&
                 (DrugPolicyUtility.IsAlcohol(newdrug) || DrugPolicyUtility.IsSmokey(newdrug)) &&
                 newdrug.IsPleasureDrug)
        {
            drugPolicyEntry.allowedForJoy = true;
        }

        if (DrugPolicyUtility.IsAddictive(newdrug))
        {
            drugPolicyEntry.allowedForAddiction = true;
        }

        var list = NonPublicFields.DrugPolicyEntryList(dp);

        list.AddDistinct(drugPolicyEntry);
        NonPublicFields.DrugPolicyEntryList(dp) = list;
    }