Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (cboStatItem.MemberValue == null || cboStatItem.Text == "")
            {
                MessageBox.Show("请为该项目设置统计大类", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (txtPrice.Text.Trim( ) != "")
            {
                if (!HIS.SYSTEM.PubicBaseClasses.XcConvert.IsNumeric(txtPrice.Text))
                {
                    MessageBox.Show("单价请输入数字", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPrice.Focus( );
                    return;
                }
                else
                {
                    if (Convert.ToDecimal(txtPrice.Text) == 0)
                    {
                        MessageBox.Show("单价不能为0,请重新输入", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtPrice.Focus( );
                        return;
                    }
                }
            }
            else
            {
                MessageBox.Show("单价没有输入", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPrice.Focus( );
                return;
            }
            //执行保存操作
            try
            {
                ServiceItemController serviceItemController = new ServiceItemController();

                if (item == null)
                {
                    item = new HIS.Base_BLL.ServiceItem( );
                    string[] pywb = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.GetPyWbCode(this.txtItemName.Text);
                    item.ITEM_NAME      = this.txtItemName.Text;
                    item.PY_CODE        = pywb[0];
                    item.WB_CODE        = pywb[1];
                    item.STD_CODE       = this.txtStdCode.Text;
                    item.PRICE          = Convert.ToDecimal(this.txtPrice.Text);
                    item.ITEM_UNIT      = this.txtUnit.Text;
                    item.STATITEM_CODE  = this.cboStatItem.MemberValue.ToString( );
                    item.NCMS_COMP_RATE = Convert.ToDecimal(this.txtNcmsCompRate.Text);
                    item.INSUR_TYPE     = cboInsurType.Text;

                    item.VALID_FLAG = chkValid.Checked ? 1 : 0;

                    serviceItemController.AddServiceItems(item);
                    this.txtStdCode.Text         = "";
                    this.txtItemName.Text        = "";
                    this.txtPrice.Text           = "";
                    this.txtUnit.Text            = "";
                    this.cboStatItem.MemberValue = null;
                    this.cboStatItem.Text        = "";
                    this.chkValid.Checked        = true;
                    item = null;
                    MessageBox.Show("保存成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //if ( item.Add( ) )
                    //{
                    //    this.txtStdCode.Text = "";
                    //    this.txtItemName.Text = "";
                    //    this.txtPrice.Text = "";
                    //    this.txtUnit.Text = "";
                    //    this.cboStatItem.MemberValue = null;
                    //    this.cboStatItem.Text = "";
                    //    this.chkValid.Checked = true;
                    //    item = null;
                    //    MessageBox.Show( "保存成功!" , "" , MessageBoxButtons.OK , MessageBoxIcon.Information );
                    //}
                }
                else
                {
                    string[] pywb = GWMHIS.BussinessLogicLayer.Classes.PublicStaticFun.GetPyWbCode(this.txtItemName.Text);
                    item.ITEM_ID        = item.ITEM_ID;
                    item.ITEM_NAME      = this.txtItemName.Text;
                    item.PY_CODE        = pywb[0];
                    item.WB_CODE        = pywb[1];
                    item.STD_CODE       = this.txtStdCode.Text;
                    item.PRICE          = Convert.ToDecimal(this.txtPrice.Text);
                    item.ITEM_UNIT      = this.txtUnit.Text;
                    item.STATITEM_CODE  = this.cboStatItem.MemberValue.ToString( );
                    item.VALID_FLAG     = chkValid.Checked ? 1 : 0;
                    item.NCMS_COMP_RATE = Convert.ToDecimal(this.txtNcmsCompRate.Text);
                    item.INSUR_TYPE     = cboInsurType.Text;

                    serviceItemController.UpdateServiceItem(item);
                    btnSave.Enabled = false;

                    //if ( item.Update( ) )
                    //{
                    //    btnSave.Enabled = false;
                    //}
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }