private void m_cmdCMDelete_Click(object sender, EventArgs e) { if (this.m_lsvCheckMethod.FocusedItem == null) { return; } Cursor.Current = Cursors.WaitCursor; this.m_cmdCMDelete.Enabled = false; clsLisCheckMethodVO objMethod = (clsLisCheckMethodVO)this.m_lsvCheckMethod.FocusedItem.Tag; clsLisCheckMethodVO objCopy = new clsLisCheckMethodVO(); objMethod.m_mthCopyTo(objCopy); long lngRes = clsTmdCheckMethodSmp.s_object.m_lngDelete(objCopy.m_intSeq); if (lngRes > 0) {//成功 int intIdx = this.m_lsvCheckMethod.FocusedItem.Index; this.m_lsvCheckMethod.FocusedItem.Remove(); //设置新的具有焦点的 ListView 项 if (intIdx < this.m_lsvCheckMethod.Items.Count) { this.m_lsvCheckMethod.Items[intIdx].Selected = true; this.m_lsvCheckMethod.Items[intIdx].Focused = true; this.m_lsvCheckMethod_Click(null, null); } else if (intIdx - 1 >= 0) { this.m_lsvCheckMethod.Items[intIdx - 1].Selected = true; this.m_lsvCheckMethod.Items[intIdx - 1].Focused = true; this.m_lsvCheckMethod_Click(null, null); } } else {//失败 clsCommonDialog.m_mthShowDBError(); } this.m_cmdCMDelete.Enabled = true; Cursor.Current = Cursors.Default; }
private void m_cmdCMSave_Click(object sender, EventArgs e) { if (this.m_lsvCheckMethod.FocusedItem == null && !this.m_blnNewCheckMethod) { return; } Cursor.Current = Cursors.WaitCursor; this.m_cmdCMSave.Enabled = false; if (this.m_blnNewCheckMethod) {//新增的保存 clsLisCheckMethodVO objMethod = new clsLisCheckMethodVO(); objMethod.m_strName = this.m_txtCMName.Text.Trim(); objMethod.m_strPycode = this.m_txtCMPYCode.Text.Trim(); objMethod.m_strWbcode = this.m_txtCMWBCode.Text.Trim(); long lngRes = clsTmdCheckMethodSmp.s_object.m_lngInsert(objMethod); if (lngRes > 0) {//成功 //更新状态标志 this.m_blnNewCheckMethod = false; //加入到集合 clsLisCheckMethodVO[] objMethods = (clsLisCheckMethodVO[])this.m_lsvCheckMethod.Tag; clsLisCheckMethodVO[] objMethodsNewArr = new clsLisCheckMethodVO[objMethods.Length + 1]; objMethods.CopyTo(objMethodsNewArr, 0); objMethodsNewArr[objMethodsNewArr.Length - 1] = objMethod; this.m_lsvCheckMethod.Tag = objMethodsNewArr; //添加新项 ListViewItem item = new ListViewItem(objMethod.m_strName); item.SubItems.Add(objMethod.m_strPycode); item.SubItems.Add(objMethod.m_strWbcode); item.Tag = objMethod; this.m_lsvCheckMethod.Items.Add(item); item.Selected = true; item.Focused = true; this.m_lsvCheckMethod_Click(null, null); } else {//失败 clsCommonDialog.m_mthShowDBError(); } } else {//修改的保存 clsLisCheckMethodVO objMethod = (clsLisCheckMethodVO)this.m_lsvCheckMethod.FocusedItem.Tag; clsLisCheckMethodVO objNewMethod = new clsLisCheckMethodVO(); objMethod.m_mthCopyTo(objNewMethod); objNewMethod.m_strName = this.m_txtCMName.Text.Trim(); objNewMethod.m_strPycode = this.m_txtCMPYCode.Text.Trim(); objNewMethod.m_strWbcode = this.m_txtCMWBCode.Text.Trim(); long lngRes = clsTmdCheckMethodSmp.s_object.m_lngUpdate(objNewMethod); if (lngRes > 0) {//成功 objNewMethod.m_mthCopyTo(objMethod); this.m_lsvCheckMethod.FocusedItem.Text = objMethod.m_strName; this.m_lsvCheckMethod.FocusedItem.SubItems[1].Text = objMethod.m_strPycode; this.m_lsvCheckMethod.FocusedItem.SubItems[2].Text = objMethod.m_strWbcode; } else {//失败 clsCommonDialog.m_mthShowDBError(); } } this.m_cmdCMSave.Enabled = true; Cursor.Current = Cursors.Default; }