Exemplo n.º 1
0
        /// <summary>
        ///  保存终端
        /// </summary>
        private void SaveTerminal( )
        {
            ListView currListView;

            //如果没有选中节点,则返回
            //发药窗口
            if (neuTabControl1.SelectedTab == this.tabPage1)
            {
                if (this.neuListView1.Items.Count > 0)
                {
                    currListView = this.neuListView1;
                }
                else
                {
                    return;
                }
            }
            else //配药台
            {
                if (this.neuListView2.Items.Count > 0)
                {
                    currListView = this.neuListView2;
                }
                else
                {
                    return;
                }
            }
            //判断是否信息已填完整
            if (this.IsValid( ) == -1)
            {
                return;
            }
            //判断是否存在重名信息
            if (this.isSameName( ) == -1)
            {
                return;
            }

            Neusoft.HISFC.Object.Pharmacy.DrugTerminal info;
            //定义数据库事务
            Neusoft.NFC.Management.Transaction t = new Neusoft.NFC.Management.Transaction(Neusoft.NFC.Management.Connection.Instance);
            t.BeginTransaction( );
            try
            {
                this.drugStore.SetTrans(t.Trans);
                bool isSave = true;
                //保存数据
                for (int i = 0; i < currListView.Items.Count; i++)
                {
                    info         = currListView.Items[i].Tag as Neusoft.HISFC.Object.Pharmacy.DrugTerminal;
                    info.Dept.ID = this.privDept.ID;
                    if (this.drugStore.SetDrugTerminal(info) == -1)
                    {   //先进行更新操作,如无数据则插入
                        isSave = false;
                        t.RollBack( );
                        MessageBox.Show(Language.Msg("保存第") + i.ToString( ) + Language.Msg("行时出错\n") + this.drugStore.Err);
                        break;
                    }
                }

                if (isSave)
                {
                    t.Commit( );
                    MessageBox.Show(Language.Msg("保存成功"));
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                t.RollBack( );
                MessageBox.Show(ex.Message);
                return;
            }

            //更新是否新增的标记
            for (int i = 0; i < currListView.Items.Count; i++)
            {
                info        = currListView.Items[i].Tag as Neusoft.HISFC.Object.Pharmacy.DrugTerminal;
                info.User01 = "";
                currListView.Items[i].Tag = info;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化库存
        /// </summary>
        private void AddStock( )
        {
            if (this.ValidCheck( ) < 0)
            {
                return;
            }
            List <Neusoft.HISFC.Object.Base.Department> aldept = this.tvDeptTree1.SelectNodes;

            if (aldept.Count == 0)
            {
                MessageBox.Show(Language.Msg("请选择要添加的库房"), Language.Msg("提示"));
                return;
            }

            //定义数据库处理事务

            Neusoft.NFC.Management.Transaction t = new Neusoft.NFC.Management.Transaction(Neusoft.NFC.Management.Connection.Instance);
            t.BeginTransaction( );
            this.item.SetTrans(t.Trans);
            try
            {
                string  drugCode = "";
                decimal quantity = Neusoft.NFC.Function.NConvert.ToDecimal(this.txtSum.Text);
                bool    IsUpdate = false;
                bool    check    = false;
                Neusoft.HISFC.Object.Pharmacy.StorageBase storageBase = new Neusoft.HISFC.Object.Pharmacy.StorageBase( );
                storageBase.GroupNO    = 1;                                                   //批次号
                storageBase.BatchNO    = "1";                                                 //批号
                storageBase.ShowState  = "0";                                                 //显示的单位标记
                storageBase.ValidTime  = this.item.GetDateTimeFromSysDateTime( ).AddYears(5); //有效期
                storageBase.Quantity   = quantity;                                            //库存更新数量
                storageBase.PlaceNO    = "0";                                                 //货位号
                storageBase.ID         = "0";                                                 //单据号
                storageBase.SerialNO   = 0;                                                   //单内序号
                storageBase.SystemType = "00";                                                //库存操作类型M1门诊发药,M2门诊退药,Z1住院发药,Z2住院退药……
                storageBase.PrivType   = "0301";                                              //class2_code
                storageBase.Memo       = "库存初始化";                                             //备注
                storageBase.Operation.Oper.OperTime = this.item.GetDateTimeFromSysDateTime( );

                foreach (Neusoft.HISFC.Object.Base.Department dept in aldept)
                {
                    for (int i = 0; i < this.neuSpread1_Sheet1.RowCount; i++)
                    {
                        Neusoft.NFC.Interface.Classes.Function.ShowWaitForm(i, this.neuSpread1_Sheet1.RowCount);
                        Application.DoEvents( );

                        //如果没有选中,则不处理此条数据
                        check = Neusoft.NFC.Function.NConvert.ToBoolean(this.neuSpread1_Sheet1.Cells[i, 0].Value);
                        if (!check)
                        {
                            continue;
                        }

                        //取药品编码
                        drugCode = this.neuSpread1_Sheet1.Cells[i, 8].Text;
                        //库房编码
                        storageBase.StockDept.ID = dept.ID;
                        //目标科室
                        storageBase.TargetDept.ID = dept.ID;
                        //获得药品信息
                        storageBase.Item = this.item.GetItem(drugCode);

                        if (storageBase.Item == null)
                        {
                            t.RollBack( );
                            MessageBox.Show(Language.Msg("无法转换成storageBase.Item类型"), Language.Msg("提示"));
                            return;
                        }

                        //包装数量为0时,不允许增加库存
                        if (storageBase.Item.PackQty == 0)
                        {
                            continue;
                        }

                        storageBase.StoreCost = quantity * storageBase.Item.PriceCollection.RetailPrice / storageBase.Item.PackQty;      //库存金额

                        //插入库存表
                        if (this.item.SetStorage(storageBase) != 1)
                        {
                            t.RollBack( );
                            MessageBox.Show(this.item.Err, Language.Msg("保存错误提示"));
                            return;
                        }

                        IsUpdate = true;
                    }
                }
                if (IsUpdate)
                {
                    t.Commit( );
                    MessageBox.Show(Language.Msg("保存成功!"));
                }
                else
                {
                    //如果没有更新的数据,则回滚事务.
                    t.RollBack( );
                }
            }
            catch (Exception ex)
            {
                t.RollBack( );
                MessageBox.Show(ex.Message);
                return;
            }

            //显示全部药品
            this.dvDrugList.RowFilter = "1=1";
            this.SetFormat( );
            //取消选中
            this.SelectDrug(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除终端
        /// </summary>
        private void DeleteTerminal( )
        {
            Neusoft.HISFC.Object.Pharmacy.DrugTerminal drugTerminal;
            //如果没有选中节点,则返回
            //发药窗口
            if (neuTabControl1.SelectedTab == this.tabPage1)
            {
                if (this.neuListView1.SelectedItems.Count > 0)
                {
                    drugTerminal = this.neuListView1.SelectedItems[0].Tag as Neusoft.HISFC.Object.Pharmacy.DrugTerminal;
                }
                else
                {
                    return;
                }
            }
            else //配药台
            {
                if (this.neuListView2.SelectedItems.Count > 0)
                {
                    drugTerminal = this.neuListView2.SelectedItems[0].Tag as Neusoft.HISFC.Object.Pharmacy.DrugTerminal;
                }
                else
                {
                    return;
                }
            }
            //确认删除
            DialogResult result = MessageBox.Show(Neusoft.NFC.Management.Language.Msg("删除后将不能恢复,是否继续?"), Neusoft.NFC.Management.Language.Msg("提示"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.No)
            {
                return;
            }
            //判断是否已经保存的数据
            if (!(drugTerminal.User01 == "New"))
            {
                int parm;
                //判断该终端是否为其他终端的替代终端、提示操作员
                parm = this.drugStore.IsReplaceFlag(drugTerminal.ID);
                if (parm == -1)
                {
                    return;
                }
                if (parm == 1)
                {
                    //提示用户是否确认删除
                    DialogResult res = MessageBox.Show(Neusoft.NFC.Management.Language.Msg("该条记录为其他终端的替代终端、确认进行删除吗?"), Neusoft.NFC.Management.Language.Msg("提示"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.RightAlign);
                    if (res == DialogResult.No)
                    {
                        return;
                    }
                }

                //定义数据库事务
                Neusoft.NFC.Management.Transaction t = new Neusoft.NFC.Management.Transaction(Neusoft.NFC.Management.Connection.Instance);
                t.BeginTransaction( );

                try
                {
                    this.drugStore.SetTrans(t.Trans);
                    //删除数据
                    if (this.drugStore.DeleteDrugTerminal(drugTerminal.ID) == -1)
                    {
                        t.RollBack( );
                        MessageBox.Show(this.drugStore.Err);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    t.RollBack( );
                    MessageBox.Show(ex.Message);
                    return;
                }

                t.Commit( );
                MessageBox.Show("删除成功");
            }

            //从列表中删除
            // 发药窗口
            if (neuTabControl1.SelectedTab == this.tabPage1)
            {
                if (this.neuListView1.SelectedItems.Count > 0)
                {
                    this.neuListView1.Items.Remove(this.neuListView1.SelectedItems[0]);
                }
            }
            else //配药台
            {
                if (this.neuListView2.SelectedItems.Count > 0)
                {
                    this.neuListView2.Items.Remove(this.neuListView2.SelectedItems[0]);
                }
            }
        }