public object DeleteData(string uid) { var tran = Utility.Database.BeginDbTransaction(); try { if (!string.IsNullOrEmpty(uid)) { #region 李总代码 //删除用户表 UserInfo _userinfo = new UserInfo(); DataRowMap rm = new DataRowMap(); rm.TableName = "FX_UserInfo"; rm.Fields.Add(new FieldInfo("EnName", null)); rm.Fields.Add(new FieldInfo("DPID", null)); rm.Fields.Add(new FieldInfo("UIConfig", null)); rm.Fields.Add(new FieldInfo("PortalConfig", null)); rm.Fields.Add(new FieldInfo("RankID", null)); rm.Condition.Add("UserID=" + uid); Utility.Database.Update(rm, tran); //删角色 RoleUserR _roleuserr = new RoleUserR(); _roleuserr.Condition.Add("UserID=" + uid); Utility.Database.Delete<RoleUserR>(_roleuserr, tran); //删用户权限组对应关系 UserGroupR usergroupr = new UserGroupR(); usergroupr.Condition.Add("UserID=" + uid); Utility.Database.Delete<UserGroupR>(usergroupr, tran); //删用户和权限直接对应表 UserPrivilegeR userprivileger = new UserPrivilegeR(); userprivileger.Condition.Add("UserID=" + uid); Utility.Database.Delete<UserPrivilegeR>(userprivileger, tran); //用户关联信息表 FX_UserInfo_Add userAdd = new FX_UserInfo_Add(); userprivileger.Condition.Add("UID=" + uid); Utility.Database.Delete<FX_UserInfo_Add>(userAdd, tran); #endregion Utility.Database.Commit(tran); } return new { }; } catch (Exception ex) { Utility.Database.Rollback(tran); ComBase.Logger(ex); //写异常日志到本地文件夹 throw (new Exception("获取数据失败!", ex)); } }
public object EdtiParent(string id, string parentId) { var tran = Utility.Database.BeginDbTransaction(); try { DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_FileType"; rm.Condition.Add("FileTypeId=" + id); rm.Fields.Add(new FieldInfo("ParentId", parentId)); Utility.Database.Update(rm); return new { }; } catch (Exception ex) { Utility.Database.Rollback(tran); throw (new Exception("保存数据失败!错误:" + ex.Message, ex)); } }
public object UpdateRank(string JsonData) { var tran = Utility.Database.BeginDbTransaction(); try { List<RankModel> rankList = (List<RankModel>)JsonConvert.DeserializeObject(JsonData, typeof(List<RankModel>)); for (int i = 0; i < rankList.Count; i++) { DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_FileType"; rm.Condition.Add("FileTypeId=" + rankList[i].id); rm.Fields.Add(new FieldInfo("RankID", rankList[i].rankId)); Utility.Database.Update(rm, tran); } Utility.Database.Commit(tran); return new { }; } catch (Exception ex) { Utility.Database.Rollback(tran); throw (new Exception("保存数据失败!错误:" + ex.Message, ex)); } }
public string DeleteFileType(string JsonData, string userid) { var tran = Utility.Database.BeginDbTransaction(); StringBuilder strSql = new StringBuilder(); try { //删除文档分类目录,包括它所有的下级菜单 B_OA_FileType fileType = JsonConvert.DeserializeObject<B_OA_FileType>(JsonData); if (!string.IsNullOrEmpty(fileType.flagType)) { throw (new Exception("删除失败:不可删除此字段,删除后会影响系统正常运行!")); } //查找子类 listSon = new List<B_OA_FileType>(); listSon.Add(fileType); GetFileSonList(fileType, tran); string d = ""; for (var i = 0; i < listSon.Count; i++) { if (i == (listSon.Count - 1)) { d = d + "'" + listSon[i].FileTypeId + "'"; } else { d = d + "'" + listSon[i].FileTypeId + "'" + ","; } } strSql.AppendFormat("delete B_OA_FileType where 1=1 and FileTypeId in ({0})", d); Utility.Database.ExecuteNonQuery(strSql.ToString(), tran); strSql.Clear(); strSql.AppendFormat("select Count(*) from B_OA_FileType where ParentId = '{0}'", fileType.ParentId); DataSet dataSet = Utility.Database.ExcuteDataSet(strSql.ToString(), tran); int count = int.Parse(dataSet.Tables[0].Rows[0][0].ToString()); if (count == 0) { DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_FileType"; rm.Condition.Add("FileTypeId=" + fileType.ParentId); rm.Fields.Add(new FieldInfo("isParent", false)); Utility.Database.Update(rm, tran); } Utility.Database.Commit(tran); return Utility.JsonMsg(true, "删除成功 "); ; //将对象转为json字符串并返回到客户端 } catch (Exception e) { Utility.Database.Rollback(tran); throw (new Exception("删除失败:" + e.Message)); ; //将对象转为json字符串并返回到客户端 } }
public void Insert_B_OA_WorkFlow_UserId_R(string travelIds, string caseId, IDbTransaction tran) { DateTime datetime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); if (!String.IsNullOrEmpty(caseId)) { DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_WorkFlow_UserId_R"; rm.Condition.Add("caseId=" + caseId); Utility.Database.Delete(rm, tran); string[] array = travelIds.Split(';'); for (int i = 0; i < array.Length - 1; i++) { DataRowMap add = new DataRowMap(); add.TableName = "B_OA_WorkFlow_UserId_R"; add.Fields.Add(new FieldInfo("userid", array[i])); add.Fields.Add(new FieldInfo("caseId", caseId)); add.Fields.Add(new FieldInfo("datetime", datetime)); Utility.Database.Insert(add, tran); } } }
/// <summary> /// 删除数据 /// </summary> /// <param name="tableName">表名</param> /// <param name="columnName">列名</param> /// <param name="id">主键</param> /// <param name="tran">事务</param> public static void DeleteData(string tableName, string columnName, string id, IDbTransaction tran) { DataRowMap rm = new DataRowMap(); rm.TableName = tableName; rm.Condition.Add(columnName + "=" + id); Utility.Database.Delete(rm, tran); }
public bool DeleteCase(string caseid, string userid, Object obj) { IDbTransaction tran = (IDbTransaction)obj; //加入针对不同的业务的删除前处理 FX_WorkFlowCase workFlow = new FX_WorkFlowCase(); workFlow.Condition.Add("ID =" + caseid); workFlow = Utility.Database.QueryObject<FX_WorkFlowCase>(workFlow, tran); if (workFlow != null) { string flowId = workFlow.FlowID; switch (flowId) { case "W000098": //发文 B_OA_SendDoc_QuZhan sendDoc = new B_OA_SendDoc_QuZhan(); sendDoc.Condition.Add("caseid=" + caseid); Utility.Database.Delete(sendDoc, tran); break; case "W000099": //收文 B_OA_ReceiveDoc_QuZhan receiveDoc = new B_OA_ReceiveDoc_QuZhan(); receiveDoc.Condition.Add("caseid=" + caseid); Utility.Database.Delete(receiveDoc, tran); break; case "W000100": //内部事项 B_OA_SendDoc_Inner_QuZhan innderDoc = new B_OA_SendDoc_Inner_QuZhan(); innderDoc.Condition.Add("caseId=" + caseid); Utility.Database.Delete(innderDoc, tran); break; case "W000070": //车辆申请 B_OA_Car car = new B_OA_Car(); car.Condition.Add("workflowcaseid=" + caseid); Utility.Database.Delete(car, tran); break; case "W000071": //会议申请 B_OA_Meeting data = new B_OA_Meeting(); data.Condition.Add("CaseID=" + caseid); Utility.Database.Delete(data, tran); break; case "W000079": //请假申请 B_OA_LeaveList leave = new B_OA_LeaveList(); leave.Condition.Add("caseId=" + caseid); Utility.Database.Delete(leave, tran); break; case "W000080": //出差申请 B_OA_TravelList travel = new B_OA_TravelList(); travel.Condition.Add("caseId=" + caseid); Utility.Database.Delete(travel, tran); break; case "W000089": //通知公告 B_OA_Notice notice = new B_OA_Notice(); notice.Condition.Add("caseid=" + caseid); Utility.Database.Delete(notice, tran); break; case "W000102": //采购申请 B_OA_FixedAssets fiexAssets = new B_OA_FixedAssets(); fiexAssets.Condition.Add("caseId ="+caseid); Utility.Database.Delete(fiexAssets, tran); B_OA_FixedAssets_Son fixedAssetsSon = new B_OA_FixedAssets_Son(); fixedAssetsSon.Condition.Add("caseId = "+caseid); Utility.Database.Delete(fixedAssetsSon, tran); break; } if (!string.IsNullOrEmpty(caseid)) { //删除正文路径 B_Common_CreateDoc createDoc = new B_Common_CreateDoc(); createDoc.Condition.Add("caseid=" + caseid); Utility.Database.Delete(createDoc, tran); //删除附件 FX_AttachMent attach = new FX_AttachMent(); attach.Condition.Add("CaseID="+caseid); Utility.Database.Delete(attach, tran); //用户和业务关系表 DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_WorkFlow_UserId_R"; rm.Condition.Add("caseId=" + caseid); Utility.Database.Delete(rm, tran); //业务数据 FX_WorkFlowBusAct workFlowBust = new FX_WorkFlowBusAct(); workFlowBust.Condition.Add("CaseID=" + caseid); Utility.Database.Delete(workFlowBust, tran); } } return true; }
public object SaveData(string json, string userid) { var tran = Utility.Database.BeginDbTransaction(); try { FX_UserInfo_Add userInforAdd = JsonConvert.DeserializeObject<FX_UserInfo_Add>(json); if (string.IsNullOrEmpty(userInforAdd.UserID)) { #region 李总源码 UserInfo insertObj = new UserInfo(); string New_UserID = Utility.MaxValue<UserInfo>("U", 6); { UserInfo user = new UserInfo(); user.Condition.Add("UserID=" + New_UserID); UserInfo findUser = Utility.Database.QueryObject<UserInfo>(user); if (findUser != null) throw new Exception("出现重复UserID,系统异常请及时联系管理员"); } insertObj.DPID = userInforAdd.DPID; insertObj.UserID = New_UserID; insertObj.EnName = userInforAdd.EnName; insertObj.PWD = userInforAdd.PWD; insertObj.CnName = userInforAdd.CnName; if (!string.IsNullOrEmpty(userInforAdd.RankID)) { insertObj.RankID = userInforAdd.RankID; } else { insertObj.RankID ="0"; } Utility.Database.Insert<UserInfo>(insertObj, tran); #endregion //用户表附加信息表 userInforAdd.UID = New_UserID; Utility.Database.Insert<FX_UserInfo_Add>(userInforAdd, tran); } else { #region 李总源码 if (userInforAdd.UserID == IWorkPrivilegeManage.AdminID) return Utility.JsonMsg(false, "顶级管理员不能编辑"); UserInfo _userinfo = new UserInfo(); _userinfo.Condition.Add("UserID=" + userInforAdd.UserID); UserInfo _user = Utility.Database.QueryObject(_userinfo); DataRowMap rm = new DataRowMap(); rm.TableName = "FX_UserInfo"; rm.Condition.Add("UserID=" + userInforAdd.UserID); rm.Fields.Add(new FieldInfo("PWD", userInforAdd.PWD)); rm.Fields.Add(new FieldInfo("EnName", userInforAdd.EnName)); rm.Fields.Add(new FieldInfo("CnName", userInforAdd.CnName)); rm.Fields.Add(new FieldInfo("DPID", userInforAdd.DPID)); rm.Fields.Add(new FieldInfo("Phone", userInforAdd.Phone)); if (!string.IsNullOrEmpty(userInforAdd.RankID)) { rm.Fields.Add(new FieldInfo("RankID", userInforAdd.RankID)); } else { rm.Fields.Add(new FieldInfo("RankID","0")); } //if (_user.DPID != userInforAdd.DPID) rm.Fields.Add(new FieldInfo("RankID", null)); Utility.Database.Update(rm, tran); #endregion FX_UserInfo_Add userInfor = new FX_UserInfo_Add(); userInfor.Condition.Add("UID = " + userInforAdd.UserID); userInfor = Utility.Database.QueryObject<FX_UserInfo_Add>(userInfor, tran); if (userInfor == null) { userInforAdd.UID = userInforAdd.UserID; Utility.Database.Insert(userInforAdd, tran); } else { userInforAdd.Condition.Add("UID=" + userInforAdd.UID); Utility.Database.Update(userInforAdd, tran); } } Utility.Database.Commit(tran); bool b = true; return new { b = b }; } catch (Exception ex) { Utility.Database.Rollback(tran); ComBase.Logger(ex); //写异常日志到本地文件夹 throw (new Exception("获取数据失败!", ex)); } }
public void SaveData(GetDataModel data, IDbTransaction tran, string caseId, string userid) { if (caseId != null) data.baseInfor_Notice.caseid = caseId; data.baseInfor_Notice.Condition.Add("caseid=" + caseId); B_OA_Notice en = Utility.Database.QueryObject<B_OA_Notice>(data.baseInfor_Notice); if (en == null) { //插入文章关系表 B_OA_Notice_FileType_R fileType_R = new B_OA_Notice_FileType_R(); fileType_R.noticeId = data.baseInfor_Notice.NewsId; fileType_R.fileTypeId = ComDocumentCenterOperate.GetFileTypeByFlayType("4", tran).FileTypeId; Utility.Database.Insert(fileType_R, tran); Utility.Database.Insert(data.baseInfor_Notice, tran); if (data.baseInfor_Notice.publicRange == 1) { DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_Notice_Range_R"; rm.Fields.Add(new FieldInfo("newsId", data.baseInfor_Notice.NewsId)); rm.Fields.Add(new FieldInfo("userid", data.baseInfor_Notice.CreaterId)); Utility.Database.Insert(rm, tran); } } else { if (data.baseInfor_Notice.publicRange==1) { DataRowMap rm_d = new DataRowMap(); rm_d.TableName = "B_OA_Notice_Range_R"; rm_d.Condition.Add("newsId =" + data.baseInfor_Notice.NewsId); Utility.Database.Delete(rm_d, tran); DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_Notice_Range_R"; rm.Fields.Add(new FieldInfo("newsId", data.baseInfor_Notice.NewsId)); rm.Fields.Add(new FieldInfo("userid", data.baseInfor_Notice.CreaterId)); Utility.Database.Insert(rm, tran); } Utility.Database.Update(data.baseInfor_Notice, tran); } //将指定人员查看存入关系表中 if (data.baseInfor_Notice.publicRange == 1) { InserAppointManSee(data.baseInfor_Notice, tran); } }
public string SaveUserInfo(string UserID, string PWD, string EnName, string CnName, string DPID, string Phone) { try { if (UserID == IWorkPrivilegeManage.AdminID) return PackResult.JsonMsg(false, "顶级管理员不能编辑"); UserInfo _userinfo = new UserInfo(); _userinfo.Condition.Add("UserID=" + UserID); UserInfo _user = Utility.Database.QueryObject(_userinfo); DataRowMap rm = new DataRowMap(); rm.TableName = "FX_UserInfo"; rm.Condition.Add("UserID=" + UserID); rm.Fields.Add(new FieldInfo("PWD", PWD)); rm.Fields.Add(new FieldInfo("EnName", EnName)); rm.Fields.Add(new FieldInfo("CnName", CnName)); rm.Fields.Add(new FieldInfo("DPID", DPID)); rm.Fields.Add(new FieldInfo("Phone", Phone)); if (_user.DPID != DPID) rm.Fields.Add(new FieldInfo("RankID", null)); Utility.Database.Update(rm); return PackResult.JsonMsg(true, "添加成功"); } catch (Exception e) { return PackResult.JsonMsg(false, "SaveUserInfo失败"); } }
public string EditDepartment(string DPID, string DPName) { try { DataRowMap rm = new DataRowMap(); rm.TableName = "FX_Department"; rm.Condition.Add("DPID=" + DPID); rm.Fields.Add(new FieldInfo("DPName", DPName)); Utility.Database.Update(rm); return PackResult.JsonMsg(true, null); } catch (Exception) { return PackResult.JsonMsg(false, "EditDepartment失败"); } }
public string Send(string BizParams, string userid, string content) { IDbTransaction tran = Utility.Database.BeginDbTransaction(); SkyLandDeveloper developer = new SkyLandDeveloper(BizParams, userid, tran); try { SaveDataModel data = JsonConvert.DeserializeObject<SaveDataModel>(content); StringBuilder strSql = new StringBuilder(); strSql.Append(@"SELECT MeetingName,StartTime,EndTime, B.CnName FROM B_OA_Meeting A LEFT JOIN FX_UserInfo B ON A.OrganizID = B. UserID WHERE MeetingID <> " + data.baseInfo.MeetingID + " AND MeetingRoomID = " + data.baseInfo.MeetingRoomID + " AND(('" + data.baseInfo.StartTime + "' Between StartTime and EndTime)OR ('" + data.baseInfo.EndTime + "' Between StartTime and EndTime))"); DataTable table = Utility.Database.ExcuteDataSet(strSql.ToString()).Tables[0]; if (table.Rows.Count > 0) return Utility.JsonMsg(false, "时间:" + table.Rows[0]["StartTime"].ToString() + " 至 " + table.Rows[0]["EndTime"].ToString() + "\n申请人:" + table.Rows[0]["CnName"].ToString()); string caseid = developer.caseid; if (String.IsNullOrEmpty(caseid)) { string titleType = "会议室申请"; developer.caseName = data.baseInfo.MeetingName + "-" + titleType; caseid = developer.Create(); data.baseInfo.Applicant = userid; data.baseInfo.CreatTime = DateTime.Now.ToString(); } if (developer.wfcase.actid == "A002") { data.baseInfo.Approver = userid; data.baseInfo.ApprovalTime = DateTime.Now.ToString(); data.baseInfo.Status = 1; DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_WorkFlow_UserId_R"; rm.Condition.Add("caseId=" + caseid); Utility.Database.Delete(rm, tran); string[] array = data.baseInfo.ParticipantNameid.Split(';'); for (int i = 0; i < array.Length - 1; i++) { DataRowMap add = new DataRowMap(); add.TableName = "B_OA_WorkFlow_UserId_R"; add.Fields.Add(new FieldInfo("userid", array[i])); add.Fields.Add(new FieldInfo("caseId", caseid)); add.Fields.Add(new FieldInfo("datetime", DateTime.Now.ToString())); Utility.Database.Insert(add, tran); } } SaveData(data, tran, caseid); developer.Send(); developer.Commit(); return Utility.JsonMsg(true, "发送成功!"); } catch (Exception ex) { developer.RollBack(); ComBase.Logger(ex); return Utility.JsonMsg(false, "发送失败:" + ex.Message.Replace(":", " ")); } }
/// <summary> /// 出差人员关系表 /// </summary> /// <param name="travelIds">出差人员</param> /// <param name="caseId"></param> /// <param name="tran"></param> public void SaveTravelRaletive(string travelIds, string caseId, IDbTransaction tran) { if (!String.IsNullOrEmpty(caseId)) { DataRowMap rm = new DataRowMap(); rm.TableName = "B_OA_WorkFlow_UserId_R"; rm.Condition.Add("caseId=" + caseId); Utility.Database.Delete(rm, tran); string[] array = travelIds.Split(';'); for (int i = 0; i < array.Length - 1; i++) { DataRowMap add = new DataRowMap(); add.TableName = "B_OA_WorkFlow_UserId_R"; add.Fields.Add(new FieldInfo("userid", array[i])); add.Fields.Add(new FieldInfo("caseId", caseId)); Utility.Database.Insert(add, tran); } } }