Exemplo n.º 1
0
        public void m_lngSave()
        {
            if (m_objViewer.m_txtCode.Text.Trim() == "")
            {
                m_ephHandler.m_mthAddControl(m_objViewer.m_txtCode);
                m_ephHandler.m_mthShowControlsErrorProvider();
                m_ephHandler.m_mthClearControl();
                m_objViewer.m_txtCode.Focus();
                return;
            }

            if (m_objViewer.m_txtName.Text.Trim() == "")
            {
                m_ephHandler.m_mthAddControl(m_objViewer.m_txtName);
                m_ephHandler.m_mthShowControlsErrorProvider();
                m_ephHandler.m_mthClearControl();
                m_objViewer.m_txtName.Focus();
                return;
            }

            if (this.m_objViewer.cboScope.Text.Trim() == "")
            {
                return;
            }

            long            lngRes    = 0;
            string          strID     = "";
            clsUsageType_VO objResult = new clsUsageType_VO();

            if (m_objViewer.m_txtCode.Text.Trim().Length == 1)
            {
                objResult.m_strUsageCode = "0" + m_objViewer.m_txtCode.Text;
            }
            else
            {
                objResult.m_strUsageCode = m_objViewer.m_txtCode.Text.Trim();
            }

            objResult.m_strUsageName   = m_objViewer.m_txtName.Text.Trim();
            objResult.m_strUsagePYCODE = m_objViewer.m_txtPYCODE.Text.Trim();
            objResult.m_strUsageWBCODE = m_objViewer.m_txtWBCODE.Text.Trim();
            objResult.m_intPutMed      = m_objViewer.m_cboPutMed_INT.SelectedIndex;
            objResult.m_intScope       = m_objViewer.cboScope.SelectedIndex;
            objResult.m_intTest        = m_objViewer.m_cboTest.SelectedIndex;
            objResult.m_strOPUsageDesc = this.m_objViewer.m_txtOPUsageDesc.Text;
            string scope = "";

            switch (objResult.m_intScope)
            {
            case 0:
                scope = "公用类";
                br    = gmc;
                break;

            case 1:
                scope = "西药类";
                br    = wmc;
                break;

            case 2:
                scope = "中药类";
                br    = cmc;
                break;
            }

            if (m_objViewer.m_txtName.Tag == null)          //新增
            {
                for (int i = 0; i < m_objViewer.m_lvw.Items.Count; i++)
                {
                    if (int.Parse(m_objViewer.m_lvw.Items[i].SubItems[1].Text) == int.Parse(m_objViewer.m_txtCode.Text))
                    {
                        MessageBox.Show("该助记码已存在!", "提示");
                        m_ephHandler.m_mthAddControl(m_objViewer.m_txtCode);
                        m_ephHandler.m_mthShowControlsErrorProvider();
                        m_ephHandler.m_mthClearControl();

                        m_objViewer.m_txtCode.Focus();
                        m_objViewer.m_txtCode.SelectAll();

                        return;
                    }
                }

                lngRes = clsDomain.m_lngAddUsage(objResult, out strID);
                int index = m_objViewer.m_lvw.Items.Count;
                if (lngRes > 0)
                {
                    ListViewItem lvw = new ListViewItem(scope);
                    lvw.SubItems.Add(objResult.m_strUsageCode);
                    lvw.SubItems.Add(objResult.m_strUsageName);
                    lvw.SubItems.Add(objResult.m_strUsagePYCODE);
                    lvw.SubItems.Add(objResult.m_strUsageWBCODE);
                    lvw.SubItems.Add(objResult.m_intPutMed == 0 ? "注射" : "非注射");
                    lvw.SubItems.Add(objResult.m_intTest == 0 ? "非皮试" : "皮试");
                    lvw.SubItems.Add(objResult.m_strOPUsageDesc);
                    lvw.Tag       = strID;
                    lvw.BackColor = br;
                    m_objViewer.m_lvw.Items.Add(lvw);
                    m_objViewer.m_lvw.Items[index].Selected = true;
                }
                else
                {
                    MessageBox.Show("保存失败!", "提示");
                }
            }
            else
            {
                if (m_objViewer.m_lvw.SelectedItems.Count <= 0)
                {
                    return;
                }
                for (int i = 0; i < m_objViewer.m_lvw.Items.Count; i++)
                {
                    if (i == m_objViewer.m_lvw.SelectedItems[0].Index)
                    {
                        continue;
                    }
                    if (int.Parse(m_objViewer.m_lvw.Items[i].SubItems[1].Text) == int.Parse(m_objViewer.m_txtCode.Text))
                    {
                        MessageBox.Show("该助记码已存在!", "提示");
                        m_ephHandler.m_mthAddControl(m_objViewer.m_txtCode);
                        m_ephHandler.m_mthShowControlsErrorProvider();
                        m_ephHandler.m_mthClearControl();

                        m_objViewer.m_txtCode.Focus();
                        m_objViewer.m_txtCode.SelectAll();

                        return;
                    }
                }

                objResult.m_strUsageID = m_objViewer.m_txtName.Tag.ToString();
                lngRes = clsDomain.m_lngDoUpdUsage(objResult);

                if (lngRes > 0)
                {
                    m_objViewer.m_lvw.SelectedItems[0].BackColor        = br;
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[0].Text = scope;
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[1].Text = objResult.m_strUsageCode;
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[2].Text = objResult.m_strUsageName;
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[3].Text = objResult.m_strUsagePYCODE;
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[4].Text = objResult.m_strUsageWBCODE;
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[5].Text = objResult.m_intPutMed == 0 ? "注射" : "非注射";
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[6].Text = objResult.m_intTest == 0 ? "非皮试" : "皮试";
                    m_objViewer.m_lvw.SelectedItems[0].SubItems[7].Text = objResult.m_strOPUsageDesc;
                    MessageBox.Show("修改成功!", "提示");
                }
                else
                {
                    MessageBox.Show("修改失败!", "提示");
                }
            }

            m_objViewer.m_txtName.Text   = "";
            m_objViewer.m_txtCode.Text   = "";
            m_objViewer.m_txtPYCODE.Text = "";
            m_objViewer.m_txtWBCODE.Text = "";
            m_objViewer.m_txtOPUsageDesc.Clear();
            m_objViewer.m_cboTest.SelectedIndex       = 0;
            m_objViewer.m_cboPutMed_INT.SelectedIndex = 0;
            m_objViewer.m_txtName.Tag = null;
            m_objViewer.m_txtCode.Focus();
        }