コード例 #1
0
ファイル: frmBaseInfo.cs プロジェクト: ewin66/HIS
        private void m_cmdCCancelDelete_Click(object sender, EventArgs e)
        {
            if (this.m_lsvConcentration.FocusedItem == null ||
                this.m_lsvConcentration.FocusedItem.Tag == null)
            {
                return;
            }

            Cursor.Current             = Cursors.WaitCursor;
            m_cmdCCancelDelete.Enabled = false;

            clsLisConcentrationVO objconcentration = (clsLisConcentrationVO)this.m_lsvConcentration.FocusedItem.Tag;
            clsLisConcentrationVO objCopy          = new clsLisConcentrationVO();

            objconcentration.m_mthCopyTo(objCopy);//拷贝到另一个对象
            objCopy.m_enmStatus = enmQCStatus.Natrural;

            //更新到数据库
            long lngRes = clsTmdConcentrationSmp.s_object.m_lngUpdate(objCopy);

            if (lngRes > 0)
            {//更新成功
                objconcentration.m_enmStatus = enmQCStatus.Natrural;
                int intIdx = this.m_lsvConcentration.FocusedItem.Index;

                this.m_lsvConcentration.FocusedItem.Remove();

                //设置新的具有焦点的 ListView 项
                if (intIdx < this.m_lsvConcentration.Items.Count)
                {
                    this.m_lsvConcentration.Items[intIdx].Selected = true;
                    this.m_lsvConcentration.Items[intIdx].Focused  = true;
                    this.m_lsvConcentration_Click(null, null);
                }
                else if (intIdx - 1 >= 0)
                {
                    this.m_lsvConcentration.Items[intIdx - 1].Selected = true;
                    this.m_lsvConcentration.Items[intIdx - 1].Focused  = true;
                    this.m_lsvConcentration_Click(null, null);
                }
            }
            else
            {//更新失败
                clsCommonDialog.m_mthShowDBError();
            }

            m_cmdCCancelDelete.Enabled = true;
            Cursor.Current             = Cursors.Default;
        }
コード例 #2
0
ファイル: frmBaseInfo.cs プロジェクト: ewin66/HIS
        private void m_cmdCSave_Click(object sender, EventArgs e)
        {
            if (this.m_lsvConcentration.FocusedItem == null &&
                !this.m_blnNewConcentration)
            {
                return;
            }
            Cursor.Current          = Cursors.WaitCursor;
            this.m_cmdCSave.Enabled = false;

            if (this.m_blnNewConcentration)
            {//新增的保存
                clsLisConcentrationVO objConentration = new clsLisConcentrationVO();
                objConentration.m_enmStatus        = enmQCStatus.Natrural;
                objConentration.m_strConcentration = this.m_txtConcentration.Text.Trim();

                long lngRes = clsTmdConcentrationSmp.s_object.m_lngInsert(objConentration);
                if (lngRes > 0)
                {//成功
                    //更新状态标志
                    this.m_blnNewConcentration = false;
                    //加入到集合
                    clsLisConcentrationVO[] objconcentrationArr    = (clsLisConcentrationVO[])this.m_lsvConcentration.Tag;
                    clsLisConcentrationVO[] objconcentrationNewArr = new clsLisConcentrationVO[objconcentrationArr.Length + 1];
                    objconcentrationArr.CopyTo(objconcentrationNewArr, 0);
                    objconcentrationNewArr[objconcentrationNewArr.Length - 1] = objConentration;
                    this.m_lsvConcentration.Tag = objconcentrationNewArr;

                    //添加新项
                    ListViewItem item = new ListViewItem(objConentration.m_strConcentration);
                    item.Text = objConentration.m_intSeq.ToString();
                    item.SubItems.Add(objConentration.m_strConcentration);
                    item.Tag = objConentration;
                    this.m_lsvConcentration.Items.Add(item);
                    item.Selected = true;
                    item.Focused  = true;
                    this.m_lsvConcentration_Click(null, null);
                }
                else
                {//失败
                    clsCommonDialog.m_mthShowDBError();
                }
            }
            else
            {//修改的保存
                clsLisConcentrationVO objConcentration = (clsLisConcentrationVO)this.m_lsvConcentration.FocusedItem.Tag;

                clsLisConcentrationVO objNewConcentration = new clsLisConcentrationVO();
                objConcentration.m_mthCopyTo(objNewConcentration);
                objNewConcentration.m_strConcentration = this.m_txtConcentration.Text.Trim();

                long lngRes = clsTmdConcentrationSmp.s_object.m_lngUpdate(objNewConcentration);

                if (lngRes > 0)
                {//成功
                    objNewConcentration.m_mthCopyTo(objConcentration);
                    this.m_lsvConcentration.FocusedItem.Text             = objConcentration.m_intSeq.ToString();
                    this.m_lsvConcentration.FocusedItem.SubItems[1].Text = objConcentration.m_strConcentration;
                }
                else
                {//失败
                    clsCommonDialog.m_mthShowDBError();
                }
            }
            this.m_cmdCSave.Enabled = true;
            Cursor.Current          = Cursors.Default;
        }