コード例 #1
0
 private Model.Drug getDrug()
 {
     Model.Drug drug = new Model.Drug(int.Parse(lblDrugId.Content.ToString()), tbDrugName.Text,
                                      tbDrugDescription.Text, int.Parse(tbDrugQuantity.Text), double.Parse(tbDrugWeight.Text),
                                      tbDrugComponents.Text, Model.TypeOfApprovedDrug.Waiting, cbAlternativeDrug.SelectedItem.ToString(), "");
     return(drug);
 }
コード例 #2
0
ファイル: add_drugs..cs プロジェクト: zymITsky/Medical
        private void bt_save_Click_1(object sender, EventArgs e)
        {
            Model.Drug drug = new Model.Drug();
            string     msg  = "";

            for (int i = 0; i < this.dataGridView1.Rows.Count - 1; i++)
            {
                drug.Drug_ab    = dataGridView1.Rows[i].Cells["简码"].Value.ToString();
                drug.Drug_name  = dataGridView1.Rows[i].Cells["药物"].Value.ToString();
                drug.Effect     = dataGridView1.Rows[i].Cells["功效"].Value.ToString();
                drug.From_where = dataGridView1.Rows[i].Cells["产地"].Value.ToString();
                drug.In_price   = Double.Parse(dataGridView1.Rows[i].Cells["进价"].Value.ToString());
                drug.Notice     = dataGridView1.Rows[i].Cells["注意"].Value.ToString();
                drug.Stock      = Double.Parse(dataGridView1.Rows[i].Cells["数量"].Value.ToString());
                drug.Unit       = dataGridView1.Rows[i].Cells["单位"].Value.ToString();
                drug.Unit_price = Double.Parse(dataGridView1.Rows[i].Cells["单价"].Value.ToString());
                drug.Use_down   = Double.Parse(dataGridView1.Rows[i].Cells["上限"].Value.ToString());
                drug.Use_up     = Double.Parse(dataGridView1.Rows[i].Cells["下限"].Value.ToString());
                drug.Wei_jin    = dataGridView1.Rows[i].Cells["味经"].Value.ToString();
                if (!drugbll.AddDrug(drug, out msg))
                {
                    MessageBoxBuilder.buildErrbox("插入第" + i + "出错!" + msg);
                }
            }
            MessageBoxBuilder.buildbox("插入成功!", "ok");
        }
コード例 #3
0
 private Model.Drug CreateDrug()
 {
     Model.Drug drug = new Model.Drug(int.Parse(lbDrugId.Content.ToString()), lbDrugName.Content.ToString(),
                                      tbuDrugDescription.Text, int.Parse(tbuDrugQuantity.Text), double.Parse(tbuDrugWeight.Text),
                                      tbuDrugComponents.Text, Model.TypeOfApprovedDrug.Approved, cbAlternativeDrug.Text, "");
     return(drug);
 }
