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

📄 fypzdwh.cs

📁 基于C/S的医疗卫生管理系统
💻 CS
📖 第 1 页 / 共 5 页
字号:

                //药品名称
                if (dwYpMc.IsItemNull(ypRow, "ypmc"))
                    dwYpMc.SetItemNull(row, "ypmc");
                else
                    dwYpMc.SetItemString(row, "ypmc", dwYpMc.GetItemString(ypRow, "ypmc"));

                //标准编码
                if (dwYpMc.IsItemNull(ypRow, "bzbm"))
                    dwYpMc.SetItemNull(row, "bzbm");
                else
                    dwYpMc.SetItemString(row, "bzbm", dwYpMc.GetItemString(ypRow, "bzbm"));

                //药品类型
                if (dwYpMc.IsItemNull(ypRow, "yplx"))
                    dwYpMc.SetItemNull(row, "yplx");
                else
                    dwYpMc.SetItemString(row, "yplx", dwYpMc.GetItemString(ypRow, "yplx"));

                //药品分类ID
                if (dwYpMc.IsItemNull(ypRow, "ypflid"))
                    dwYpMc.SetItemNull(row, "ypflid");
                else
                    dwYpMc.SetItemString(row, "ypflid", dwYpMc.GetItemString(ypRow, "ypflid"));


                dwYpMc.SetRow(row);
                dwYpMc.ScrollToRow(row);
            }
            catch (Exception ex)
            {
                MessageBox.Show("增加别名成功,刷新界面发生异常,请退出重试!\r\n" + ex.Message, MsgTitle.Error);
                this.btnAddOtherName.Enabled = false;
            }
        }
        #endregion

        #region 修改药品别名
        private void ModifyYpBm()
        {
            int row = dwYpMc.CurrentRow;
            if (row>0)
            {
                string ypBmId = "";
                if (dwYpMc.IsItemNull(row, "ypbmid"))
                    return;
                else
                    ypBmId = dwYpMc.GetItemString(row, "ypbmid");

                string ypId = dwYpMc.GetItemString(row, "ypid");
                string ypMc = "";
                if (!dwYpMc.IsItemNull(row, "ypmc"))
                    ypMc = dwYpMc.GetItemString(row, "ypmc");


                FYpZdWh_YpBmWh fYpBmWh = null;
                try
                {
                    fYpBmWh = new FYpZdWh_YpBmWh();
                    fYpBmWh.SetId(ypBmId, ypId, ypMc);
                    DialogResult dResult = fYpBmWh.ShowDialog(this);
                    if (dResult == DialogResult.OK)
                    {
                        dwYpMc.SetItemString(row, "ypbmmc", fYpBmWh.YpBmXx.ypBmMc); 
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("调用药品别名维护窗口发生异常:" + ex.Message, MsgTitle.Error);
                }
                finally
                {
                    if (fYpBmWh != null)
                        fYpBmWh.Dispose();
                }
            }
        }
        #endregion

        #region 删除药品别名
        private void DelYpBm()
        {
            int row = dwYpMc.CurrentRow;
            if (row > 0)
            {
                string ypBmId = "";
                if (!dwYpMc.IsItemNull(row, "ypbmid"))
                    ypBmId = dwYpMc.GetItemString(row, "ypbmid");

                if (string.IsNullOrEmpty(ypBmId))
                    return;

                string ypBmMc = "";
                if (!dwYpMc.IsItemNull(row, "ypbmmc"))
                    ypBmMc = dwYpMc.GetItemString(row, "ypbmmc");


                DialogResult dResult = MessageBox.Show("您确定要删除别名【" + ypBmMc + "】吗?", MsgTitle.Prompt, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dResult == DialogResult.No)
                    return;

                OracleCommand command = new OracleCommand();
                command.CommandText = "UPDATE GY_YPBMK SET ZFBZ=1 WHERE YPBMID=:p_ypbmid";
                command.CommandType = CommandType.Text;
                OracleParameter p_YpBmId = new OracleParameter();
                p_YpBmId.ParameterName = ":p_ypbmid";
                p_YpBmId.DbType = DbType.String;
                p_YpBmId.Value = ypBmId;
                command.Parameters.Add(p_YpBmId);

                try
                {
                    DbProxyClient proxy = App.DbProxy;
                    proxy.Clear();
                    proxy.AddDbCommand(command, new VerifyInfo(VerifyModeEnum.AffectRows, LogicSymbolEnum.Equal, 1));
                    proxy.Update();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("删除药品别名发生异常:" + ex.Message, MsgTitle.Error);
                    return;
                }

                string ypId = dwYpMc.GetItemString(row,"ypid");
                int findRow = dwYpMc.FindRow("ypid='" + ypId + "' and ypbmid <>'" + ypBmId + "'",1,dwYpMc.RowCount);
                if (findRow > 0)
                    dwYpMc.DeleteRow(dwYpMc.CurrentRow);
                else
                {
                    dwYpMc.SetItemNull(row, "ypbmid");
                    dwYpMc.SetItemNull(row, "ypbmmc");
                }
            }
        }
        #endregion
        #endregion

        #region 药品规格 查、增、删、改

        #region 增加药品规格
        private void btnAddStandard_Click(object sender, EventArgs e)
        {
            AddYpGg();
        }

        private void AddYpGg()
        {
            int row = dwYpMc.CurrentRow;
            if (row == 0)
                return;

            if (dwYpMc.IsItemNull(row, "ypid"))
                return;

            string ypId = dwYpMc.GetItemString(row, "ypid");
            string ypmc = "";
            if (!dwYpMc.IsItemNull(row, "ypmc"))
                ypmc = dwYpMc.GetItemString(row, "ypmc");

            string ypLx = "";
            if (dwYpMc.IsItemNull(row, "yplx"))
            {
                MessageBox.Show("没有取到药品类型!", MsgTitle.Error);
                return;
            }
            else
            {
                ypLx = dwYpMc.GetItemString(row, "yplx");
            }

            FYpZdWh_YpGgWh fYpGgWh = null;
            try
            {
                string ypGgId = "0"; //0表示新增
                fYpGgWh = new FYpZdWh_YpGgWh();
                fYpGgWh.SetId(ypGgId, ypId, ypmc, ypLx);
                DialogResult dResult = fYpGgWh.ShowDialog(this);
                if (dResult == DialogResult.OK)
                {
                    this.RetrieveYpGg(ypId, ypLx);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("调用药品规格维护窗口发生异常:" + ex.Message, MsgTitle.Error);
            }
            finally
            {
                if (fYpGgWh != null)
                    fYpGgWh.Dispose();
            }
        }
        #endregion

        private void ModifyYpGg()
        {
            int row = dwYpGg.CurrentRow;
            if (row > 0)
            {
                string ypGgId = dwYpGg.GetItemString(row, "ypggid");
                string ypMc = "";
                if (!dwYpGg.IsItemNull(row,"ypmc"))
                    ypMc = dwYpGg.GetItemString(row, "ypmc");

                string ypId = dwYpGg.GetItemString(row, "ypid");
                string ypLx = dwYpGg.GetItemString(row, "yplx");

                FYpZdWh_YpGgWh fYpGgWh = null;
                try
                {
                   
                    fYpGgWh = new FYpZdWh_YpGgWh();
                    fYpGgWh.SetId(ypGgId, ypId, ypMc, ypLx);
                    DialogResult dResult = fYpGgWh.ShowDialog(this);
                    if (dResult == DialogResult.OK)
                    {
                        this.RetrieveYpGg(ypId, ypLx);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("调用药品规格维护窗口发生异常:" + ex.Message, MsgTitle.Error);
                }
                finally
                {
                    if (fYpGgWh != null)
                        fYpGgWh.Dispose();
                }
            }
        }

        #region 删除药品规格
        private void DelYpGg()
        {
            int row = dwYpGg.CurrentRow;
            if (row > 0)
            {
                string ypGgId = dwYpGg.GetItemString(row, "ypggid");
                string ypMc = "";
                if (!dwYpGg.IsItemNull(row, "ypmc"))
                    ypMc = dwYpGg.GetItemString(row, "ypmc");

                string ypGg = "";
                if (!dwYpGg.IsItemNull(row, "ypgg"))
                    ypGg = dwYpGg.GetItemString(row, "ypgg");

                DialogResult dResult = MessageBox.Show("您确定要删除规格【" + ypMc +"  "+ypGg+ "】吗?", MsgTitle.Prompt, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dResult == DialogResult.No)
                    return;

                DbProxyClient proxy = App.DbProxy;
                //检查规格是否可删
                OracleCommand cmd = new OracleCommand();
                cmd.CommandText = "PKG_GY_YPZD.Prc_TestDeleteYpGg";
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter p_YpGgId = new OracleParameter();
                p_YpGgId.ParameterName = ":p_ypggid";
                p_YpGgId.Value = ypGgId;
                p_YpGgId.DbType = DbType.String;
                p_YpGgId.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;

                cmd.Parameters.Add(p_YpGgId);
                cmd.Parameters.Add(p_AppCode);
                cmd.Parameters.Add(p_OutBuffer);

                proxy.Clear();
                proxy.AddDbCommand(cmd);
                proxy.Update();

                if (p_AppCode.Value == null || p_AppCode.Value.ToString() != "1")
                {
                    //不可删除
                    MessageBox.Show(p_OutBuffer.Value.ToString());
                    return;
                }

                //删除规格
                cmd.Parameters.Clear();
                cmd.CommandText = "PKG_GY_YPZD.Prc_DeleteYpGg";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(p_YpGgId);

                proxy.Clear();
                proxy.AddDbCommand(cmd);
                proxy.Update();

                dwYpGg.DeleteRow(row);
            }
        }
        #endregion

        #region 检索药品规格
        private void RetrieveYpGg(string ypId, string ypLx)
        {
            DbProxyClient proxy = App.DbProxy;
            try
            {
                proxy.Clear();
                proxy.AddRetrieveParam("p_ypid", ypId);
                proxy.Retrieve(dwYpGg);
            }
            catch (Exception ex)
            {
                MessageBox.Show("检索药品规格发生异常:" + ex.Message, MsgTitle.Error);
            }

            try
            {
                DataWindowChild dwc = dwYpGg.GetChild("zblbid");
                proxy.Clear();
                proxy.AddRetrieveParam("p_yplx", ypLx);
                proxy.Retrieve(dwc);
            }
            catch (Exception ex)
            {
                MessageBox.Show("检索帐薄类别发生异常:" + ex.Message, MsgTitle.Error);
            }

        }
        #endregion

        #endregion

        #region 药品名称Dw事件
        private void dwYpMc_DoubleClick(object sender, EventArgs e)
        {
            //根据药品分类ID在药品分类树中定位分类
        }

        private void dwYpMc_RowFocusChanged(object sender, Sybase.DataWindow.RowFocusChangedEventArgs e)
        {
            if (e.RowNumber == 0)
                dwYpGg.Reset();
            else
            {
                string ypId = dwYpMc.GetItemString(e.RowNumber, "ypid");
                string ypLx = dwYpMc.GetItemString(e.RowNumber, "yplx");
                this.RetrieveYpGg(ypId, ypLx);
            }
        }

        private void dwYpMc_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                //if (dwYpMc.RowCount == 0)
                //    return;

⌨️ 快捷键说明

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