コード例 #1
0
        private void txtProductCode_Leave(object sender, EventArgs e)
        {
            //判断编号是否已存在
            if (!string.IsNullOrEmpty(this.txtProductCode.Text.Trim()) && !string.IsNullOrEmpty(this.txtPartsCode.Text.Trim()))
            {
                BaseProductPartsTable ProductPartsCode = new BaseProductPartsTable();
                ProductPartsCode = bProductParts.GetModel(txtProductCode.Text, txtPartsCode.Text);
                if (ProductPartsCode != null)
                {
                    txtProductCode.Text = "";
                    txtProductName.Text = "";
                    txtPartsCode.Text   = "";
                    txtProductCode.Focus();
                    MessageBox.Show("商品编号和材料编号的组合已存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            string product = txtProductCode.Text.Trim();

            if (!string.IsNullOrEmpty(product))
            {
                BaseMaster baseMaster = bCommon.GetBaseMaster("PRODUCT", product);
                if (baseMaster != null)
                {
                    txtProductCode.Text = baseMaster.Code;
                    txtProductName.Text = baseMaster.Name;
                    txtPartsCode.Focus();
                }
                else
                {
                    MessageBox.Show("商品编号不存在,请重新输入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtProductCode.Text = "";
                    txtProductName.Text = "";
                    txtProductCode.Focus();
                }
            }
            else
            {
                txtProductName.Text = "";
            }
        }
コード例 #2
0
        /// <summary>
        /// 获得当前选中的数据
        /// </summary>
        private void GetCurrentSelectedTable()
        {
            try
            {
                string productcode = dgvData.SelectedRows[0].Cells["PRODUCT_CODE"].Value.ToString();
                string partcode    = dgvData.SelectedRows[0].Cells["PRODUCT_PART_CODE"].Value.ToString();
                if (productcode != "")
                {
                    _currentProductPartsTable = bProductParts.GetModel(productcode, partcode);
                }
            }
            catch (Exception ex) { }

            if (_currentProductPartsTable == null || _currentProductPartsTable.PRODUCT_CODE == null || "".Equals(_currentProductPartsTable.PRODUCT_CODE))
            {
                _currentProductPartsTable = null;
            }
        }