Esempio n. 1
0
        private void nudDosage_ValueChanged(object sender, EventArgs e)
        {
            if (null == nudDosage.Tag)
            {
                return;
            }

            BLPublic.IDCodeItem ic = (BLPublic.IDCodeItem)nudDosage.Tag;

            string dosageUnit = lvDrugs.Items[ic.ID].SubItems[2].Text;
            int    p          = dosageUnit.IndexOf(' ');

            if (0 < p)
            {
                dosageUnit = dosageUnit.Substring(p + 1).Trim();
            }
            else
            {
                return;
            }

            lvDrugs.Items[ic.ID].SubItems[2].Text = nudDosage.Value.ToString() + " " + dosageUnit;

            if (ic.Code.Equals(nudDosage.Value.ToString())) //值未变
            {
                return;
            }

            nudDosage.Enabled = false;

            calTPN();

            nudDosage.Enabled = true;
        }
Esempio n. 2
0
        private void lvDrugs_SelectedIndexChanged(object sender, EventArgs e)
        {
            if ((0 == lvDrugs.SelectedItems.Count) || (null == lvDrugs.SelectedItems[0].Tag))
            {
                nudDosage.Hide();
                return;
            }

            string dosage = lvDrugs.SelectedItems[0].SubItems[2].Text.Trim();
            int    p      = dosage.IndexOf(' ');

            if (0 < p)
            {
                dosage = dosage.Substring(0, p).Trim();
            }
            else
            {
                return;
            }

            int t = lvDrugs.Top + 18 + 1;

            for (int i = lvDrugs.SelectedItems[0].Index; i > lvDrugs.TopItem.Index; i--)
            {
                t += imageList1.ImageSize.Height + 1;
            }

            nudDosage.Width = lvDrugs.Columns[2].Width;
            nudDosage.Top   = t;
            nudDosage.Left  = lvDrugs.Left + lvDrugs.Columns[0].Width + lvDrugs.Columns[1].Width + 2 -
                              GetScrollPos(lvDrugs.Handle,  0);
            if (null == nudDosage.Tag)
            {
                nudDosage.Tag = new BLPublic.IDCodeItem(lvDrugs.SelectedItems[0].Index, dosage);
            }
            else
            {
                BLPublic.IDCodeItem ic = (BLPublic.IDCodeItem)nudDosage.Tag;
                ic.ID   = lvDrugs.SelectedItems[0].Index;
                ic.Code = dosage;
            }
            nudDosage.Value = Convert.ToDecimal(dosage);
            nudDosage.Show();
        }