コード例 #4
0
        public List <Model.Drug> LoadDrug()
        {
            List <Model.Drug> drugs = new List <Model.Drug>();

            try
            {
                String       line;
                StreamReader sr = new StreamReader(FileLocation);

                while ((line = sr.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                    string[] words = line.Split(',');

                    Model.Drug drug = new Model.Drug(int.Parse(words[0]), words[1], words[2], int.Parse(words[3]),
                                                     double.Parse(words[4]), words[5], (Model.TypeOfApprovedDrug)Enum.Parse(typeof(Model.TypeOfApprovedDrug), words[6]), words[7], words[8]);

                    drugs.Add(drug);
                    next_id = drug.DrugId;
                }

                sr.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
            finally
            {
                Console.WriteLine("Executing finally block.");
            }

            return(drugs);
        }
コード例 #5
0
ファイル: add_drugs..cs プロジェクト: qq5013/Medical
 private void bt_save_Click_1(object sender, EventArgs e)
 {
     Model.Drug drug = new Model.Drug();
     string msg = "";
     for (int i = 0; i < this.dataGridView1.Rows.Count - 1; i++)
     {
         drug.Drug_ab = dataGridView1.Rows[i].Cells["简码"].Value.ToString();
         drug.Drug_name = dataGridView1.Rows[i].Cells["药物"].Value.ToString();
         drug.Effect = dataGridView1.Rows[i].Cells["功效"].Value.ToString();
         drug.From_where = dataGridView1.Rows[i].Cells["产地"].Value.ToString();
         drug.In_price = Double.Parse(dataGridView1.Rows[i].Cells["进价"].Value.ToString());
         drug.Notice = dataGridView1.Rows[i].Cells["注意"].Value.ToString();
         drug.Stock = Double.Parse(dataGridView1.Rows[i].Cells["数量"].Value.ToString());
         drug.Unit = dataGridView1.Rows[i].Cells["单位"].Value.ToString();
         drug.Unit_price = Double.Parse(dataGridView1.Rows[i].Cells["单价"].Value.ToString());
         drug.Use_down = Double.Parse(dataGridView1.Rows[i].Cells["上限"].Value.ToString());
         drug.Use_up = Double.Parse(dataGridView1.Rows[i].Cells["下限"].Value.ToString());
         drug.Wei_jin = dataGridView1.Rows[i].Cells["味经"].Value.ToString();
         if (!drugbll.AddDrug(drug, out msg))
         {
             MessageBoxBuilder.buildErrbox("插入第" + i + "出错!" + msg);
         }
     }
     MessageBoxBuilder.buildbox("插入成功!", "ok");
 }
コード例 #6
0
 private void Button_Click_OK(object sender, RoutedEventArgs e)
 {
     Model.Drug selectedDrug = (Model.Drug)drugListForVerify.lvDataBindingDrugs.SelectedItems[0];
     selectedDrug.DrugType = Model.TypeOfApprovedDrug.Approved;
     drugListForVerify.drugController.UpdateDrug(selectedDrug);
     drugListForVerify.LoadAllDrugs();
     MessageBox.Show("Uspešno ste potvrdili lek!", "Uspešno izvršeno!", MessageBoxButton.OK, MessageBoxImage.Information);
     this.Close();
 }
コード例 #7
0
 public void LoadComponents()
 {
     Model.Drug selectedDrug = (Model.Drug)drugListForVerify.lvDataBindingDrugs.SelectedItems[0];
     lblDrugId.Content          = selectedDrug.DrugId;
     lblDrugName.Content        = selectedDrug.DrugName;
     lblDrugDescription.Content = selectedDrug.DrugDescription;
     lblDrugComponents.Content  = selectedDrug.DrugComponents;
     lblDrugQuantity.Content    = selectedDrug.DrugQuantity;
     lblDrugWeight.Content      = selectedDrug.DrugWeight;
     lblDrugAlternative.Content = selectedDrug.AlternativeDrug;
 }
コード例 #8
0
 public void LoadAllComponents()
 {
     Model.Drug selected = (Model.Drug)drugListVerify.lvDataBindingDrugs.SelectedItems[0];
     lbDrugId.Content   = selected.DrugId;
     lbDrugName.Content = selected.DrugName;
     drugComponents     = selected.DrugComponents;
     drugDescription    = selected.DrugDescription;
     drugQuantity       = selected.DrugQuantity;
     drugWeight         = selected.DrugWeight;
     LoadAlternatives();
     cbAlternativeDrug.SelectedItem = selected.AlternativeDrug.ToString();
 }
コード例 #9
0
 public void LoadAllComponents()
 {
     Model.Drug selected = (Model.Drug)drugList.lvDataBinding.SelectedItems[0];
     lblDrugId.Content = selected.DrugId;
     drugName          = selected.DrugName;
     drugDescription   = selected.DrugDescription;
     drugQuantity      = selected.DrugQuantity;
     drugWeight        = selected.DrugWeight;
     DrugComponents    = selected.DrugComponents;
     tbComment.Text    = selected.DrugComment;
     LoadAlternatives();
     cbAlternativeDrug.SelectedItem = selected.AlternativeDrug;
 }
コード例 #10
0
ファイル: DrugBLL.cs プロジェクト: zymITsky/Medical
 public bool AddDrug(Model.Drug drug, out string msg)
 {
     try
     {
         iDrug.Add(drug);
     }
     catch (Exception exp)
     {
         msg = exp.Message;
         return(false);
     }
     msg = "成功";
     return(true);
 }
コード例 #11
0
ファイル: DrugDALImp.cs プロジェクト: XEgithub/Medical
        public bool Update(Model.Drug drug)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [drug] set");
            strSql.Append("(drug_ab=@drug_ab,drug_name=@drug_name,unit_price=@unit_price," +
                          "unit=@unit,in_price=@in_price ,stock=@stock,from_where=@from_where" +
                          ",wei_jin=@wei_jin ,notice=@notice ,effect=@effect,use_up=@use_up,use_down=@use_down");
            strSql.Append(" where drug_id =@drug_id  ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@drug_ab",    SqlDbType.VarChar, 10),
                new SqlParameter("@drug_name",  SqlDbType.VarChar, 16),
                new SqlParameter("@unit_price", SqlDbType.Decimal, 10),
                new SqlParameter("@unit",       SqlDbType.VarChar,  5),
                new SqlParameter("@in_price",   SqlDbType.Decimal, 10),
                new SqlParameter("@stock",      SqlDbType.Decimal, 10),
                new SqlParameter("@from_where", SqlDbType.VarChar, 16),
                new SqlParameter("@wei_jin",    SqlDbType.VarChar, 32),
                new SqlParameter("@notice",     SqlDbType.VarChar, 64),
                new SqlParameter("@effect",     SqlDbType.VarChar, 64),
                new SqlParameter("@use_up",     SqlDbType.Decimal, 10),
                new SqlParameter("@use_down",   SqlDbType.Decimal, 10),
                new SqlParameter("@drug_id",    SqlDbType.Int)
            };
            parameters[0].Value  = drug.Drug_ab;
            parameters[1].Value  = drug.Drug_name;
            parameters[2].Value  = drug.Unit_price;
            parameters[3].Value  = drug.Unit;
            parameters[4].Value  = drug.In_price;
            parameters[5].Value  = drug.Stock;
            parameters[6].Value  = drug.From_where;
            parameters[7].Value  = drug.Wei_jin;
            parameters[8].Value  = drug.Notice;
            parameters[9].Value  = drug.Effect;
            parameters[10].Value = drug.Use_up;
            parameters[11].Value = drug.Use_down;
            parameters[12].Value = drug.Id;
            int rows = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters);

            if (rows == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #12
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (tbuDrugComponents.Text == "" || tbuDrugDescription.Text == "" || tbuDrugQuantity.Text == "" || tbuDrugWeight.Text == "")
     {
         MessageBox.Show("Niste popunili sva polja!", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     else
     {
         Model.Drug drug = CreateDrug();
         drugListVerify.drugController.UpdateDrug(drug);
         drugListVerify.LoadAll();
         MessageBox.Show("Uspešno ste kreirali izveštaj!", "Uspešno izvršeno!", MessageBoxButton.OK, MessageBoxImage.Information);
         this.Close();
     }
 }
コード例 #13
0
 private void Button_Click_Ok(object sender, RoutedEventArgs e)
 {
     if (tbQuantityOfDrug.Text == "" || tbQuantityOfDrug.Text == null)
     {
         MessageBox.Show("Niste popunili sva polja!", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning);
         tbQuantityOfDrug.BorderBrush = Brushes.Red;
     }
     else
     {
         Controller.DrugController drugController = new Controller.DrugController();
         Model.Drug drug = drugController.GetDrugByName(cbDrugName.Text);
         drug.DrugQuantity = int.Parse(tbQuantityOfDrug.Text);
         drugConsumption.lvDataBinding.Items.Add(drug);
         MessageBox.Show("Uspešno ste dodali lek!", "Uspešno izvršeno!", MessageBoxButton.OK, MessageBoxImage.Information);
         this.Close();
     }
 }
コード例 #14
0
ファイル: DrugDALImp.cs プロジェクト: XEgithub/Medical
        public bool Add(Model.Drug drug)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [drug]");
            strSql.Append("(drug_ab,drug_name,unit_price,unit ,in_price ,stock ,from_where ,wei_jin ,notice ,effect,use_up,use_down values");
            strSql.Append("(@drug_ab,@drug_name,@unit_price,@unit ,@in_price ,@stock ,@from_where ,@wei_jin ,@notice ,@effect,@use_up,@use_down)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@drug_ab",    SqlDbType.VarChar, 10),
                new SqlParameter("@drug_name",  SqlDbType.VarChar, 16),
                new SqlParameter("@unit_price", SqlDbType.Decimal, 10),
                new SqlParameter("@unit",       SqlDbType.VarChar,  5),
                new SqlParameter("@in_price",   SqlDbType.Decimal, 10),
                new SqlParameter("@stock",      SqlDbType.Decimal, 10),
                new SqlParameter("@from_where", SqlDbType.VarChar, 16),
                new SqlParameter("@wei_jin",    SqlDbType.VarChar, 32),
                new SqlParameter("@notice",     SqlDbType.VarChar, 64),
                new SqlParameter("@effect",     SqlDbType.VarChar, 64),
                new SqlParameter("@use_up",     SqlDbType.Decimal, 10),
                new SqlParameter("@use_down",   SqlDbType.Decimal, 10)
            };
            parameters[0].Value  = drug.Drug_ab;
            parameters[1].Value  = drug.Drug_name;
            parameters[2].Value  = drug.Unit_price;
            parameters[3].Value  = drug.Unit;
            parameters[4].Value  = drug.In_price;
            parameters[5].Value  = drug.Stock;
            parameters[6].Value  = drug.From_where;
            parameters[7].Value  = drug.Wei_jin;
            parameters[8].Value  = drug.Notice;
            parameters[9].Value  = drug.Effect;
            parameters[10].Value = drug.Use_up;
            parameters[11].Value = drug.Use_down;
            int row = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters);

            if (row == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #15
0
 private void Button_Click_OK(object sender, RoutedEventArgs e)
 {
     if (tbComment.Text == "" || tbComment.Text == null)
     {
         check_validation();
     }
     else
     {
         Model.Drug selected = (Model.Drug)DrugListForVerifyOne.drugListForVerify.lvDataBindingDrugs.SelectedItems[0];
         selected.DrugType    = Model.TypeOfApprovedDrug.NotApproved;
         selected.DrugComment = tbComment.Text.ToString();
         DrugListForVerifyOne.drugListForVerify.drugController.UpdateDrug(selected);
         DrugListForVerifyOne.drugListForVerify.LoadAllDrugs();
         DrugListForVerifyOne.Close();
         MessageBox.Show("Uspešno ste poslali obrazloženje!", "Uspešno izvršeno!", MessageBoxButton.OK, MessageBoxImage.Information);
         this.Close();
     }
 }
コード例 #16
0
 private void Button_Click_OK(object sender, RoutedEventArgs e)
 {
     if (tbDrugComponents.Text == "" || tbDrugComponents.Text == null || tbDrugDescription.Text == "" || tbDrugDescription.Text == null ||
         tbDrugName.Text == "" || tbDrugName.Text == null || tbDrugQuantity.Text == "" || tbDrugQuantity.Text == null ||
         tbDrugWeight.Text == "" || tbDrugWeight.Text == null)
     {
         MessageBox.Show("Niste popunili sva polja!", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     else
     {
         drugList = new DrugList();
         Model.Drug drug = getDrug();
         drugList.drugController.UpdateDrug(drug);
         drugList.LoadAll();
         drugList.Show();
         this.Close();
         MessageBox.Show("Uspešno ste izmenili lek!", "Uspešno!", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
コード例 #17
0
 public void UpdateDrug(Model.Drug drug)
 {
     drugService.Update(drug);
 }
コード例 #18
0
 public void CreateDrug(Model.Drug drug)
 {
     drugService.Create(drug);
 }
コード例 #19
0
 private void Button_Click_Delete(object sender, RoutedEventArgs e)
 {
     Model.Drug drug = (Model.Drug)lvDataBinding.SelectedItems[0];
     drugController.DeleteDrug(drug.DrugId);
     LoadAll();
 }