コード例 #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         TimeSpan    sp          = dtpDue.Value.Subtract(dtpProDate.Value);
         AddMedicine addMedicine = new AddMedicine();
         addMedicine.MedID        = txtMedId.Text.Trim();
         addMedicine.MedName      = txtName.Text.Trim();
         addMedicine.Production   = cmbProduce.Text.Trim();
         addMedicine.ProduteDate  = dtpProDate.Value;
         addMedicine.DueDate      = dtpDue.Value;
         addMedicine.ReleaseDay   = Convert.ToInt32(sp.Days);
         addMedicine.Quantity     = Convert.ToInt32(numSum.Value);
         addMedicine.MedBid       = Convert.ToDecimal(numBid.Text);
         addMedicine.MedUnitPrice = Convert.ToDecimal(numSale.Text.Trim());
         addMedicine.Memary       = txtMemary.Text.Trim();
         if (BllMedicine.InsertInMed(addMedicine))
         {
             MessageBox.Show(@"添加成功!");
             Information.Medicine = null;
             this.Close();
         }
         else
         {
             MessageBox.Show(@"添加失败,请检查后重试!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(@"需要输入纯数字的地方是否正确输入!" + ex);
         return;
     }
 }
コード例 #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtStandard.Text) || string.IsNullOrEmpty(cmbType.Text) || string.IsNullOrEmpty(cmbUnits.Text) || string.IsNullOrEmpty(txtMedApproval.Text) || string.IsNullOrEmpty(txtSpellFirst.Text))
     {
         MessageBox.Show(@"请完善药品信息!");
         return;
     }
     if (!string.IsNullOrEmpty(medId))
     {
         Medicine medicine = new Medicine();
         medicine.MedId         = medId;
         medicine.MedName       = txtName.Text.Trim();
         medicine.MedApproval   = txtMedApproval.Text.Trim();
         medicine.MedStandard   = txtStandard.Text.Trim();
         medicine.MedUnit       = cmbUnits.Text.Trim();
         medicine.MedTypeId     = cmbType.SelectedValue.ToString().Trim();
         medicine.MedSpellFirst = txtSpellFirst.Text.Trim();
         if (BllMedicine.InsertMedicine(medicine))
         {
             MessageBox.Show(@"修改成功!");
             Information.Medicine = null;
             this.Close();
         }
         else
         {
             MessageBox.Show(@"修改失败,检查后重试!");
         }
     }
     else
     {
         Medicine medicine = new Medicine();
         medicine.MedId         = string.Empty;
         medicine.MedName       = txtName.Text.Trim();
         medicine.MedApproval   = txtMedApproval.Text.Trim();
         medicine.MedStandard   = txtStandard.Text.Trim();
         medicine.MedUnit       = cmbUnits.Text.Trim();
         medicine.MedTypeId     = cmbType.SelectedValue.ToString().Trim();
         medicine.MedSpellFirst = txtSpellFirst.Text.Trim();
         if (BllMedicine.InsertMedicine(medicine))
         {
             MessageBox.Show(@"创建成功!");
             txtName.Text = txtStandard.Text = cmbUnits.Text = cmbType.Text = txtMedApproval.Text = txtSpellFirst.Text = string.Empty;
         }
         else
         {
             MessageBox.Show(@"创建失败,检查后重试!");
         }
     }
 }