Example #1
0
        /// <summary>
        /// Updates a given DrugInfo, uses drug guid as comparator
        /// </summary>
        /// <param name="drugInfo">DrugInfo to update</param>
        public static void UpdateDrugInfo(DrugInfo drugInfo)
        {
            //creates and opens the connection
            using var connection = new SQLiteConnection(_connectionInfo);
            connection.Open();

            //create a command, set the text and set all parameters to given DrugInfo
            var command = connection.CreateCommand();

            command.CommandText = @"UPDATE tblDrugInfo
                                       SET NumberLeft = $numberLeft,
                                           DiscordWebHook = $webHook,
                                           DiscordWebHookEnabled = $webHookEnabled,
                                           NotificationsEnabled = $notifications
                                     WHERE Guid LIKE $guid";

            command.Parameters.AddWithValue("$numberLeft", drugInfo.NumberLeft);
            command.Parameters.AddWithValue("$webHook", drugInfo.DrugSettings.DiscordWebHook);
            command.Parameters.AddWithValue("$webHookEnabled", drugInfo.DrugSettings.DiscordWebHookEnabled);
            command.Parameters.AddWithValue("$notifications", drugInfo.DrugSettings.NotificationsEnabled);
            command.Parameters.AddWithValue("$guid", drugInfo.Guid);

            //write to database
            command.ExecuteNonQuery();
        }
Example #2
0
        /// <summary>
        /// Add a given DrugInfo to the database
        /// </summary>
        /// <param name="info">DrugInfo to add</param>
        public static void AddDrugInfo(DrugInfo info)
        {
            //create and open the connection
            using var connection = new SQLiteConnection(_connectionInfo);
            connection.Open();

            //create a command, set the text and set all parameters to given DrugInfo
            var command = connection.CreateCommand();

            command.CommandText = @"INSERT INTO tblDrugInfo
                                    VALUES($guid, $drugName, $info, $user, $timeBetweenDose, $expectedDoses, $numberLeft, $discordWebHook, $discordWebHookEnabled, $notificationsEnabled)";

            command.Parameters.AddWithValue("$guid", info.Guid);
            command.Parameters.AddWithValue("$drugName", info.Name);
            command.Parameters.AddWithValue("$info", info.Info);
            command.Parameters.AddWithValue("user", info.User);
            command.Parameters.AddWithValue("$timeBetweenDose", info.TimeBetweenDoses);
            command.Parameters.AddWithValue("$expectedDoses", info.ExpectedDoses);
            command.Parameters.AddWithValue("$numberLeft", info.NumberLeft);
            command.Parameters.AddWithValue("$discordWebHook", info.DrugSettings.DiscordWebHook);
            command.Parameters.AddWithValue("$discordWebHookEnabled", info.DrugSettings.DiscordWebHookEnabled);
            command.Parameters.AddWithValue("$notificationsEnabled", info.DrugSettings.NotificationsEnabled);

            //add all associated dosages
            foreach (DosageInfo dosageInfo in info.Dosages)
            {
                AddDosageInfo(dosageInfo);
            }

            //write to database
            command.ExecuteNonQuery();
        }
