Esempio n. 1
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.EditSuperviseArgs e)
        {
            List <object> sqlParams = new List <object>();

            if (Model.QueryIsExistSameUserNoUpdate(e.UserId, e.UserNo))
            {
                View.ExeMessageBox("存在相同用户名,请修改...", false);
                return;
            }
            string loginUserId = e.LoginUser.Rows[0]["user_id"].ToString();

            sqlParams.Add(e.UserNo);
            sqlParams.Add(e.UserName);
            sqlParams.Add(e.OrganId);
            sqlParams.Add(loginUserId);
            sqlParams.Add(e.UserId);
            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                // 修改用户表
                if (Model.UpdateUser(trans.ID, sqlParams))
                {
                    // 删除该用户原有功能(删除角色功能表)
                    Model.DeleteRoleFunctionByRoleId(trans.ID, loginUserId, e.RoleId);
                    // 插入角色功能表新数据
                    Model.InsertRoleFunction(trans.ID, e.RoleId, e.ListFunction, loginUserId);
                    View.ExeMessageBox("修改成功!", true);
                }
                else
                {
                    View.ExeMessageBox("修改失败,请联系管理员...", false);
                }
                trans.Complete();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 审方修改批次(审方用)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void View_OnUpdateCheckFrequencyBatch(object sender, Views.DataManage.EditFrequencyToBatchEventArgs e)
 {
     using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
     {
         CJia.PIVAS.Models.CheckAdviceModel checkAdviceModel = new CJia.PIVAS.Models.CheckAdviceModel();
         int checkSeq = checkAdviceModel.GetCheckSeq();
         //插入审核表
         checkAdviceModel.AddCheck(trans.ID, checkSeq, User.UserId, User.UserNo, User.UserName, User.DeptId, User.DeptName, User.UserId);
         //更新瓶贴基表
         List <string> GroupIndex = new List <string>();
         GroupIndex.Add(e.GroupIndex);
         if (GroupIndex != null && GroupIndex.Count != 0)
         {
             checkAdviceModel.DeleteCommonLabel(trans.ID, GroupIndex);
             checkAdviceModel.InsertCommonLabel(trans.ID, GroupIndex, CJia.PIVAS.User.UserId);
             checkAdviceModel.InsertLabelDetail(trans.ID, GroupIndex);
         }
         //将之前审核明细置为无效
         int detailId  = checkAdviceModel.GetDetailIdByGroupIndex(e.GroupIndex);
         int detailSeq = checkAdviceModel.GetCheckDetailSeq();
         this.Model.UpdateCheckBatch(trans.ID, detailSeq, checkSeq, e.BatchsName, e.UserId, e.GroupIndex);
         checkAdviceModel.ModifyCheckDetailValid(trans.ID, User.UserId, detailId);
         trans.Complete();
         this.View.CloseWindow();
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 同意退药时插入退药表
 /// </summary>
 /// <param name="cancelRCPSeq">退药单号</param>
 /// <param name="userId">退药审核人ID</param>
 /// <param name="userCode">退药审核人代码</param>
 /// <param name="userName">退药审核人名称</param>
 /// <param name="deptId">退药审核人部门ID</param>
 /// <param name="deptName">退药审核人部门名称</param>
 /// <returns>true:插入成功; false:插入失败</returns>
 public bool InsertCancelRCP(long cancelRCPSeq, long userId, string userCode, string userName, string deptId, string deptName)
 {
     using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
     {
         bool          isSuccess = false;
         List <object> sqlParams = new List <object>();
         sqlParams.Add(cancelRCPSeq);
         sqlParams.Add(userId);
         sqlParams.Add(userCode);
         sqlParams.Add(userName);
         sqlParams.Add(deptId);
         sqlParams.Add(deptName);
         sqlParams.Add(userId);
         sqlParams.Add(userId);
         //sqlParams.Add(201301310001);
         //sqlParams.Add(1000000001);
         //sqlParams.Add("huyang");
         //sqlParams.Add("胡洋");
         //sqlParams.Add("1000000289");
         //sqlParams.Add("急诊输液室");
         //sqlParams.Add(1000000001);
         //sqlParams.Add(1000000001);
         isSuccess = CJia.DefaultOleDb.Execute(trans.ID, SqlTools.SqlInsertCancelRCP, sqlParams) > 0 ? true : false;
         trans.Complete();
         return(isSuccess);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.AddRoleArgs e)
        {
            bool   isSuccess = false;
            string organId   = e.User.Rows[0]["organ_id"].ToString();
            // 0代表超级管理员所拥有角色;1代表超级管理员(为组织管理员)所建角色;2代表组织管理员(为普通用户)所建角色
            string roleType = "2";

            if (Model.QueryExistSameRoleName(e.RoleName, organId))
            {
                View.ExeMessageBox("该组织下存在相同角色名,请修改...", false);
                return;
            }
            string createBy = e.User.Rows[0]["user_id"].ToString();
            // 角色表Seq
            string roleSeq = Model.QueryRoleSeq();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                // 插入角色表
                if (Model.InsertRole(trans.ID, roleSeq, e.RoleName, createBy, organId, roleType))
                {
                    // 插入角色功能表
                    Model.InsertRoleFunction(trans.ID, roleSeq, e.ListFunction, createBy);
                    isSuccess = true;
                    View.ExeMessageBox("保存成功!", false);
                }
                trans.Complete();
            }
            if (!isSuccess)
            {
                View.ExeMessageBox("保存失败,请联系管理员...", false);
            }
        }
Esempio n. 5
0
 //拒绝退药
 void view_OnRefuseApply(object sender, Views.NewCancelApplyArgs e)
 {
     long cancelRCPID = Model.GetNextCancelRCPId();
     if (e.LabelID.Count > 0)
     {
         using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
         {
             List<string> list = new List<string>();
             list = GetLable(e.LabelID);
             for (int i = 0; i < list.Count; i++)
             {
                 bool bol = Model.ModifyCancelRCPID(trans.ID, cancelRCPID, list[i], User.UserId.ToString(), "1", "1000305");
                 bool bol1 = Model.ModifyLabelStatusByID(trans.ID, list[i], User.UserId.ToString());
                 if (!bol || !bol1)
                 {
                     View.ShowMessage("拒绝退药申请失败!");
                     return;
                 }
             }
             bool bol2 = Model.AddCancelApplyRCP(trans.ID, cancelRCPID, User.UserId.ToString(), User.UserName, User.DeptId, User.DeptName, User.UserId.ToString());
             if (bol2)
             {
                 View.ShowMessage("拒绝退药申请成功!");
             }
             trans.Complete();
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// 单个审方
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnInsertCheck(object sender, Views.CheckAdviceArgs e)
        {
            int checkSeq = Model.GetCheckSeq();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                //插入审核表
                this.Model.AddCheck(trans.ID, checkSeq, User.UserId, User.UserNo, User.UserName, User.DeptId, User.DeptName, User.UserId);
                //判断是否在明细表
                DataTable data = Model.GetCheckDetailDataByGroupIndex(e.GroupIndex);
                if (data == null)//新医嘱,未审核过
                {
                    //插入审核明细表
                    Model.AddCheckDetail(trans.ID, checkSeq, e.GroupIndex, e.OriginalPivasStatus, e.CheckPivasStatus, e.OriginalPivasBatchNo, e.CheckPivasBatchNo, User.UserId, e.CancelReason);
                    //更新瓶贴基表
                    List <string> groupIndex = new List <string>();
                    groupIndex.Add(e.GroupIndex);
                    RefreshCommonLabel(trans.ID, groupIndex);
                }
                else
                {
                    //更新瓶贴基表
                    List <string> groupIndex = new List <string>();
                    groupIndex.Add(e.GroupIndex);
                    RefreshCommonLabel(trans.ID, groupIndex);
                    //将之前审核明细置为无效
                    int detailId = Model.GetDetailIdByGroupIndex(e.GroupIndex);
                    Model.ModifyCheckDetailValid(trans.ID, User.UserId, detailId);
                    //插入新的审核明细
                    Model.AddCheckDetail(trans.ID, checkSeq, e.GroupIndex, e.OriginalPivasStatus, e.CheckPivasStatus, e.OriginalPivasBatchNo, e.CheckPivasBatchNo, User.UserId, e.CancelReason);
                }
                trans.Complete();
            }
        }
Esempio n. 7
0
        void View_OnSendPharm(object sender, Views.SendPharmEventArgs e)
        {
            //判断冲药是否今天
            DateTime sysdate = Model.SystemDate;

            if (sysdate.ToShortDateString() != e.date.ToShortDateString())
            {
                View.ShowMessage("请选择当前时间进行冲药操作!");
                return;
            }
            //判断有无退药申请

            //判断库存
            DataTable data = Model.GetTodayNOPharmStore(e.IffieldID);

            if (data != null && data.Rows.Count > 0)
            {
                View.ExeBindTodayNoPharmStore(data, e.IffieldID); return;
            }
            //扣费用 扣库存 费用明细
            DataTable adviceData = Model.QueryTodayPharmSend(e.IffieldID);

            if (adviceData != null && adviceData.Rows.Count > 0)
            {
                DataTable trueAdvice  = adviceData.Clone();
                DataTable falseAdvice = adviceData.Clone();
                falseAdvice.Columns.Add("MESSAGE", typeof(string));
                using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
                {
                    for (int i = 0; i < adviceData.Rows.Count; i++)
                    {
                        int    j       = int.Parse(adviceData.Rows[i]["TIMES"].ToString());
                        string message = Models.PIVASModel.ExecuteAdviceIdFee(trans.ID, adviceData.Rows[i]["ADVICE_ID"].ToString(), User.HisUserId.ToString(), sysdate, j, 1);
                        if (message != "Successed!")
                        {
                            DataRow  dr     = falseAdvice.NewRow();
                            object[] drItem = new object[adviceData.Rows[i].ItemArray.Length + 1];
                            for (int k = 0; k < drItem.Length - 1; k++)
                            {
                                drItem[k] = adviceData.Rows[i].ItemArray[k];
                            }
                            drItem[drItem.Length - 1] = message;
                            dr.ItemArray = drItem;
                            falseAdvice.Rows.Add(dr);
                        }
                        else
                        {
                            DataRow dr = trueAdvice.NewRow();
                            dr.ItemArray = adviceData.Rows[i].ItemArray;
                            trueAdvice.Rows.Add(dr);
                        }
                    }
                    trans.Complete();
                }
                View.ExeBindTodayPharmSend(trueAdvice, falseAdvice);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 审方通过
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnComplete(object sender, Views.CheckAdviceArgs e)
        {
            DataTable batchData = Model.GetBatchData(e.BeginListDate, e.EndListDate, e.OfficeID);

            if (batchData == null)
            {
                CJia.Message.Show("没有待审医嘱!");
            }
            else
            {
                int checkSeq = Model.GetCheckSeq();
                using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
                {
                    //插入审核表
                    this.Model.AddCheck(trans.ID, checkSeq, User.UserId, User.UserNo, User.UserName, User.DeptId, User.DeptName, User.UserId);
                    ////明细表中的未审医嘱
                    DataTable noData = Model.GetCheckDetail(e.BeginListDate, e.EndListDate, e.OfficeID);
                    //明细表中的已审医嘱
                    DataTable yesData = Model.GetYesCheckDetail(e.BeginListDate, e.EndListDate, e.OfficeID);
                    if (yesData == null && noData == null)//新医嘱,未审核过
                    {
                        //插入审核明细表
                        Model.BatchAddCheckDetail(trans.ID, checkSeq, e.CheckPivasStatus, User.UserId, e.BeginListDate, e.EndListDate, e.OfficeID);
                        //更新瓶贴基表
                        List <string> groupIndex = new List <string>();
                        //DataTable batchData = Model.GetBatchData(e.BeginListDate, e.EndListDate, e.OfficeID);
                        for (int i = 0; i < batchData.Rows.Count; i++)
                        {
                            groupIndex.Add(batchData.Rows[i]["GROUP_INDEX"].ToString());
                        }
                        RefreshCommonLabel(trans.ID, groupIndex);
                    }
                    else
                    {
                        List <string> groupIndex = new List <string>();
                        //DataTable batchData = Model.GetBatchData(e.BeginListDate, e.EndListDate, e.OfficeID);
                        if (batchData != null)
                        {
                            for (int i = 0; i < batchData.Rows.Count; i++)
                            {
                                groupIndex.Add(batchData.Rows[i]["GROUP_INDEX"].ToString());
                            }
                        }
                        //将之前审核明细批量置为无效
                        Model.ModifyCheckDetail(trans.ID, User.UserId, e.BeginListDate, e.EndListDate, e.OfficeID, groupIndex);
                        //插入新的审核明细
                        Model.BatchAddCheckDetail(trans.ID, checkSeq, e.CheckPivasStatus, User.UserId, e.BeginListDate, e.EndListDate, e.OfficeID);
                        //更新瓶贴基表
                        RefreshCommonLabel(trans.ID, groupIndex);
                    }
                    trans.Complete();
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 删除单个用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnDeleteUserId(object sender, Views.QuerySuperviseArgs e)
        {
            string updateBy = e.User.Rows[0]["user_id"].ToString();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                Model.DeleteUserRoleByUserId(trans.ID, updateBy, e.DeletedUserId);
                Model.DeleteUserById(trans.ID, updateBy, e.DeletedUserId);
                trans.Complete();
            }
        }
Esempio n. 10
0
        /// <summary>
        ///  删除所选择多个组织
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnDeletedDeptArr(object sender, Views.QueryDeptArgs e)
        {
            string updateBy = e.User.Rows[0]["user_id"].ToString();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                for (int i = 0; i < e.DeletedDeptArr.Count; i++)
                {
                    bool s = Model.DeleteDeptById(trans.ID, updateBy, e.DeletedDeptArr[i].ToString());
                }
                trans.Complete();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 同意退药修改瓶贴表瓶贴状态
        /// </summary>
        /// <param name="userName">用户名称</param>
        /// <param name="group_index">瓶贴所属组号</param>
        /// <returns></returns>
        public bool UpdatePivasLabelStatus(long userId, string group_index)
        {
            bool   isSuccess = false;
            string group     = string.Format(SqlTools.SqlUpdatePivasLabelStatus, group_index);

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                object[] sqlParams = new object[] { userId };
                isSuccess = CJia.DefaultOleDb.Execute(trans.ID, group, sqlParams) > 0 ? true : false;
                trans.Complete();
            }
            return(isSuccess);
        }
Esempio n. 12
0
        /// <summary>
        /// 拒绝退药时根据界面所选group_index修改退药表
        /// </summary>
        /// <param name="userId">用户名称</param>
        /// <param name="group_index"></param>
        /// <returns></returns>
        public bool UpdateCancelApplyByRefuse(long refuseRCPId, long userId, string group_index)
        {
            string group = string.Format(SqlTools.SqlUpdateRefuseApply, group_index);

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                bool     isSuccess = false;
                object[] sqlParams = new object[] { refuseRCPId, userId };
                isSuccess = CJia.DefaultOleDb.Execute(trans.ID, group, sqlParams) > 0 ? true : false;
                trans.Complete();
                return(isSuccess);
            }
        }
Esempio n. 13
0
 public void Transaction_检查事务是否有效_有效()
 {
     using (CJia.Transaction trans = new CJia.Transaction())
     {
         string SqlDelete = @"delete from temp_test where a = 10000";
         CJia.DefaultData.Execute(trans.ID, SqlDelete);
         string SqlInsert = @"insert into temp_test (a,b,c) values (10000,'cc',to_date('2012-12-01','YYYY-MM-DD'))";
         int    Result    = CJia.DefaultData.Execute(trans.ID, SqlInsert);
         string SqlQuery  = @"select count(1) from temp_test where a = 10000";
         string count     = CJia.DefaultData.QueryScalar(trans.ID, SqlQuery);
         Assert.AreEqual("1", count, "事务无效");
         trans.Complete();
     }
 }
Esempio n. 14
0
        public void postgred数据库访问()
        {
            for (int i = 10; i < 100; i++)
            {
                using (CJia.Transaction tran = new CJia.Transaction())
                {
                    for (int j = i * 1000; j < (i + 1) * 1000; j++)
                    {
                        string sql = string.Format(@"insert into gm_user (user_id,user_no,user_name,user_pwd)
values ({0},'{0}','{0}','{0}')", j);
                        CJia.DefaultPostgre.Execute(tran.ID, sql);
                    }
                    tran.Complete();
                }
            }
        }
Esempio n. 15
0
        //确认退药
        void view_OnOkCancel(object sender, Views.NewCancelApplyArgs e)
        {
            long cancelRCPID = Model.GetNextCancelRCPId();
            if (e.LabelID.Count > 0)
            {
                using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
                {
                    List<string> list = new List<string>();
                    list = GetLable(e.LabelID);
                    for (int i = 0; i < list.Count; i++)
                    {
                        bool bol = Model.ModifyCancelRCPID(trans.ID, cancelRCPID, list[i], User.UserId.ToString(), "1", "1000303");
                        bool bol1 = Model.ModifyLabelStatusByID2(trans.ID, list[i], User.UserId.ToString());
                        bool bol3 = Model.ModifyBarCodeStatusByID(trans.ID, list[i], User.UserId.ToString());
                        if (!bol || !bol1 || !bol3)
                        {
                            View.ShowMessage("确定退药失败!" + bol.ToString() + bol1.ToString() + bol3.ToString());
                            return;
                        }
                    }

                    for (int j = 0; j < e.AdviceID.Count; j++)
                    {
                        if (CJia.PIVAS.Models.PIVASModel.QueryCancelFeeTimeLabelId(e.LabelID[j]))
                        {
                            int feeCount = int.Parse(this.Model.QueryLabelTimes(e.LabelID[j]));
                            if (feeCount != 0)
                            {
                                string str = CJia.PIVAS.Models.PIVASModel.ExecuteAdviceIdFee(trans.ID, e.AdviceID[j], User.HisUserId.ToString(), Model.Sysdate().AddSeconds(j), feeCount, 1);
                                if (str != "Successed")
                                {
                                    View.ShowMessage("确定退药失败!" + str);
                                    return;
                                }
                            }
                        }
                    }
                    bool bol2 = Model.AddCancelApplyRCP(trans.ID, cancelRCPID, User.UserId.ToString(), User.UserName, User.DeptId, User.DeptName, User.UserId.ToString());
                    if (bol2)
                    {
                        View.ShowMessage("确定退药成功!");
                    }
                    trans.Complete();
                }
            }
        }
Esempio n. 16
0
        public void TestNewEntity_测试实体删除_添加_查询_保存()
        {
            TestDataEntity de = new TestDataEntity();

            de.Fill();
            for (int i = 0; i < de.Count; i++)
            {
                de[i].Delete();
            }
            int result = de.Save();

            de.Add();
            de.AFild = "1";
            de.BFild = "AA";
            //de.CFild = "2012-10-11";
            de.DFild = "WW";
            de.Add();
            de.AFild = "2";
            de.BFild = "BB";
            de.CFild = "2012-10-12";
            de.DFild = "QQ";
            de.Add();
            de.AFild = "3";
            de.BFild = "CC";
            de.CFild = "2012-10-13";
            de.DFild = "EE";
            DataRow dr = de.EntitySet.NewRow();

            dr["A"] = "4";
            dr["B"] = "DD";
            dr["C"] = "2012-10-13";
            dr["D"] = "FF";
            de.Add(dr);
            using (CJia.Transaction trans = new CJia.Transaction())
            {
                result = de.Save(trans.ID);
                string count = CJia.DefaultData.QueryScalar(trans.ID, "select count(1) from TEST_TABLE");
                Assert.AreEqual("4", count, "实体事务保存失败");
                //trans.Complete();
                //de.Commit();
            }
            Assert.AreEqual(4, result, "实体保存失败");
            string count2 = CJia.DefaultData.QueryScalar("select count(1) from TEST_TABLE");

            Assert.AreEqual("0", count2, "实体事务回滚保存失败");
        }
Esempio n. 17
0
 void view_OnReportData(object sender, Views.CheckReportArgs e)
 {
     //判断审核结果数据源中有无强制类型
     if (CanReport(e.CheckResultPatientData))
     {
         if (Message.ShowQuery("确定上报数据?", Message.Button.OkCancel) == Message.Result.Ok)
         {
             using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
             {
                 Tools.Loading load = new Tools.Loading();
                 Tools.Help.NewRedBorderShowFrom(load);
                 Application.DoEvents();
                 bool isSuccess = true;
                 foreach (DataRow dr in e.PatientData.Rows)
                 {
                     //将非强制类型病人copy到本地库
                     DataTable data = Model.GetMyPatient(dr["P3"].ToString(), dr["P2"].ToString());
                     if (data.Rows.Count == 0)  //本地库无此病人
                     {
                         Model.AddPatient(trans.ID, dr);
                     }
                     isSuccess = Model.ModifyPatientReportState(trans.ID, dr["P3"].ToString(), dr["P2"].ToString());
                     if (!isSuccess)
                     {
                         break;
                     }
                 }
                 load.ParentForm.Close();
                 bool bol = View.ExeBindIsSuccessReport(isSuccess);
                 if (bol)
                 {
                     trans.Complete();
                     Message.Show("上报数据成功!");
                 }
                 else
                 {
                     Message.Show("上报数据失败!");
                 }
             }
         }
     }
     //修改病人审核状态,上报过的不能继续上报
     //修改病人上报状态
     //生成DBF文件
 }
Esempio n. 18
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.EditTaskArgs e)
        {
            System.Data.DataRow dr      = e.User.Rows[0];
            bool          isSaveSuccess = false;
            List <object> sqlParams     = new List <object>();

            sqlParams.Add(e.TaskName);
            sqlParams.Add(e.TemplateId);
            sqlParams.Add(e.StartDate);
            sqlParams.Add(e.EndDate);
            sqlParams.Add(dr["USER_ID"]);
            sqlParams.Add(dr["USER_NAME"].ToString());
            sqlParams.Add(dr["USER_ID"]);
            sqlParams.Add(e.TaskTypeId);
            sqlParams.Add(e.OrganName);
            sqlParams.Add(e.CheckScord);
            sqlParams.Add(e.Remark);
            sqlParams.Add(e.EditTaskId);
            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                // 修改任务
                if (Model.UpdateTask(trans.ID, sqlParams))
                {
                    if (e.DeleteFilesId != null)
                    {
                        // 根据文件ID删除文件
                        for (int m = 0; m < e.DeleteFilesId.Count; m++)
                        {
                            Model.DeleteFileById(trans.ID, e.DeleteFilesId[m], dr["USER_ID"].ToString());
                        }
                    }
                    if (e.FileName != null)
                    {
                        for (int i = 0; i < e.FileName.Count; i++)
                        {
                            // 插入文件表
                            Model.InsertFiles(trans.ID, e.FileName[i], e.FilePath[i], e.EditTaskId, dr["USER_ID"].ToString());
                        }
                    }
                    isSaveSuccess = true;
                }
                trans.Complete();
            }
            View.ExeIsSaveSuccess(isSaveSuccess);
        }
Esempio n. 19
0
        public void Transaction_检查事务提交是否有效_有效()
        {
            string SqlCount = @"select count(1) from temp_test";
            string count_2  = "";
            string count_1  = CJia.DefaultData.QueryScalar(SqlCount);

            using (CJia.Transaction trans = new CJia.Transaction())
            {
                string SqlInsert = @"insert into temp_test (a,b,c) values (10000,'cc',to_date('2012-12-01','YYYY-MM-DD'))";
                int    Result    = CJia.DefaultData.Execute(trans.ID, SqlInsert);
                count_2 = CJia.DefaultData.QueryScalar(trans.ID, SqlCount);
                //调用Complete后将自动提交事务
                trans.Complete();
            }
            string count_3 = CJia.DefaultData.QueryScalar(SqlCount);

            Assert.AreEqual(count_3, count_2, "事务未提交。");
            Assert.AreEqual(count_2, (Convert.ToInt32(count_1) + 1).ToString(), "未进行事务操作。");
        }
Esempio n. 20
0
        ///// <summary>
        ///// 查询文件Seq,重命名文件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //void view_OnFileSeq(object sender, Views.PublishTaskArgs e)
        //{
        //    e.FileSeq = Model.QueryFileSeq();
        //}

        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.PublishTaskArgs e)
        {
            System.Data.DataRow dr      = e.User.Rows[0];
            bool          isSaveSuccess = false;
            List <object> sqlParams     = new List <object>();
            string        taskSeq       = Model.QueryTaskSeq();

            sqlParams.Add(taskSeq);
            sqlParams.Add(e.TaskName);
            sqlParams.Add(e.TemplateId);
            sqlParams.Add(e.StartDate);
            sqlParams.Add(e.EndDate);
            sqlParams.Add(dr["USER_ID"]);
            sqlParams.Add(dr["USER_NAME"].ToString());
            sqlParams.Add(dr["USER_ID"]);
            sqlParams.Add(e.TaskType);
            sqlParams.Add(e.OrganName);
            sqlParams.Add(e.CheckScord);
            sqlParams.Add(e.Remark);
            sqlParams.Add(e.User.Rows[0]["organ_id"].ToString());
            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                // 插入任务表
                if (Model.InsertTask(trans.ID, sqlParams))
                {
                    for (int i = 0; i < e.FileName.Count; i++)
                    {
                        // 插入文件表
                        if (Model.InsertFiles(trans.ID, e.FileName[i], e.FilePath[i], taskSeq, dr["USER_ID"].ToString()))
                        {
                            isSaveSuccess = true;
                        }
                        else
                        {
                            isSaveSuccess = false;
                        }
                    }
                }
                trans.Complete();
            }
            View.ExeIsSaveSuccess(isSaveSuccess);
        }
Esempio n. 21
0
        ///// <summary>
        ///// 插入角色功能表
        ///// </summary>
        ///// <param name="roleName">角色名称</param>
        ///// <param name="listFunctionId">功能角色ID</param>
        ///// <returns></returns>
        //public bool InsertRoleFunction(string roleFunctionName,List<long> listFunctionId)
        //{
        //    bool isSuccess = false;
        //    List<object> sqlParams = new List<object>();
        //    using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
        //    {
        //        for (int i = 0; i < listFunctionId.Count; i++)
        //        {
        //            sqlParams.Add(roleFunctionName);
        //            sqlParams.Add(listFunctionId[i]);
        //            sqlParams.Add(long.Parse(User.UserData.Rows[0]["user_id"].ToString()));
        //            isSuccess = CJia.DefaultOleDb.Execute(trans.ID, SqlTools.SqlInsertRoleFunction, sqlParams) > 0 ? true : false;
        //            sqlParams.Clear();
        //        }
        //        trans.Complete();
        //    }
        //    return isSuccess;
        //}

        /// <summary>
        /// 插入角色功能表
        /// </summary>
        /// <param name="roleName">角色名称</param>
        /// <param name="listFunctionId">功能角色ID</param>
        /// <returns></returns>
        public bool InsertRoleFunction(long roleId, string roleName, List <long> listFunctionId)
        {
            bool          isSuccess = false;
            List <object> sqlParams = new List <object>();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                for (int i = 0; i < listFunctionId.Count; i++)
                {
                    sqlParams.Add(roleId);
                    sqlParams.Add(roleName);
                    sqlParams.Add(listFunctionId[i]);
                    sqlParams.Add(long.Parse(User.UserData.Rows[0]["user_id"].ToString()));
                    isSuccess = CJia.DefaultOleDb.Execute(trans.ID, SqlTools.SqlInsertRoleFunction, sqlParams) > 0 ? true : false;
                    sqlParams.Clear();
                }
                trans.Complete();
            }
            return(isSuccess);
        }
Esempio n. 22
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.AddUserArgs e)
        {
            List <object> sqlParams = new List <object>();

            if (Model.QueryIsExistSameUserNo(e.UserNo))
            {
                View.ExeMessageBox("存在相同用户名,请修改...");
                return;
            }
            string userSeq = Model.QueryUserSeq();
            //string roleSeq = Model.QueryRoleSeq();
            string createId  = e.User.Rows[0]["user_id"].ToString();
            string organId   = e.User.Rows[0]["organ_id"].ToString();
            bool   isSuccess = false;

            sqlParams.Add(userSeq);
            sqlParams.Add(e.UserNo);
            sqlParams.Add(e.UserName);
            sqlParams.Add(createId);
            sqlParams.Add(organId);
            sqlParams.Add(e.UserType);
            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                if (Model.InsertUser(trans.ID, sqlParams))
                {
                    for (int i = 0; i < e.RoleArr.Count; i++)
                    {
                        Model.InsertUserRole(trans.ID, userSeq, e.RoleArr[i], createId);
                    }

                    View.ExeMessageBox("保存成功!");
                    isSuccess = true;
                }
                trans.Complete();
            }

            if (!isSuccess)
            {
                View.ExeMessageBox("保存失败,请联系管理员...");
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 撤销审核
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnCancelCheck(object sender, Views.CheckAdviceArgs e)
        {
            int checkSeq = Model.GetCheckSeq();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                //插入审核表
                this.Model.AddCheck(trans.ID, checkSeq, User.UserId, User.UserNo, User.UserName, User.DeptId, User.DeptName, User.UserId);
                if (e.OriginalPivasStatus == 1000102)    //撤销已审
                {
                    //更新瓶贴基表
                    List <string> groupIndex = new List <string>();
                    groupIndex.Add(e.GroupIndex);
                    RefreshCommonLabel(trans.ID, groupIndex);
                }
                int detailId = Model.GetDetailIdByGroupIndex(e.GroupIndex);
                //修改审核明细
                Model.ModifyCheckDetail(trans.ID, checkSeq, e.OriginalPivasStatus, e.CheckPivasStatus, e.OriginalPivasBatchNo, e.CheckPivasBatchNo, User.UserId, e.CancelReason, detailId);
                trans.Complete();
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.EditUserArgs e)
        {
            List <object> sqlParams = new List <object>();

            if (Model.QueryIsExistSameUserNoUpdate(e.UserId, e.UserNo))
            {
                View.ExeMessageBox("存在相同用户名,请修改...", false);
                return;
            }

            string loginUserId = e.LoginUser.Rows[0]["user_id"].ToString();
            bool   isSuccess   = false;

            sqlParams.Add(e.UserNo);
            sqlParams.Add(e.UserName);
            sqlParams.Add(loginUserId);
            sqlParams.Add(e.UserId);
            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                if (Model.UpdateUser(trans.ID, sqlParams))
                {
                    Model.DeleteUserRoleByUserId(trans.ID, loginUserId, e.UserId);
                    for (int i = 0; i < e.RoleArr.Count; i++)
                    {
                        Model.InsertUserRole(trans.ID, e.UserId, e.RoleArr[i], loginUserId);
                    }

                    View.ExeMessageBox("保存成功!", true);
                    isSuccess = true;
                }
                trans.Complete();
            }
            if (!isSuccess)
            {
                View.ExeMessageBox("保存失败,请联系管理员...", false);
            }
        }
Esempio n. 25
0
        /// <summary>
        /// 删除所选择多个用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnDeletedUserArr(object sender, Views.QuerySuperviseArgs e)
        {
            string updateBy = e.User.Rows[0]["user_id"].ToString();

            // 如果删除用户中包括最高权限 则不允许删除
            for (int i = 0; i < e.DeletedUserArr.Count; i++)
            {
                if (e.DeletedUserArr[i].ToString() == "1000000001")
                {
                    // 查询此超级管理员名称
                    string userName = Model.QueryUserNameById("1000000001");
                    View.ExeMessageBox("不能删除【" + userName + "】");
                    return;
                }
            }
            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                for (int i = 0; i < e.DeletedUserArr.Count; i++)
                {
                    bool s = Model.DeleteUserById(trans.ID, updateBy, e.DeletedUserArr[i].ToString());
                }
                trans.Complete();
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.EditRoleArgs e)
        {
            bool   isSuccess = false;
            string organId   = e.User.Rows[0]["organ_id"].ToString();

            // 查询修改新名称是否在库中存在相同名称
            if (Model.QueryExistSameRoleNameWhenUpdate(e.RoleId, e.RoleName, organId))
            {
                View.ExeMessageBox("存在相同角色名称,请修改...", false);
                return;
            }
            string userId = e.User.Rows[0]["user_id"].ToString();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                // 修改角色表信息
                if (Model.UpdateRole(trans.ID, e.RoleName, userId, e.RoleId))
                {
                    // 删除该角色所有权限
                    bool a = Model.DeleteRoleFunctionByRoleId(trans.ID, e.RoleId, userId);

                    // 插入角色功能表
                    bool b = Model.InsertRoleFunction(trans.ID, e.RoleId, e.ListFunction, userId);
                    isSuccess = true;
                }
                trans.Complete();
            }
            if (isSuccess)
            {
                View.ExeMessageBox("修改成功!", true);
            }
            else
            {
                View.ExeMessageBox("修改失败,请联系管理员...", false);
            }
        }
Esempio n. 27
0
 void view_OnBtnDelete(object sender, Views.NewCancelApplyArgs e)
 {
     string barCode = e.BarCodeID;
     if (!e.barCodeList.Contains(barCode))
     {
         View.ExeDeleteReturn("不在查询的瓶贴中", false);
         return;
     }
     DataTable data = Model.GetLabelByBarCodeID(barCode);
     if (data != null)
     {
         if (data.Rows[0]["STATUS"].ToString() == "1000603")
         {
             View.ExeDeleteReturn("该瓶贴之前已作废", false);
             return;
         }
         using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
         {
             string labelID = data.Rows[0]["LABEL_ID"].ToString();
             string labelBarCodeStatus = data.Rows[0]["STATUS"].ToString();
             string labelBarCode = data.Rows[0]["LABEL_BAR_ID"].ToString();
             bool isFee = CJia.PIVAS.Models.PIVASModel.QueryCancelFeeTime(labelBarCode);
             this.Model.DelectCancelApply(trans.ID, labelID);
             bool bol4 = true;
             bool bol = true;
             bool bol2 = true;
             //if(isFee)// 产生了费用
             //{
             long cancelRCPID = Model.GetNextCancelRCPId();
             bol2 = Model.AddCancelApplyRCP(trans.ID, cancelRCPID, User.UserId.ToString(), User.UserName, User.DeptId, User.DeptName, User.HisUserId.ToString());
             bol4 = Model.AddCancelApply(trans.ID, labelID, labelBarCode, User.UserId.ToString(), User.UserName, User.DeptId, User.DeptName, " ", User.UserId.ToString(), isFee ? "1" : "0");
             string strFee = "";
             if (isFee) strFee = "1";
             else strFee = "0";
             bol = Model.ModifyCancelRCPID(trans.ID, cancelRCPID, labelID, User.UserId.ToString(), strFee, "1000303");
             //}
             bool bol1 = Model.ModifyLabelStatusByID2(trans.ID, labelID, User.UserId.ToString());
             bool bol3 = Model.ModifyBarCodeStatusByID(trans.ID, labelID, User.UserId.ToString());
             if (!bol || !bol1 || !bol2 || !bol3 || !bol4)
             {
                 View.ExeDeleteReturn("作废瓶贴失败!", false);
                 return;
             }
             if (isFee)
             {
                 int feeCount = int.Parse(data.Rows[0]["FEE_COUNT"].ToString());
                 for (int j = 0; j < data.Rows.Count; j++)
                 {
                     if (feeCount != 0)
                     {
                         string str = CJia.PIVAS.Models.PIVASModel.ExecuteAdviceIdFee(trans.ID, data.Rows[j]["HIS_ADVICE_ID"].ToString(), User.HisUserId.ToString(), Model.Sysdate(), feeCount, 1);
                         if (str != "Successed")
                         {
                             View.ExeDeleteReturn("作废瓶贴失败!" + str + "!", false);
                             return;
                         }
                     }
                 }
             }
             trans.Complete();
             View.ExeDeleteReturn("作废瓶贴成功!", true);
         }
     }
     else
     {
         View.ExeDeleteReturn("无此条形码对应的瓶贴信息!", false);
     }
 }
Esempio n. 28
0
        /// <summary>
        /// 审方通过
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnComplete(object sender, Views.CheckAdviceArgs e)
        {
            DataTable batchData = Model.GetBatchData(e.BeginListDate, e.EndListDate, e.OfficeID, e.IsValidCheck, e.IsAllCheck, e.IsNoCheck, e.IsYesCheck, e.IsTypePTY, e.IsTypeJSY, e.IsTypeDMY, e.IsTypeGCY, e.IsTypeKSS, e.CheckPivasStatus, e.CheckLong, e.CheckTemporary);

            if (batchData == null)
            {
                CJia.Message.Show("没有待审医嘱!");
            }
            else
            {
                int checkSeq = Model.GetCheckSeq();
                using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
                {
                    //插入审核表
                    this.Model.AddCheck(trans.ID, checkSeq, User.UserId, User.UserNo, User.UserName, User.DeptId, User.DeptName, User.UserId);
                    //明细表中的未审医嘱
                    DataTable noData = Model.GetCheckDetail(e.BeginListDate, e.EndListDate, e.OfficeID, e.IsValidCheck, e.IsAllCheck, e.IsNoCheck, e.IsYesCheck, e.IsTypePTY, e.IsTypeJSY, e.IsTypeDMY, e.IsTypeGCY, e.IsTypeKSS, e.CheckPivasStatus, e.CheckLong, e.CheckTemporary);
                    //明细表中的已审医嘱
                    DataTable yesData = Model.GetYesCheckDetail(e.BeginListDate, e.EndListDate, e.OfficeID, e.IsValidCheck, e.IsAllCheck, e.IsNoCheck, e.IsYesCheck, e.IsTypePTY, e.IsTypeJSY, e.IsTypeDMY, e.IsTypeGCY, e.IsTypeKSS, e.CheckPivasStatus, e.CheckLong, e.CheckTemporary);
                    if (yesData == null && noData == null)//新医嘱,未审核过
                    {
                        //插入审核明细表
                        Models.CheckResult checkResult = Model.BatchAddCheckDetail(trans.ID, checkSeq, 1000102, User.UserId, e.BeginListDate, e.EndListDate, e.OfficeID, e.IsValidCheck, e.IsAllCheck, e.IsNoCheck, e.IsYesCheck, e.IsTypePTY, e.IsTypeJSY, e.IsTypeDMY, e.IsTypeGCY, e.IsTypeKSS, e.CheckPivasStatus, e.CheckLong, e.CheckTemporary);
                        //更新瓶贴基表
                        //List<string> groupIndex = new List<string>();
                        ////DataTable batchData = Model.GetBatchData(e.BeginListDate, e.EndListDate, e.OfficeID);
                        //for(int i = 0; i < batchData.Rows.Count; i++)
                        //{
                        //    groupIndex.Add(batchData.Rows[i]["GROUP_INDEX"].ToString());
                        //}
                        RefreshCommonLabel(trans.ID, checkResult.CheckGroup);
                        this.showMes(checkResult.NoCheckGroup);
                    }
                    else
                    {
                        //DataTable batchData = Model.GetBatchData(e.BeginListDate, e.EndListDate, e.OfficeID);
                        if (batchData != null)
                        {
                            Models.CheckResult checkResult = new Models.CheckResult();
                            for (int i = 0; i < batchData.Rows.Count; i++)
                            {
                                List <string> result = this.Model.QueryPharm(batchData.Rows[i]["GROUP_INDEX"].ToString());
                                if (result != null && result.Count > 0)
                                {
                                    checkResult.NoCheckGroup.Add(new Models.NoCheckGroupPharm()
                                    {
                                        GroupIndex = batchData.Rows[i]["GROUP_INDEX"].ToString(),
                                        pharmList  = result
                                    });
                                }
                                else
                                {
                                    //将之前审核明细置为无效
                                    //int detailId = Model.GetDetailIdByGroupIndex(batchData.Rows[i]["GROUP_INDEX"].ToString());
                                    //Model.ModifyCheckDetailValid(trans.ID, User.UserId, detailId);
                                    this.Model.ModifyCheckDetailGroupIndex(trans.ID, batchData.Rows[i]["GROUP_INDEX"].ToString(), User.UserId);
                                    //插入新的审核明细
                                    Model.AddCheckDetail(trans.ID, checkSeq, batchData.Rows[i]["GROUP_INDEX"].ToString(), 1000101, 1000102, e.OriginalPivasBatchNo, batchData.Rows[i]["CHECK_PIVAS_BATCH_NO"].ToString(), User.UserId, e.CancelReason, e.LongTimeStatus);
                                    //更新瓶贴基表
                                    List <string> groupIndex = new List <string>();
                                    groupIndex.Add(batchData.Rows[i]["GROUP_INDEX"].ToString());
                                    RefreshCommonLabel(trans.ID, groupIndex);
                                    checkResult.CheckGroup.Add(batchData.Rows[i]["GROUP_INDEX"].ToString());
                                }
                            }
                            this.showMes(checkResult.NoCheckGroup);
                        }
                        ////将之前审核明细批量置为无效
                        //Model.ModifyCheckDetail(trans.ID, User.UserId, e.BeginListDate, e.EndListDate, e.OfficeID, groupIndex);
                        ////插入新的审核明细
                        //Model.BatchAddCheckDetail(trans.ID, checkSeq, e.CheckPivasStatus, User.UserId, e.BeginListDate, e.EndListDate, e.OfficeID, batchStr);
                        ////更新瓶贴基表
                        //RefreshCommonLabel(trans.ID, groupIndex);
                    }
                    trans.Complete();
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        /// 单个审方
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnInsertCheck(object sender, Views.CheckAdviceArgs e)
        {
            int checkSeq = Model.GetCheckSeq();

            using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
            {
                Models.CheckResult checkResult = new Models.CheckResult();
                //插入审核表
                this.Model.AddCheck(trans.ID, checkSeq, User.UserId, User.UserNo, User.UserName, User.DeptId, User.DeptName, User.UserId);
                //判断是否在明细表
                DataTable data = Model.GetCheckDetailDataByGroupIndex(e.GroupIndex);
                if (data == null)//新医嘱,未审核过
                {
                    List <string> pharmList = this.Model.QueryPharm(e.GroupIndex);
                    if (pharmList != null && pharmList.Count > 0)
                    {
                        checkResult.NoCheckGroup.Add(new Models.NoCheckGroupPharm()
                        {
                            GroupIndex = e.GroupIndex,
                            pharmList  = pharmList
                        });
                    }
                    else
                    {
                        //插入审核明细表
                        Model.AddCheckDetail(trans.ID, checkSeq, e.GroupIndex, e.OriginalPivasStatus, e.CheckPivasStatus, e.OriginalPivasBatchNo, e.CheckPivasBatchNo, User.UserId, e.CancelReason, e.LongTimeStatus);
                        //更新瓶贴基表
                        List <string> groupIndex = new List <string>();
                        groupIndex.Add(e.GroupIndex);
                        RefreshCommonLabel(trans.ID, groupIndex);
                        checkResult.CheckGroup.Add(e.GroupIndex);
                    }
                }
                else
                {
                    List <string> pharmList = this.Model.QueryPharm(e.GroupIndex);
                    if (pharmList != null && pharmList.Count > 0)
                    {
                        checkResult.NoCheckGroup.Add(new Models.NoCheckGroupPharm()
                        {
                            GroupIndex = e.GroupIndex,
                            pharmList  = pharmList
                        });
                    }
                    else
                    {
                        //将之前审核明细置为无效
                        //int detailId = Model.GetDetailIdByGroupIndex(e.GroupIndex);
                        //Model.ModifyCheckDetailValid(trans.ID, User.UserId, detailId);
                        this.Model.ModifyCheckDetailGroupIndex(trans.ID, e.GroupIndex, User.UserId);
                        //插入新的审核明细
                        Model.AddCheckDetail(trans.ID, checkSeq, e.GroupIndex, e.OriginalPivasStatus, e.CheckPivasStatus, e.OriginalPivasBatchNo, e.CheckPivasBatchNo, User.UserId, e.CancelReason, e.LongTimeStatus);
                        //更新瓶贴基表
                        List <string> groupIndex = new List <string>();
                        groupIndex.Add(e.GroupIndex);
                        RefreshCommonLabel(trans.ID, groupIndex);
                        checkResult.CheckGroup.Add(e.GroupIndex);
                    }
                }
                this.showMes(checkResult.NoCheckGroup);
                trans.Complete();
            }
        }
Esempio n. 30
0
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_OnSave(object sender, Views.AddSuperviseArgs e)
        {
            List <object> sqlParams = new List <object>();

            if (Model.QueryIsExistSameUserNo(e.UserNo))
            {
                View.ExeMessageBox("存在相同用户名,请修改...");
                return;
            }
            string createBy  = e.User.Rows[0]["user_id"].ToString();
            bool   isSuccess = false;
            // 用户表Seq
            string userSeq = Model.QueryUserSeq();
            // 角色表Seq
            string roleSeq = Model.QueryRoleSeq();

            sqlParams.Add(userSeq);
            sqlParams.Add(e.UserNo);
            sqlParams.Add(e.UserName);
            sqlParams.Add(createBy);
            sqlParams.Add(e.OrganId);
            sqlParams.Add(e.UserType);
            // 如果不是超级管理员(即普通管理员)
            if (!e.IsCheckSupper)
            {
                using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
                {
                    // 普通管理员自动为其创建一个名叫“管理员”的角色名
                    string roleName = "管理员";
                    // 插入用户表
                    if (Model.InsertUser(trans.ID, sqlParams))
                    {
                        // 插入角色表
                        if (Model.InsertRole(trans.ID, roleSeq, roleName, createBy, e.OrganId, e.RoleType))
                        {
                            // 插入用户角色表
                            if (Model.InsertUserRole(trans.ID, userSeq, roleSeq, createBy))
                            {
                                // 插入角色功能表
                                Model.InsertRoleFunction(trans.ID, roleSeq, e.ListFunction, createBy);
                                View.ExeMessageBox("保存成功!");
                                isSuccess = true;
                            }
                        }
                    }
                    trans.Complete();
                }
            }
            // 超级管理员
            else
            {
                using (CJia.Transaction trans = new CJia.Transaction(CJia.DefaultOleDb.DefaultAdapter))
                {
                    if (Model.InsertUser(trans.ID, sqlParams))
                    {
                        // 如果不存在超级管理员角色
                        if (Model.QueryExistSuperRole())
                        {
                            // 创建超级管理员角色
                            if (Model.InsertRole(trans.ID, "1000000001", "超级管理员", createBy, "360000", "0"))
                            {
                                List <string> superFun = new List <string>();
                                superFun.Add("10");
                                superFun.Add("43");
                                superFun.Add("44");
                                // 往角色功能表插入超级管理员的角色功能
                                if (Model.InsertRoleFunction(trans.ID, "1000000001", superFun, createBy))
                                {
                                    if (Model.InsertUserRole(trans.ID, userSeq, "1000000001", createBy))
                                    {
                                        View.ExeMessageBox("保存成功!");
                                        isSuccess = true;
                                    }
                                }
                            }
                        }
                        // 如果存在超级管理员角色
                        else
                        {
                            if (Model.InsertUserRole(trans.ID, userSeq, "1000000001", createBy))
                            {
                                View.ExeMessageBox("保存成功!");
                                isSuccess = true;
                            }
                        }
                    }
                    trans.Complete();
                }
            }

            if (!isSuccess)
            {
                View.ExeMessageBox("保存失败,请联系管理员...");
            }
        }