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

📄 fypzdwh.cs

📁 基于C/S的医疗卫生管理系统
💻 CS
📖 第 1 页 / 共 5 页
字号:
                ObjectAtPointer obj = dwYpMc.ObjectUnderMouse;
                if (obj.RowNumber > 0)
                {
                    dwYpMc.SetRow(obj.RowNumber);
                    string ypBmId = "";
                    if (!dwYpMc.IsItemNull(obj.RowNumber, "ypbmid"))
                        ypBmId = dwYpMc.GetItemString(obj.RowNumber, "ypbmid");


                    QContextMenuStrip contextMenu = new QContextMenuStrip();
                    contextMenu.Items.Add(MenuAddYpMc);
                    contextMenu.Items.Add(MenuModifyYpMc);
                    contextMenu.Items.Add(MenuDelYpMc);
                    contextMenu.Items.Add("-");
                    contextMenu.Items.Add(MenuAddYpBm);
                    contextMenu.Items.Add(MenuModifyYpBm);
                    contextMenu.Items.Add(MenuDelYpBm);
                    contextMenu.Items.Add("-");
                    contextMenu.Items.Add(MenuAddYpGg);

                    MenuAddYpGg.Enabled = true;
                    if (ypBmId == "")
                    {
                        MenuDelYpMc.Enabled = true;
                        MenuModifyYpBm.Enabled = false;
                        MenuDelYpBm.Enabled = false;
                    }
                    else
                    {
                        MenuDelYpMc.Enabled = false;
                        MenuModifyYpBm.Enabled = true;
                        MenuDelYpBm.Enabled = true;
                    }

                    contextMenu.Show(dwYpMc, e.Location);

                }
            }
        }

        #endregion

        #region 药品产地价格 查、增、删、改

        #region 增加药品产地价格
        private void btnAddPrice_Click(object sender, EventArgs e)
        {
            AddYpJg();
        }

        private void AddYpJg()
        {
            int row = dwYpGg.CurrentRow;
            if (row == 0)
                return;


            if (dwYpGg.IsItemNull(row, "ypggid"))
                return;

            string ypGgId = "";
            if (!dwYpGg.IsItemNull(row, "ypggid"))
                ypGgId = dwYpGg.GetItemString(row, "ypggid");

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

            string ypMcGg = "";
            if (!dwYpGg.IsItemNull(row, "ypmc"))
                ypMcGg = dwYpGg.GetItemString(row, "ypmc");

            if (!dwYpGg.IsItemNull(row, "ypgg"))
                ypMcGg += "  " + dwYpGg.GetItemString(row, "ypgg");

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

        #region 检索药品产地价格
        private void RetrieveYpJg(string ypGgId)
        {
            DbProxyClient proxy = App.DbProxy;
            try
            {
                proxy.Clear();
                proxy.AddRetrieveParam("p_ypggid", ypGgId);
                proxy.Retrieve(dwYpJg);
            }
            catch (Exception ex)
            {
                MessageBox.Show("检索药品价格发生异常:" + ex.Message, MsgTitle.Error);
            }
        }
        #endregion

        #region 修改药品产地价格
        private void ModifyYpJg()
        {
            int row = dwYpJg.CurrentRow;
            if (row == 0)
                return;


            string ypGgId = "";
            if (dwYpJg.IsItemNull(row, "ypggid"))
                return;
            else
                ypGgId = dwYpJg.GetItemString(row, "ypggid");

            string ypId = "";
            if (dwYpJg.IsItemNull(row, "ypid"))
                return;
            else
                ypId = dwYpJg.GetItemString(row, "ypid");

            string ypJgId = "";
            if (dwYpJg.IsItemNull(row, "ypjgid"))
                return;
            else
                ypJgId = dwYpJg.GetItemString(row, "ypjgid");

            string ypMcGg = "";
            if (!dwYpJg.IsItemNull(row, "ypmcgg"))
                ypMcGg = dwYpJg.GetItemString(row, "ypmcgg");

            FYpZdWh_YpJgWh fYpJgWh = null;
            try
            {
                fYpJgWh = new FYpZdWh_YpJgWh();
                fYpJgWh.SetId(ypJgId, ypGgId, ypMcGg, ypId);
                DialogResult dResult = fYpJgWh.ShowDialog(this);
                if (dResult == DialogResult.OK)
                {
                    this.RetrieveYpJg(ypGgId);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("调用药品价格维护窗口发生异常:" + ex.Message, MsgTitle.Error);
            }
            finally
            {
                if (fYpJgWh != null)
                    fYpJgWh.Dispose();
            }
        }
        #endregion

        #region 删除药品产地价格
        private void DelYpJg()
        {
            //检查删除条件

            int row = dwYpJg.CurrentRow;
            if (row > 0)
            {
                string ypJgId = dwYpJg.GetItemString(row, "ypjgid");

                string ypMcGg = "";
                if (!dwYpJg.IsItemNull(row, "ypMcGg"))
                    ypMcGg = dwYpJg.GetItemString(row, "ypMcGg");

                string cdMc = "";
                if (!dwYpJg.IsItemNull(row, "cdmc"))
                    cdMc = dwYpJg.GetItemString(row, "cdmc");

                DialogResult dResult = MessageBox.Show("您确定要删除规格为【" + ypMcGg + "】,产地为【"+cdMc+"】吗?", 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_TestDeleteYpJg";
                cmd.CommandType = CommandType.StoredProcedure;

                OracleParameter p_YpJgId = new OracleParameter();
                p_YpJgId.ParameterName = ":p_ypjgid";
                p_YpJgId.Value = ypJgId;
                p_YpJgId.DbType = DbType.String;
                p_YpJgId.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_YpJgId);
                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_DeleteYpJg";
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(p_YpJgId);

                proxy.Clear();
                proxy.AddDbCommand(cmd);
                proxy.Update();
                
                dwYpJg.DeleteRow(row);
            }
        }
        #endregion

        #endregion

        #region 药品规格DataWindow事件
        private void dwYpGg_RowFocusChanged(object sender, RowFocusChangedEventArgs e)
        {
            if (e.RowNumber > 0)
            {
                RetrieveYpJg(dwYpGg.GetItemString(e.RowNumber, "ypggid"));
            }
            else
            {
                dwYpJg.Reset();
            }
        }

        private void dwYpGg_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                QContextMenuStrip contextMenu = new QContextMenuStrip();
                contextMenu.Items.Add(MenuAddYpGg);
                contextMenu.Items.Add(MenuModifyYpGg);
                contextMenu.Items.Add(MenuDelYpGg);
                contextMenu.Items.Add("-");
                contextMenu.Items.Add(MenuAddYpJg);


                ObjectAtPointer obj = dwYpGg.ObjectUnderMouse;
                if (obj.RowNumber > 0)
                {
                    dwYpGg.SetRow(obj.RowNumber);

                    MenuModifyYpGg.Enabled = true;
                    //如果该规格存在产地价格,删除药品规格则不可用
                    if (dwYpJg.RowCount > 0)
                        MenuDelYpGg.Enabled = false;
                    else
                        MenuDelYpGg.Enabled = true;

                    MenuAddYpJg.Enabled = true;
                }
                else
                {
                    MenuModifyYpGg.Enabled = false;
                    MenuDelYpGg.Enabled = false;
                    MenuAddYpJg.Enabled = false;
                }
                if (dwYpMc.RowCount == 0)
                    MenuAddYpGg.Enabled = false;
                else
                    MenuAddYpGg.Enabled = true;


                contextMenu.Show(dwYpGg, e.Location);
            }
        }

        private void dwYpGg_Click(object sender, EventArgs e)
        {

        }
        #endregion

        #region 右键菜单处理
        private void MenuAddFlYp_Click(object sender, EventArgs e)
        {
            //调用新增分类/药品按钮事件
            btnAddYpFl_Click(sender, e);
        }

        //删除药品分类
        private void MenuDelYpFl_Click(object sender, EventArgs e)
        {
            DelYpFl();
        }

        //修改药品分类
        private void MenuModifyYpFl_Click(object sender, EventArgs e)
        {
            ModifyYpFl();
        }

        //增加药品
        private void MenuAddYpMc_Click(object sender, EventArgs e)
        {
            if (dwYpMc.CurrentRow > 0)
            {
                btnAddYpFl_Click(sender, e);
            }
        }

        //修改药品名称
        private void MenuModifyYpMc_Click(object sender, EventArgs e)
        {
            int row = dwYpMc.CurrentRow;
            if (row > 0)
            {
                //药品ID
                string ypId = dwYpMc.GetItemString(row,"ypid");
                //别名ID
                string ypBmId = "";
                if (!dwYpMc.IsItemNull(row,"ypbmid"))
                    dwYpMc.GetItemString(row, "ypflid");

                //药品分类ID
                string ypFlId = dwYpMc.GetItemString(row,"ypflid");
                //药品分类名称
                string ypFlMc = "";
                if (tvYpFl.SelectedNode != null)
                {
                    ypFlMc = tvYpFl.SelectedNode.Text;
                }

                ModifyYpMc(ypId,ypFlId,ypFlMc,ypBmId);
            }
        }

⌨️ 快捷键说明

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