Example #3
0
        /// <summary>
        /// Removes a given drug info from the database, along with all associated entries and dosages
        /// </summary>
        /// <param name="drugInfo">DrugInfo to remove</param>
        public static void RemoveDrugInfo(DrugInfo drugInfo)
        {
            //creates and opens the connection
            using var connection = new SQLiteConnection(_connectionInfo);
            connection.Open();

            //create a command, set the text and set all parameters to given DrugInfo
            var command = connection.CreateCommand();

            command.CommandText = @"DELETE FROM tblDrugInfo
                                    WHERE Guid LIKE $guid";

            command.Parameters.AddWithValue("$guid", drugInfo.Guid);

            //write to database
            command.ExecuteNonQuery();

            //then remove all drug entries with same name
            command.CommandText = @"DELETE FROM tblDrugEntries
                                    WHERE DrugGuid LIKE $guid";

            command.Parameters.AddWithValue("$guid", drugInfo.Guid);
            command.ExecuteNonQuery();

            //then remove all dosage info with same name
            command.CommandText = @"DELETE FROM tblDosageInfo
                                    WHERE Guid LIKE $guid";

            command.Parameters.AddWithValue("$guid", drugInfo.Guid);
            command.ExecuteNonQuery();
        }
        //填写样品固定的信息, headBorder:报表的外框
        private void FillDocumentFixedInfo(DrugInfo data, Border headBorder)
        {
            //填写样品检测信息
            Run typerun = headBorder.FindName("IDUnit") as Run;     //单位

            typerun.Text = SettingData.settingData.runing_para.unitName;

            FillTextData(headBorder, "txtsampleNumber", data.sampleNumber);                                    //检测时间
            FillTextData(headBorder, "txtidentTime", data.identTime.ToString(SettingData.LongDateTimeString)); //检测地点
            FillTextData(headBorder, "txtidentModel", data.identModel);                                        //取样日期
            FillTextData(headBorder, "txtscanType", data.scanType);                                            //取样地点
            FillTextData(headBorder, "txtidentThresold", data.identThresold.ToString());                       //数据文件名
            FillTextData(headBorder, "txtidentValue", data.identValue.ToString());                             //操作员
            FillTextData(headBorder, "txtfilename", data.filename);                                            //操作员

            //填写样品药品信息
            FillTextData(headBorder, "txtlicenseCode", data.licenseCode);                                           //备注
            FillTextData(headBorder, "txtproductUnit", data.productUnit);                                           //名称
            FillTextData(headBorder, "txtchemicalName", data.chemicalName);                                         //厂家
            FillTextData(headBorder, "txtcommercialName", data.commercialName);                                     //厂家
            FillTextData(headBorder, "txtform", data.form);                                                         //厂家
            FillTextData(headBorder, "txtspecification", data.specification);                                       //厂家
            FillTextData(headBorder, "txtbatchNumber", data.batchNumber);                                           //厂家
            FillTextData(headBorder, "txtproductTime", data.productTime.ToString(SettingData.ShortDateTimeString)); //厂家
            FillTextData(headBorder, "txtvalidMonth", data.validMonth + "月");                                       //厂家
            //还需要输入剂型

            FillTextData(headBorder, "txtmemo", data.memo);                             //剂型
            FillTextData(headBorder, "txtidentOperator", data.identOperator);           //文号
        }
