⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fypzdwh_ypggwh.cs

📁 基于C/S的医疗卫生管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
                dwYpGg.Focus();
                dwYpGg.SetColumn("zblbid");
                return false;
            }

            //剂型ID
            if (dwYpGg.IsItemNull(1, "jxid") || dwYpGg.GetItemString(1, "jxid") == "")
            {
                MessageBox.Show("剂型不能为空,请输入!", MsgTitle.Prompt);
                dwYpGg.Focus();
                dwYpGg.SetColumn("jxid");
                return false;
            }

            //包装量
            if (dwYpGg.IsItemNull(1, "bzl") || dwYpGg.GetItemDecimal(1, "bzl") <=0)
            {
                MessageBox.Show("包装量必须大于0,请输入!", MsgTitle.Prompt);
                dwYpGg.Focus();
                dwYpGg.SetColumn("bzl");
                return false;
            }

            //最小单位
            if (dwYpGg.IsItemNull(1, "zxdw") || dwYpGg.GetItemString(1, "zxdw") == "")
            {
                MessageBox.Show("最小单位不能为空,请输入!", MsgTitle.Prompt);
                dwYpGg.Focus();
                dwYpGg.SetColumn("zxdw");
                return false;
            }

            //包装单位
            if (dwYpGg.IsItemNull(1, "bzdw") || dwYpGg.GetItemString(1, "bzdw") == "")
            {
                MessageBox.Show("包装单位不能为空,请输入!", MsgTitle.Prompt);
                dwYpGg.Focus();
                dwYpGg.SetColumn("bzdw");
                return false;
            }

            //输入了剂量必须输入剂量单位
            if (!dwYpGg.IsItemNull(1,"jl") && dwYpGg.GetItemDecimal(1,"jl") !=0)
            {
                if (dwYpGg.IsItemNull(1,"jldw") || dwYpGg.GetItemString(1,"jldw")=="")
                {
                    MessageBox.Show("请输入正确的剂量单位!", MsgTitle.Prompt);
                    dwYpGg.Focus();
                    dwYpGg.SetColumn("jldw");
                    return false;
                }
            }

            //输入了剂量单位必须输入剂量
            if (!dwYpGg.IsItemNull(1, "jldw") && dwYpGg.GetItemString(1, "jldw") != "")
            {
                if (dwYpGg.IsItemNull(1, "jl") || dwYpGg.GetItemDecimal(1, "jl")<=0)
                {
                    MessageBox.Show("请输入正确的剂量!", MsgTitle.Prompt);
                    dwYpGg.Focus();
                    dwYpGg.SetColumn("jl");
                    return false;
                }
            }

            //输入了体积必须输入体积单位
            if (!dwYpGg.IsItemNull(1, "tj") && dwYpGg.GetItemDecimal(1, "tj") != 0)
            {
                if (dwYpGg.IsItemNull(1, "tjdw") || dwYpGg.GetItemString(1, "tjdw")=="")
                {
                    MessageBox.Show("请输入正确的体积单位!", MsgTitle.Prompt);
                    dwYpGg.Focus();
                    dwYpGg.SetColumn("tjdw");
                    return false;
                }
            }

            //输入了体积单位必须输入体积
            if (!dwYpGg.IsItemNull(1, "tjdw") && dwYpGg.GetItemString(1, "tjdw") != "")
            {
                if (dwYpGg.IsItemNull(1, "tj") || dwYpGg.GetItemDecimal(1, "tj") <= 0)
                {
                    MessageBox.Show("请输入正确的体积!",MsgTitle.Prompt);
                    dwYpGg.Focus();
                    dwYpGg.SetColumn("tj");
                    return false;
                }
            }

            //浓度
            if (!dwYpGg.IsItemNull(1, "nd"))
            {
                if (dwYpGg.GetItemDecimal(1, "nd") < 0)
                    MessageBox.Show("浓度不能为负数!", MsgTitle.Prompt);
                else if(dwYpGg.GetItemDecimal(1,"nd")==0)
                    dwYpGg.SetItemNull(1, "nd");
            }

            return true;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            SetYpGg();

            if (!CheckYpGgXx())
                return;

            if (m_YpGgId =="0")
            {
                //设置主键
                try
                {
                    string ypGgId = Sequence.GetXhByName("SEQ_GY_YPGGK_YPGGID", 6);
                    if (string.IsNullOrEmpty(ypGgId))
                    {
                        MessageBox.Show("取药品规格ID不成功,取到的值为空!", MsgTitle.Error);
                        return;
                    }
                    //药品规格ID
                    dwYpGg.SetItemString(1, "ypggid", ypGgId);
                    //大规格ID
                    dwYpGg.SetItemString(1, "dggid", ypGgId);
                    //小规格ID
                    dwYpGg.SetItemNull(1, "xggid");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("取药品规格ID发生异常:" + ex.Message, MsgTitle.Error);
                    return;
                }
            }

            //保存
            try
            {
                DbProxyClient proxy = App.DbProxy;
                proxy.Clear();
                proxy.AddDataWindow(dwYpGg);
                if (m_YpGgId =="0")  //增加规格
                {
                    proxy.AddDbCommand(GetAfterInsertCommand(), new VerifyInfo(VerifyModeEnum.OutputPara,":p_appcode", LogicSymbolEnum.Equal, 1));
                }
                else //修改规格
                {
                    proxy.AddDbCommand(GetAfterUpdateCommand(), new VerifyInfo(VerifyModeEnum.OutputPara, ":p_appcode", LogicSymbolEnum.Equal, 1));
                }
                proxy.Update();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存药品规格信息时发生异常:" + ex.Message, MsgTitle.Error);
            }
        }

        private OracleCommand GetAfterInsertCommand()
        {
            if (dwYpGg.IsItemNull(1, "ypid"))
                throw new Exception("数据窗口中药品ID没有设置值。");

            string ypId = dwYpGg.GetItemString(1, "ypid");

            string ypGgId = dwYpGg.GetItemString(1, "ypggid");

            OracleCommand command = new OracleCommand();
            command.CommandText = "PKG_GY_YPZD.Prc_AfterInsertYpGgXx";
            command.CommandType = CommandType.StoredProcedure;

            //药品规格ID
            OracleParameter p_YpGgId = new OracleParameter();
            p_YpGgId.ParameterName = ":p_ypggid";
            p_YpGgId.Value = ypGgId;
            p_YpGgId.DbType = DbType.String;
            p_YpGgId.Direction = ParameterDirection.Input;

            //药品ID
            OracleParameter p_YpId = new OracleParameter();
            p_YpId.ParameterName = ":p_ypid";
            p_YpId.Value = ypId;
            p_YpId.DbType = DbType.String;
            p_YpId.Direction = ParameterDirection.Input;

            OracleParameter p_AppCode = new OracleParameter();
            p_AppCode.ParameterName = ":p_appcode";
            p_AppCode.DbType = DbType.Int32;
            p_AppCode.Direction = ParameterDirection.Output;

            OracleParameter p_OutBuffer = new OracleParameter();
            p_OutBuffer.ParameterName = ":p_outbuffer";
            p_OutBuffer.DbType = DbType.String;
            p_OutBuffer.Size = 600;
            p_OutBuffer.Direction = ParameterDirection.Output;


            command.Parameters.Add(p_YpGgId);
            command.Parameters.Add(p_YpId);
            command.Parameters.Add(p_AppCode);
            command.Parameters.Add(p_OutBuffer);

            return command;
        }
        private OracleCommand GetAfterUpdateCommand()
        {
            string ypGgId = dwYpGg.GetItemString(1, "ypggid");

            OracleCommand command = new OracleCommand();
            command.CommandText = "PKG_GY_YPZD.Prc_AfterUpdateYpGgXx";
            command.CommandType = CommandType.StoredProcedure;

            //药品规格ID
            OracleParameter p_YpGgId = new OracleParameter();
            p_YpGgId.ParameterName = ":p_ypggid";
            p_YpGgId.Value = ypGgId;
            p_YpGgId.DbType = DbType.String;
            p_YpGgId.Direction = ParameterDirection.Input;

            //小规格ID
            OracleParameter p_XggId = new OracleParameter();
            p_XggId.ParameterName = ":p_xggid";
            p_XggId.Value = null;
            p_XggId.DbType = DbType.String;
            p_XggId.Direction = ParameterDirection.Input;

            OracleParameter p_AppCode = new OracleParameter();
            p_AppCode.ParameterName = ":p_appcode";
            p_AppCode.DbType = DbType.Int32;
            p_AppCode.Direction = ParameterDirection.Output;

            OracleParameter p_OutBuffer = new OracleParameter();
            p_OutBuffer.ParameterName = ":p_outbuffer";
            p_OutBuffer.DbType = DbType.String;
            p_OutBuffer.Size = 600;
            p_OutBuffer.Direction = ParameterDirection.Output;

            command.Parameters.Add(p_YpGgId);
            command.Parameters.Add(p_XggId);
            command.Parameters.Add(p_AppCode);
            command.Parameters.Add(p_OutBuffer);

            return command;
        }

        private void dwYpGg_ItemChanged(object sender, Sybase.DataWindow.ItemChangedEventArgs e)
        {
            switch (e.ColumnName)
            {
                case "nd":
                case "jl":
                case "jldw":
                case "tj":
                case "tjdw":
                case "bzl":
                case "zxdw":
                    SetYpGg();
                    break;
            }
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -