Beispiel #1
0
        private void m_cmdVDDelete_Click(object sender, EventArgs e)
        {
            if (this.m_lsvVendor.FocusedItem == null)
            {
                return;
            }
            Cursor.Current             = Cursors.WaitCursor;
            this.m_cmdVDDelete.Enabled = false;

            clsLisVendorVO objVendor = (clsLisVendorVO)this.m_lsvVendor.FocusedItem.Tag;
            clsLisVendorVO objCopy   = new clsLisVendorVO();

            objVendor.m_mthCopyTo(objCopy);

            long lngRes = clsTmdCheckMethodSmp.s_object.m_lngDelete(objCopy.m_intSeq);

            if (lngRes > 0)
            {//成功
                int intIdx = this.m_lsvVendor.FocusedItem.Index;

                this.m_lsvVendor.FocusedItem.Remove();

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

            this.m_cmdVDDelete.Enabled = true;
            Cursor.Current             = Cursors.Default;
        }
Beispiel #2
0
        private void m_cmdVDSave_Click(object sender, EventArgs e)
        {
            if (this.m_lsvVendor.FocusedItem == null &&
                !this.m_blnNewVendor)
            {
                return;
            }
            Cursor.Current           = Cursors.WaitCursor;
            this.m_cmdVDSave.Enabled = false;

            if (this.m_blnNewVendor)
            {//新增的保存
                clsLisVendorVO objVendor = new clsLisVendorVO();

                objVendor.m_strVendor = this.m_txtVDName.Text.Trim();
                objVendor.m_strId     = this.m_txtVendorCode.Text.Trim();
                objVendor.m_strPycode = this.m_txtVDPYCode.Text.Trim();
                objVendor.m_strWbcode = this.m_txtVDWBCode.Text.Trim();

                long lngRes = clsTmdVendorSmp.s_object.m_lngInsert(objVendor);
                if (lngRes > 0)
                {//成功
                    //更新状态标志
                    this.m_blnNewVendor = false;
                    //加入到集合
                    clsLisVendorVO[] objVendorArr    = (clsLisVendorVO[])this.m_lsvVendor.Tag;
                    clsLisVendorVO[] objVendorNewArr = new clsLisVendorVO[objVendorArr.Length + 1];
                    objVendorArr.CopyTo(objVendorNewArr, 0);
                    objVendorNewArr[objVendorNewArr.Length - 1] = objVendor;
                    this.m_lsvVendor.Tag = objVendorNewArr;
                    //添加新项
                    ListViewItem item = new ListViewItem(objVendor.m_strVendor);
                    item.SubItems.Add(objVendor.m_strId);
                    item.SubItems.Add(objVendor.m_strPycode);
                    item.SubItems.Add(objVendor.m_strWbcode);

                    item.Tag = objVendor;
                    this.m_lsvVendor.Items.Add(item);
                    item.Selected = true;
                    item.Focused  = true;
                    this.m_lsvVendor_Click(null, null);
                }
                else
                {//失败
                    clsCommonDialog.m_mthShowDBError();
                }
            }
            else
            {//修改的保存
                clsLisVendorVO objVendor = (clsLisVendorVO)this.m_lsvVendor.FocusedItem.Tag;

                clsLisVendorVO objNewVendor = new clsLisVendorVO();
                objVendor.m_mthCopyTo(objNewVendor);
                objNewVendor.m_strVendor = this.m_txtVDName.Text.Trim();
                objNewVendor.m_strId     = this.m_txtVendorCode.Text.Trim();
                objNewVendor.m_strPycode = this.m_txtVDPYCode.Text.Trim();
                objNewVendor.m_strWbcode = this.m_txtVDWBCode.Text.Trim();

                long lngRes = clsTmdVendorSmp.s_object.m_lngUpdate(objNewVendor);

                if (lngRes > 0)
                {//成功
                    objNewVendor.m_mthCopyTo(objVendor);

                    this.m_lsvVendor.FocusedItem.Text             = objVendor.m_strVendor;
                    this.m_lsvVendor.FocusedItem.SubItems[1].Text = objVendor.m_strId;
                    this.m_lsvVendor.FocusedItem.SubItems[2].Text = objVendor.m_strPycode;
                    this.m_lsvVendor.FocusedItem.SubItems[3].Text = objVendor.m_strWbcode;
                }
                else
                {//失败
                    clsCommonDialog.m_mthShowDBError();
                }
            }
            this.m_cmdVDSave.Enabled = true;
            Cursor.Current           = Cursors.Default;
        }