Example #5
0
        protected void prefillButton_Click(object sender, EventArgs e)
        {
            int parseResult;

            if (!Int32.TryParse(PZNBox.Text, out parseResult))
            {
                return;
            }

            try
            {
                DrugInfo drugInfo = DrugInfoService.GetInfo(Int32.Parse(PZNBox.Text));
                NameBox.Text        = drugInfo.Name;
                DescriptionBox.Text = drugInfo.Description;
                // to make sure errors are not shown by accident
                Validate();
                ResultLabel.Text     = "Prefilled data for drug.";
                ResultLabel.CssClass = "success";
            }
            catch (ArgumentException ex)
            {
                ResultLabel.Text     = ex.Message;
                ResultLabel.CssClass = "error";
            }
        }
        public async Task <IActionResult> PutDrugInfo([FromRoute] int id, [FromBody] DrugInfo drugInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != drugInfo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(drugInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DrugInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #7
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     btnSearch.Visible = false;
     btnAdd.Visible    = false;
     btnDelete.Visible = false;
     btnModify.Visible = false;
     try
     {
         _TYPE = OperateType.Add;
         SetEditMode(true);
         InitialEditTab();
         entity = new DrugInfo();
         this.ucGoodsInfo1.RunMode                               = Pharmacy.UI.Common.FormRunMode.Add;
         this.ucGoodsInfo1.DrugInfo                              = entity;
         this.ucGoodsInfo1.GoodsAdditional                       = new GoodsAdditionalProperty();
         this.ucGoodsInfo1.GoodsAdditional.Id                    = entity.Id;
         this.ucGoodsInfo1.GoodsAdditional.DrugInfoId            = entity.Id;
         this.ucGoodsInfo1.GoodsAdditional.PutOnRecordDate       = DateTime.Now;
         this.ucGoodsInfo1.GoodsAdditional.LicensePermissionDate = DateTime.Now;
         this.ucGoodsInfo1.getDrugInfoCount();
         this.ucGoodsInfo1.setEnableState();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Log.Error(ex);
     }
 }
Example #8
0
        //end


        /// <summary>
        ///  新增一条药品和审批流程记录
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns
        public void AddDrugInfoApproveFlow(DrugInfo su, Guid approvalFlowTypeID, Guid userID, string changeNote)
        {
            try
            {
                //增加药品记录
                this.Add(su);
                if (su.GoodsType != GoodsType.DrugDomestic && su.GoodsType != GoodsType.DrugImport)
                {
                    if (su.GoodsAdditionalProperty != null)
                    {
                        RepositoryProvider.Db.GoodsAdditionalPropertys.Add(su.GoodsAdditionalProperty);
                    }
                }
                if (approvalFlowTypeID != Guid.Empty)
                {
                    //增加审批流程
                    ApprovalFlow af = BusinessHandlerFactory.ApprovalFlowBusinessHandler.GetApproveFlowInstance(approvalFlowTypeID, su.FlowID, userID, changeNote);
                    BusinessHandlerFactory.ApprovalFlowBusinessHandler.Add(af);

                    //增加审批流程记录
                    ApprovalFlowRecord afr = BusinessHandlerFactory.ApprovalFlowRecordBusinessHandler.GetApproveFlowRecordInstance(af, userID, changeNote);
                    BusinessHandlerFactory.ApprovalFlowRecordBusinessHandler.Add(afr);
                }

                this.Save();
            }
            catch (Exception ex)
            {
                this.HandleException("新增一条药品和审批流程记录失败", ex);
            }
        }
        public DrugInfo GetDrugInfo(string drugCode, string drugStoreCode, int drugUnit)
        {
            var drugInfo = new DrugInfo();
            IBaseRepository <Thuoc> drugRepo = null;
            var drugs = _dataFilterService.GetValidDrugs(drugStoreCode, null, false, out drugRepo);
            var drug  = drugs.Where(d => d.MaThuoc == drugCode).FirstOrDefault();

            if (drug == null)
            {
                throw new ValidationException("drugManagement.validation.itemNotExist");
            }

            if (drug.DonViXuatLe_MaDonViTinh == drugUnit)
            {
                drugInfo.InPrice   = drug.GiaNhap;
                drugInfo.OutPrice  = drug.GiaBanLe;
                drugInfo.OutPriceB = drug.GiaBanBuon;
                drugInfo.UnitCode  = drugUnit;
                //drugInfo.UnitName = drug.DonViTinh1.TenDonViTinh;
            }
            else
            {
                drugInfo.InPrice   = drug.GiaNhap * drug.HeSo;
                drugInfo.OutPrice  = drug.GiaBanLe * drug.HeSo;
                drugInfo.OutPriceB = drug.GiaBanBuon * drug.HeSo;
                drugInfo.UnitCode  = drugUnit;
                //drugInfo.UnitName = drug.DonViTinh.TenDonViTinh;
            }

            return(drugInfo);
        }
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new OpenFileDialog <FileFormat.FileOpenDlg>();

            dlg.Filter                 = "样品光谱|*.spc";
            dlg.Multiselect            = true;
            dlg.Title                  = "Open File";
            dlg.FileDlgStartLocation   = AddonWindowLocation.Right;
            dlg.FileDlgDefaultViewMode = NativeMethods.FolderViewMode.Tiles;
            dlg.FileDlgOkCaption       = "&Open";
            dlg.FileDlgEnableOkBtn     = true;
            dlg.SetPlaces(new object[] { (int)Places.History, (int)Places.MyComputer, (int)Places.Desktop,
                                         (int)Places.MyDocuments, (int)Places.Favorites });

            if ((bool)dlg.ShowDialog() == true)
            {
                foreach (string file in dlg.FileNames)
                {
                    DrugInfo newDrug = Common.CommonMethod.ReadDrugInfo(file);
                    if (newDrug == null)
                    {
                        newDrug          = new DrugInfo();
                        newDrug.filename = file;
                        newDrug.fileData = new SpecFileFormatDouble();
                        newDrug.fileData.ReadFile(newDrug.filename);
                        newDrug.identResult = EnumIdentResult.UNKNOWN;
                    }

                    dataList.Add(newDrug);
                }
            }
        }
