示例#1
0
        /// <summary>
        /// 删除一行
        /// </summary>
        /// <param name="row"></param>
        private void del(int row)
        {
            if (row < 0 || this.fpSpread2_Sheet1.RowCount == 0)
            {
                return;
            }
            if (this.fpSpread2_Sheet1.Tag == null || this.fpSpread2_Sheet1.Tag.ToString() == "")
            {
                return;
            }

            if (MessageBox.Show("是否删除该排班类型?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
                == DialogResult.No)
            {
                return;
            }

            //删除
            Neusoft.HISFC.Models.Registration.WorkType obj = this.fpSpread2_Sheet1.Rows[row].Tag as
                                                             Neusoft.HISFC.Models.Registration.WorkType;

            Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

            //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(this.deptManager.Connection);
            //t.BeginTransaction();

            if (tabMgr == null)
            {
                tabMgr = new Neusoft.HISFC.BizProcess.Integrate.Registration.Tabulation();
            }
            tabMgr.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

            try
            {
                if (tabMgr.Delete(this.fpSpread2_Sheet1.Tag.ToString(), obj.ID) == -1)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    MessageBox.Show(tabMgr.Err, "提示");
                    return;
                }
                Neusoft.FrameWork.Management.PublicTrans.Commit();
            }
            catch (Exception e)
            {
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                MessageBox.Show(e.Message, "提示");
                return;
            }

            this.fpSpread2_Sheet1.Rows.Remove(row, 1);

            MessageBox.Show("删除成功!", "提示");
        }
示例#2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        public int Save()
        {
            //验证
            if (valid() == -1)
            {
                return(-1);
            }

            //安排序号
            string arrangeID = DateTime.Parse(fpSpread1_Sheet1.ColumnHeader.Cells[0, 2].Text).ToString("yyyyMMdd") +
                               DateTime.Parse(fpSpread1_Sheet1.ColumnHeader.Cells[0, 8].Text).ToString("yyyyMMdd");
            string deptID = this.Tag.ToString();//科室代码

            Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

            //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(this.personMgr.Connection);
            //t.BeginTransaction();

            tabMgr.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

            try
            {
                //删除已经保存的排班记录
                if (tabMgr.DeleteTabular(arrangeID, deptID) == -1)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    MessageBox.Show(this.tabMgr.Err, "提示");
                    return(-1);
                }
                //添加排班记录
                for (int i = 0; i < fpSpread1_Sheet1.RowCount; i++)
                {
                    //员工代码
                    string emplID = (fpSpread1_Sheet1.GetTag(i, 1) as Neusoft.HISFC.Models.Base.Employee).ID;

                    for (int j = 2; j < 9; j++)
                    {
                        if (fpSpread1_Sheet1.GetTag(i, j) != null)
                        {
                            //排班日期
                            DateTime workDate = DateTime.Parse(fpSpread1_Sheet1.ColumnHeader.Cells[0, j].Text);

                            tabular      = new Neusoft.HISFC.Models.Registration.Tabulation();
                            tabular.Kind = (Neusoft.HISFC.Models.Registration.WorkType)fpSpread1_Sheet1.GetTag(i, j);
                            //
                            tabular.arrangeID = arrangeID; //安排序号
                            tabular.DeptID    = deptID;    //科室
                            tabular.EmplID    = emplID;
                            tabular.Workdate  = workDate;
                            tabular.OperID    = var.ID;
                            tabular.Memo      = fpSpread1_Sheet1.GetNote(i, j);
                            tabular.SortID    = 2 * i;

                            if (tabMgr.Insert(tabular) == -1)
                            {
                                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                                MessageBox.Show(tabMgr.Err, "提示");
                                return(-1);
                            }
                        }
                    }
                }
                Neusoft.FrameWork.Management.PublicTrans.Commit();
            }
            catch (Exception e)
            {
                Neusoft.FrameWork.Management.PublicTrans.RollBack();
                MessageBox.Show(e.Message, "提示");
                return(-1);
            }

            MessageBox.Show("安排成功!", "提示");

            return(0);
        }