Example #11
0
        public FormDrugInfo(OperateType operateType, DrugInfo di) : this()
        {
            _TYPE = operateType;

            this.Text   = UpdateFormTitle(_TYPE);
            this.entity = di;
            EditItem("");
            switch (_TYPE)
            {
            case OperateType.Add:
                btnSearch.Visible = false;
                btnModify.Visible = false;
                btnAdd.Visible    = false;
                btnDelete.Visible = false;
                btnSave.Enabled   = true;
                btnCancel.Enabled = true;
                break;

            case OperateType.Browse:
                btnSearch.Visible = true;
                btnAdd.Visible    = true;
                btnModify.Enabled = true;
                btnSave.Enabled   = true;
                btnCancel.Enabled = true;
                break;
            }
        }
Example #12
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                _TYPE = OperateType.Delete;
                if (MessageBox.Show("确定要删除吗?", "信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (dataGridView1.CurrentRow != null)
                    {
                        //执行删除操作
                        int currRowIndex = dataGridView1.CurrentRow.Cells[0].RowIndex;
                        entity = _listDrugInfo[currRowIndex];

                        string msg = string.Empty;
                        PharmacyDatabaseService.DeleteDrugInfo(out msg, entity.Id);
                        SetEditMode(false);

                        btnRefresh_Click(this, null);
                    }
                    else
                    {
                        MessageBox.Show("没有选择要删除的记录!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Error(ex);
            }
        }
Example #13
0
        /// <summary>
        /// Returns all DosageInfos associated with a given DrugInfo from the database
        /// </summary>
        /// <param name="drugInfo">DrugInfo to find associated DosageInfos for</param>
        /// <returns>A list of DosageInfos</returns>
        private static List <DosageInfo> GetDosageInfos(DrugInfo drugInfo)
        {
            //creates and opens the connection
            using var connection = new SQLiteConnection(_connectionInfo);
            connection.Open();

            //create a command, set the text and set all parameters to given DrugInfo
            var command = connection.CreateCommand();

            command.CommandText = @"SELECT * FROM tblDosageInfo
                                    WHERE Guid = $guid";

            command.Parameters.AddWithValue("$guid", drugInfo.Guid);

            var reader = command.ExecuteReader();

            //read a list of DateTimes from the table
            List <DosageInfo> dosages = new List <DosageInfo>();

            while (reader.Read())
            {
                dosages.Add(new DosageInfo()
                {
                    Guid   = drugInfo.Guid,
                    Drug   = (string)reader["Drug"],
                    Dosage = new Dosage(Convert.ToInt32(reader["Dosage"])).Micrograms
                });
            }

            return(dosages);
        }
Example #14
0
        //根据内容来选择, 药品名 - 厂家 - 包装
        public bool SelectNode(DrugInfo infoToFind)
        {
            MethodTreeNode chemicalInfo = rootItem.Children.Find(item => item.Name == infoToFind.chemicalName);

            if (chemicalInfo == null)
            {
                return(false);
            }

            MethodTreeNode productInfo = chemicalInfo.Children.Find(item => item.Name == infoToFind.productUnit);

            if (productInfo == null)
            {
                return(false);
            }

            MethodTreeNode packInfo = productInfo.Children.Find(item => item.Name == infoToFind.package);

            if (packInfo == null)
            {
                return(false);
            }

            if (packInfo.Method != infoToFind.ramanMethod)
            {
                return(false);
            }

            packInfo.IsExpanded = true;
            packInfo.IsSelected = true;

            return(true);
        }
Example #15
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            try
            {
                _TYPE = OperateType.Edit;
                if (dataGridView1.CurrentRow != null)
                {
                    int curRowIndex = dataGridView1.CurrentRow.Index;
                    entity = _listDrugInfo[curRowIndex];
                    InitialEditTab();

                    SetEditMode(true);
                    //编辑操作
                }
                else
                {
                    MessageBox.Show("没有选择要修改的记录!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.Error(ex);
            }
        }
        /// <summary>
        ///  光谱分析回调函数,在ProcessWaitDialog中调用
        /// </summary>
        /// <param name="callBack"></param>
        /// <returns></returns>
        public bool ProcessTask(ProcessWaitDialog.SetProcessAndMsgDeletage callBack)
        {
            foreach (spectrumDisplayInfo item in reIdentifyItems)
            {
                DrugInfo drug = item as DrugInfo;

                double cc = Common.DrugAnalyte.CorCoeffAnalyte(curModel, drug.filename);
                if (cc > 0)
                {
                    drug.identModel  = curModel.licenseCode;
                    drug.identValue  = cc;
                    drug.identResult = cc >= curModel.thresold ? EnumIdentResult.OK : EnumIdentResult.FAULT;
                    drug.identTime   = DateTime.Now;

                    Common.CommonMethod.WriteDrugInfo(drug);
                }
                else
                {
                    ErrorString = Common.DrugAnalyte.ErrorString;
                    return(false);
                }

                bool abortTask = false;
                callBack("正在分析:" + drug.filename, reIdentifyItems.Count, reIdentifyItems.IndexOf(item), out abortTask);
            }
            return(true);
        }
Example #17
0
 public FormGoodsInfoView(DrugInfo drugInfo)
 {
     InitializeComponent();
     if (!DesignMode)
     {
         DrugInfo = drugInfo;
     }
 }
Example #18
0
        public SpecFileIdentify(DrugInfo sampleData)
        {
            InitializeComponent();

            IdentSampleList = new List <DrugInfo>();
            IdentSampleList.Add(sampleData);
            AddToList();
        }
        public IEnumerable <DrugEntry> Get(string name, int count)
        {
            //create a druginfo with the given id
            DrugInfo info = Database.GetDrugInfo().First(x => x.Name == name);

            //return the drug entries with that id
            return(Database.GetDrugEntries(info, count));
        }
Example #20
0
        /// <summary>
        /// 显示要点提示信息
        /// </summary>
        /// <param name="codeMm">药品编码</param>
        /// <param name="nameMm">药品名称</param>
        public override void ShowDrugInstruction(string codeMm, string nameMm)
        {
            DrugInfo drug = new DrugInfo();

            drug.License_number = codeMm;
            drug.General_name   = nameMm;

            string msg = drugMonitor.HintMainPoints(drug);
        }
 /// <summary>
 /// 根据审核流程ID打开审核详细
 /// </summary>
 public FormApprovalFlowCenter(object druginfo, Guid flowID, bool isVisible) : this()
 {
     FlowID = flowID;
     this.label24.Visible           = isVisible;
     this.txtOperatorReason.Visible = isVisible;
     this.btnReject.Visible         = isVisible;
     this.btnAccept.Visible         = isVisible;
     this.druginfo = druginfo as DrugInfo;
 }
Example #22
0
        /// <summary>
        /// 获取要点提示信息
        /// </summary>
        /// <returns></returns>
        private string GetMainPoints(OrdSrvMmDO ordSrvMm)
        {
            DrugInfo drug = new DrugInfo();

            drug.General_name   = ordSrvMm.Name_mm; // 药品名称
            drug.License_number = ordSrvMm.Code_mm; // 药品编码

            string mainPoints = drugMonitor.HintMainPoints(drug);

            return(mainPoints);
        }
Example #23
0
        public double GetDrugRetailFactors(DrugInfo drug, int?drugUnitIdOnNote)
        {
            var factors = 1.0;

            if (drugUnitIdOnNote.HasValue && drug.UnitId.HasValue && drugUnitIdOnNote.Value == drug.UnitId.Value)
            {
                factors = drug.Factors;
            }

            return(factors);
        }
        public IEnumerable <DrugEntry> Get(string guid)
        {
            //create a druginfo with the given id
            DrugInfo info = new DrugInfo()
            {
                Guid = guid
            };

            //return the drug entries with that id
            return(Database.GetDrugEntries(info));
        }
        public async void Post([FromBody] DrugInfo info)
        {
            //generate GUID
            info.Guid = Guid.NewGuid().ToString();

            //add the druginfo from the post request to the database
            Database.AddDrugInfo(info);

            //send new info to all clients
            await _hubContext.Clients.All.SendAsync("AddDrugInfo", info);
        }
Example #26
0
        /// <summary>
        /// Removes a given DrugEntry from database, and updates all clients
        /// </summary>
        /// <param name="entry">DrugEntry to remove</param>
        /// <param name="amount">Amount of doses left</param>
        /// <returns></returns>
        public async Task RemoveDrugEntry(DrugEntry entry, decimal amount)
        {
            Database.RemoveDrugEntry(entry);
            Database.UpdateNumberLeft(entry.DrugGuid, amount);

            DrugInfo relevantInfo = Database.GetDrugInfo(entry.DrugGuid)[0];

            relevantInfo.ReCalculateStats();

            await Clients.All.SendAsync("RemoveDrugEntry", entry, relevantInfo.Stats);
        }
        public async Task <IActionResult> PostDrugInfo([FromBody] DrugInfo drugInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.DrugInfos.Add(drugInfo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDrugInfo", new { id = drugInfo.Id }, drugInfo));
        }
Example #28
0
        /// <summary>
        /// Updates a given DrugEntry
        /// </summary>
        /// <param name="entry">Entry to update</param>
        /// <param name="change">Change in number remaining</param>
        /// <returns></returns>
        public async Task UpdateDrugEntry(DrugEntry entry, decimal change)
        {
            Database.UpdateDrugEntry(entry);

            DrugInfo relevantInfo = Database.GetDrugInfo(entry.DrugGuid)[0];

            relevantInfo.ReCalculateStats();

            Database.UpdateNumberLeft(entry.DrugGuid, relevantInfo.NumberLeft + change);

            await Clients.All.SendAsync("UpdateDrugEntry", entry, relevantInfo.Stats, relevantInfo.NumberLeft + change);
        }
        private void dataGridViewAdd(Dictionary <Guid, DrugInfo> listDrugInfo)
        {
            try
            {
                foreach (var unit in listDrugInfo)
                {
                    bool exist = false;
                    foreach (DataGridViewRow r in this.dataGridView1.Rows)
                    {
                        if (r.Cells["clmDrugId"].Value.ToString().Contains(unit.Value.Id.ToString()))
                        {
                            exist = true;
                            break;
                        }
                    }
                    if (!exist)
                    {
                        string   msg = string.Empty;
                        decimal  currentInventoryCount = 0;
                        Guid     drugId = Guid.Parse(unit.Value.Id.ToString());
                        DrugInfo drg    = this.PharmacyDatabaseService.GetDrugInfo(out msg, drugId);
                        DrugInventoryRecord[] drgInv = this.PharmacyDatabaseService.AllDrugInventoryRecords(out msg);
                        for (int i = 0; i < drgInv.Length; i++)
                        {
                            if (drgInv[i].DrugInfoId == drugId)
                            {
                                currentInventoryCount = drgInv[i].CurrentInventoryCount;
                            }
                        }

                        int index = this.dataGridView1.Rows.Add();
                        this.dataGridView1.Rows[index].Cells["clmDrugId"].Value                     = unit.Value.Id.ToString();
                        this.dataGridView1.Rows[index].Cells["clmDrugName"].Value                   = unit.Value.ProductGeneralName;
                        this.dataGridView1.Rows[index].Cells["clmDrugNumber"].Value                 = 0;
                        this.dataGridView1.Rows[index].Cells["clmSupplyUnitId"].Value               = string.Empty;
                        this.dataGridView1.Rows[index].Cells["clmSupplyName"].Value                 = string.Empty;
                        this.dataGridView1.Rows[index].Cells["clmPurchasePrice"].Value              = unit.Value.PurchasePrice;
                        this.dataGridView1.Rows[index].Cells["clmActualPrice"].Value                = unit.Value.PurchasePrice;
                        this.dataGridView1.Rows[index].Cells["AmountOfTax"].Value                   = "17";
                        this.dataGridView1.Rows[index].Cells["DictionarySpecificationCode"].Value   = unit.Value.DictionarySpecificationCode;
                        this.dataGridView1.Rows[index].Cells["DictionaryMeasurementUnitCode"].Value = unit.Value.DictionaryMeasurementUnitCode;
                        this.dataGridView1.Rows[index].Cells["FactoryName"].Value                   = unit.Value.FactoryName;
                        this.dataGridView1.Rows[index].Cells["DictionaryDosageCode"].Value          = unit.Value.DictionaryDosageCode;
                        this.dataGridView1.Rows[index].Cells["LicensePermissionNumber"].Value       = unit.Value.LicensePermissionNumber;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK);
                Log.Error(ex);
            }
        }
Example #30
0
        /// <summary>
        /// Gets a list of all DrugInfos stored within the database
        /// </summary>
        /// <returns>A list of DrugInfo</returns>
        public static List <DrugInfo> GetDrugInfo(string guid = null)
        {
            //create and open the connection
            using var connection = new SQLiteConnection(_connectionInfo);
            connection.Open();

            //create the command, set the text and create a reader from that command
            var command = connection.CreateCommand();

            command.CommandText = @"SELECT * FROM tblDrugInfo";

            if (guid is not null)
            {
                command.CommandText += "\nWHERE Guid = $guid";
                command.Parameters.AddWithValue("$guid", guid);
            }

            var reader = command.ExecuteReader();

            //read a list of DrugInfos from the table
            List <DrugInfo> info = new List <DrugInfo>();

            while (reader.Read())
            {
                var drug = new DrugInfo
                {
                    Guid             = (string)reader["Guid"],
                    Name             = (string)reader["DrugName"],
                    User             = (string)reader["User"],
                    Info             = reader["Info"].HandleNull <string>(),
                    TimeBetweenDoses = reader["TimeBetweenDoses"].HandleNull <decimal?>(),
                    ExpectedDoses    = reader["ExpectedDoses"].HandleNull <int?>(),
                    NumberLeft       = reader["NumberLeft"].HandleNull <decimal>(),
                    DrugSettings     =
                    {
                        NotificationsEnabled  = reader["NotificationsEnabled"].HandleNull <bool>(),
                        DiscordWebHook        = reader["DiscordWebHook"].HandleNull <string>(),
                        DiscordWebHookEnabled = reader["DiscordWebHookEnabled"].HandleNull <bool>()
                    }
                };


                //find all DrugEntries associated with the DrugInfo
                drug.Entries = GetDrugEntries(drug);
                drug.Dosages = GetDosageInfos(drug);

                info.Add(drug);
            }

            return(info);
        }
Example #31
0
    public int delete_DrugInfo(DrugInfo DInfo,string userID)
    {
        SqlConnection sqlCon = new SqlConnection(ConStr);
        int flag = 0;
        try
        {
            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection = sqlCon;
            int drugCount=0;
            if(DInfo.DrugID != null)
                sqlCmd.CommandText = "select COUNT(*) from Drug_Inventory where Drug_ID=" + DInfo.DrugID.ToString();
            sqlCon.Open();
            drugCount=sqlCmd.ExecuteNonQuery();
            sqlCon.Close();
            if (drugCount !=-1)
            {
                flag = 0;
            }
            else
            {
                sqlCmd.CommandText = "sp_delete_DrugInfo";
                sqlCmd.CommandType = CommandType.StoredProcedure;
                SqlParameter dID = sqlCmd.Parameters.Add("@DID", SqlDbType.Int);
                if (DInfo.DrugID != null)
                    dID.Value = DInfo.DrugID;
                else
                    dID.Value = Convert.DBNull;

                SqlParameter pUserID = sqlCmd.Parameters.Add("@UserID", SqlDbType.VarChar, 20);
                pUserID.Value = userID;

                sqlCon.Open();
                sqlCmd.ExecuteNonQuery();
                flag = 1;
            }

        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);

        }
        finally
        {
            sqlCon.Close();
        }
        return flag;
    }
Example #32
0
    public string update_DrugInfo(DrugInfo DInfo, string userID)
    {
        try
        {
            SqlConnection con = new SqlConnection(ConStr);
            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection = con;
            sqlCmd.CommandText = "sp_update_DrugInfo";
            sqlCmd.CommandType = CommandType.StoredProcedure;
            SqlParameter dID = sqlCmd.Parameters.Add("@DID", SqlDbType.Int);
            if (DInfo.DrugID != null)
                dID.Value = DInfo.DrugID;
            else
                dID.Value = Convert.DBNull;

            SqlParameter dCindex = sqlCmd.Parameters.Add("@DCostIndex", SqlDbType.Char);
            if (DInfo.DCostIndex != null)
                dCindex.Value = DInfo.DCostIndex;
            else
                dCindex.Value = Convert.DBNull;

            int DTID = getDrugTypeID(DInfo);
            if (DTID != null)
                DInfo.DrugTypeID = DTID;

            SqlParameter dTypeID = sqlCmd.Parameters.Add("@DType_ID", SqlDbType.Int);
            if (DInfo.DrugTypeID != null)
                dTypeID.Value = DInfo.DrugTypeID;
            else
                dTypeID.Value = Convert.DBNull;

            SqlParameter pUserID = sqlCmd.Parameters.Add("@UserID", SqlDbType.VarChar, 20);
            pUserID.Value = userID;

            con.Open();
            sqlCmd.ExecuteNonQuery();
            con.Close();
        }

        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
            return ex.Message;
        }
        return "Drug Information Updated Successfully...";
    }
Example #33
0
    public int Ins_DrugTypeInfo(DrugInfo DInfo,string user)
    {
        int flag = 0;
        try
        {
            SqlConnection con = new SqlConnection(ConStr);
            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection = con;
            sqlCmd.CommandText = "sp_set_DType";
            sqlCmd.CommandType = CommandType.StoredProcedure;
            SqlParameter dType = sqlCmd.Parameters.Add("@DrugType", SqlDbType.VarChar, 50);
            dType.Value = DInfo.DrugType;

            SqlParameter userID = sqlCmd.Parameters.Add("@UserID", SqlDbType.VarChar,20);
            userID.Value = user;

            con.Open();
            sqlCmd.ExecuteNonQuery();
            flag = 1;
            con.Close();
        }

        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);

        }

        return flag;
    }
Example #34
0
    public int getDrugTypeID(DrugInfo dInfo)
    {
        int dID = 0;
        SqlConnection con = new SqlConnection(ConStr);
        try
        {
            SqlCommand sqlCmd = new SqlCommand("select DrugType_ID from DrugType_Info where DrugType = '" + dInfo.DrugType + "'", con);

            con.Open();
            dID = Convert.ToInt32(sqlCmd.ExecuteScalar());
        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
        }
        con.Close();

        return dID;
    }
Example #35
0
    public string getDrugType(DrugInfo dInfo)
    {
        string DrugType;
        SqlConnection con = new SqlConnection(ConStr);
        SqlCommand sqlCmd = new SqlCommand("select DrugType from DrugType_Info where DrugType_ID = '" + dInfo.DrugTypeID + "'", con);

        con.Open();
        try
        {
            DrugType = sqlCmd.ExecuteScalar().ToString();
            con.Close();
            return DrugType;
        }
        catch (Exception ex)
        {
            objNLog.Error("Exception : " + ex.Message);
            return ex.Message;
        }
    }
Example #36
0
 public DataTable getDrugSearch(DrugInfo DInfo)
 {
     SqlConnection con = new SqlConnection(ConStr);
     SqlCommand sqlCmd = new SqlCommand("select * from Drug_Info where Drug_Name = '" + DInfo.DrugName + "'", con);
     SqlDataReader sqlDr;
     DataTable dtable = new DataTable();
     // DataRow dr;
     con.Open();
     try
     {
         sqlDr = sqlCmd.ExecuteReader();
         dtable.Load(sqlDr);
         con.Close();
     }
     catch (Exception ex)
     {
         objNLog.Error("Exception : " + ex.Message);
     }
     return dtable;
 }