public override DbCommand CreateSelectRangeCommand(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn, bool identyColumnIsNumber) { Check.Require(((object)where) != null && where.From != null, "expr and expr.From could not be null!"); Check.Require(columns != null && columns.Length > 0, "columns could not be null or empty!"); Check.Require(topCount > 0, "topCount must > 0!"); if (string.IsNullOrEmpty(where.OrderBy) && identyColumn != null) { where.SetOrderBy(new KeyValuePair<string,bool>[] { new KeyValuePair<string,bool>(identyColumn, false) }); } if (topCount == int.MaxValue && skipCount == 0) { return CreateSelectCommand(where, columns); } else if (skipCount == 0) { return CreateSelectTopCommand(where, columns, topCount); } else { Check.Require(!string.IsNullOrEmpty(identyColumn), "identyColumn could not be null or empty!"); identyColumn = ColumnFormatter.ValidColumnName(identyColumn); if (identyColumnIsNumber && where.OrderByStartsWith(identyColumn) && (string.IsNullOrEmpty(where.GroupBy) || where.GroupBy == identyColumn)) { return CreateSelectRangeCommandForSortedRows(where, columns, topCount, skipCount, identyColumn, where.OrderByStartsWith(identyColumn + " DESC")); } else { return CreateSelectRangeCommandForUnsortedRows(where, columns, topCount, skipCount, identyColumn); } } }
public string getVideoNav() { string res = string.Empty; string lb = Request.QueryString.Get("sid"); string newsid = Request.QueryString.Get("id"); videoManager mgr = new videoManager(); if (!string.IsNullOrEmpty(newsid)) { WhereClip where = new WhereClip(); where = where && video._.id == newsid; video model = new video(); model = mgr.GetvideoItemById(where); if (model != null) { lb = model.sid.ToString(); } } if (!string.IsNullOrEmpty(lb)) { videoclass modelclass = new videoclass(); WhereClip where2 = new WhereClip(); where2 = where2 && videoclass._.id == lb; modelclass = mgr.GetItemById(where2); res = string.Format(@"<a href='Category.aspx?type=video'>视频频道</a> > <a href='Category.aspx?sid={0}&type=video'>{1}</a>", modelclass.id, modelclass.classname); } else { res = "<a href='Category.aspx?type=video'>视频频道</a>"; } return res; }
public override DbCommand CreateSelectRangeCommand(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn, bool identyColumnIsNumber) { Check.Require(((object)where) != null && where.From != null, "expr and expr.From could not be null!"); Check.Require(columns != null && columns.Length > 0, "columns could not be null or empty!"); Check.Require(topCount > 0, "topCount must > 0!"); if (string.IsNullOrEmpty(where.OrderBy) && identyColumn != null) { where.SetOrderBy(new KeyValuePair<string,bool>[] { new KeyValuePair<string,bool>(identyColumn, false) }); } if (topCount == int.MaxValue && skipCount == 0) { return CreateSelectCommand(where, columns); } else { DbCommand cmd = CreateSelectCommand(where, columns); if (skipCount == 0) { cmd.CommandText += " LIMIT " + topCount; } else { cmd.CommandText += " LIMIT " + skipCount; cmd.CommandText += "," + topCount; } return cmd; } }
protected virtual DbCommand CreateSelectRangeCommandForSortedRows(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn, bool isIdentyColumnDesc) { DbCommand cmd = fac.CreateCommand(); cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder("SELECT "); if (topCount < int.MaxValue) { sb.Append("TOP "); sb.Append(topCount); sb.Append(' '); } for (int i = 0; i < columns.Length; ++i) { SqlQueryUtils.AppendColumnName(sb, columns[i]); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(" FROM "); WhereClip cloneWhere = (WhereClip)where.Clone(); #region Construct & extend CloneWhere StringBuilder sbInside = new StringBuilder(); sbInside.Append(identyColumn); sbInside.Append(" NOT IN (SELECT TOP "); sbInside.Append(skipCount); sbInside.Append(' '); sbInside.Append(identyColumn); sbInside.Append(" FROM "); sbInside.Append(where.ToString()); sbInside.Append(")"); if (cloneWhere.Sql.Length == 0) { cloneWhere.Sql = sbInside.ToString(); } else { cloneWhere.Sql = "(" + cloneWhere.Sql.ToString() + ") AND " + sbInside.ToString(); } #endregion sb.Append(cloneWhere.ToString()); AddExpressionParameters(where, cmd); AddExpressionParameters(cloneWhere, cmd); cmd.CommandText = SqlQueryUtils.ReplaceDatabaseTokens(sb.ToString(), leftToken, rightToken, paramPrefixToken, wildcharToken, wildsinglecharToken); PrepareCommand(cmd); return cmd; }
/// <summary> /// �����û�ӵ�е��� /// </summary> /// <param name="Userid"></param> /// <returns></returns> public List<cachetList> GetByUserid(object prmUsID) { WhereClip where = new WhereClip(); where.Sql = "clUsids like '%" + prmUsID.ToString() + ",%'"; List<cachetList> lists = new List<cachetList>(); lists.AddRange(db.FindArray<cachetList>(where)); return lists; }
public DataTable GetDataTable(WhereClip where) { return Dal.From<DayLog>().Where(where).OrderBy(DayLog._.CreateDate.Desc) .Select( DayLog._.UserName.Alias("填报人"), DayLog._.WordDate.Alias("日志日期"), DayLog._.Content.Alias("工作内容"), DayLog._.GS.Alias("工时"), DayLog._.CreateDate.Alias("填报日期")) .ToDataTable(); }
/// <summary> /// 根据条件获取待办任务 /// </summary> /// <param name="p"></param> /// <param name="pageSize"></param> /// <param name="where"></param> /// <param name="orderByClip"></param> /// <param name="count"></param> /// <param name="recordCount"></param> /// <returns></returns> public DataTable GetDaiBanDataTable(int pageindex, int pagesize, WhereClip where, OrderByClip orderby, ref int pageCount, ref int recordCount) { WhereClip appendwhere = new WhereClip(); appendwhere.Append(" ( HandSequence= (select max(HandSequence) from WorkHandLog where [WorkID]=[WorkInfo].[ID]))"); return Dal.From<WorkHandLog>().Join<WorkInfo>(WorkInfo._.ID == WorkHandLog._.WorkID && appendwhere, JoinType.leftJoin) .Join<ShebeiInfo>(ShebeiInfo._.ID == WorkInfo._.SbID, JoinType.leftJoin) .Where(where && ShebeiInfo._.State != "正常").OrderBy(orderby) .Select(WorkHandLog._.ID.All, WorkInfo._.SbID, WorkInfo._.Address, WorkInfo._.ChuLiYiJian , WorkInfo._.CreaterName, WorkInfo._.CurrentUser, WorkInfo._.Guzhang, WorkInfo._.GuZhangXx , WorkInfo._.Note, WorkInfo._.PlanTime, WorkInfo._.RealTime, WorkInfo._.Status , WorkInfo._.Tel, WorkInfo._.City, WorkInfo._.Xian, WorkInfo._.Zhen , ShebeiInfo._.Code, ShebeiInfo._.Name, ShebeiInfo._.GuiGe, ShebeiInfo._.Note.Alias("SheBeiNote")) .ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; ShebeiInfoManager manager = new ShebeiInfoManager(); int pageNum = int.Parse(context.Request.QueryString.Get("pagenum")); int pagesize = int.Parse(context.Request.QueryString.Get("pagesize")); int recordCount = 0; WhereClip where = new WhereClip(); if (!string.IsNullOrEmpty(context.Request["status"])) { where = ShebeiInfo._.State == context.Request["status"]; } string filter = context.Request["filtervalue0"]; //获取当前用户的部们 if (context.Session["AllDepart"] != null) { List<AdministrativeRegions> list = context.Session["AllDepart"] as List<AdministrativeRegions>; if (list != null && list.Count > 0) { string[] dparr = new string[list.Count]; for (int i = 0; i < list.Count; i++) { dparr[i] = list[i].ID.ToString(); } where = where && ShebeiInfo._.SocrceDepart.In(dparr); } } if (!string.IsNullOrEmpty(filter)) { filter = filter.Trim(); where = where && (ShebeiInfo._.Code.Contains(filter) || ShebeiInfo._.Name.Contains(filter) || ShebeiInfo._.Address.Contains(filter)); } DataTable dt = manager.GetDataTable(pageNum + 1, pagesize, where, ref pagesize, ref recordCount); //manager.GetDataTable(); string result = JsonConvert.Convert2Json(dt); context.Response.Write("{\"total\":\"" + recordCount.ToString() + "\",\"rows\":" + result + "}"); context.Response.End(); }
/// <summary> /// 分页获取获取设备信息表datatable /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetDataTable(int pageindex, int pagesize, WhereClip where, string orderby, ref int pageCount, ref int recordCount) { return Dal.From<NoticeInfo>().Where(where).OrderBy(new OrderByClip(orderby)).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(FIN_SubmitExpenseResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (string.IsNullOrEmpty(param.SourceBillNo)) { throw new WarnException("请选择关联单号!"); } if (string.IsNullOrEmpty(param.ExpName)) { throw new WarnException("请填写报销标题!"); } if (string.IsNullOrEmpty(param.OpEmpName)) { throw new WarnException("请选择处理人!"); } #endregion #region 系统默认值 List <FIN_SubmitExpenseLineResult> expenseLineList = param.ExpenseLineList; if (param.ExpID.ToInt32() > 0) { WhereClip where = FIN_SubmitExpense._.ExpID == param.ExpID; param.GCompanyGuID = this.SessionInfo.CompanyID; param.UpdatedEmpID = this.SessionInfo.UserID; param.UpdatedEmpName = this.SessionInfo.UserName; param.UpdatedTime = DateTime.Now; affect = this.Update <FIN_SubmitExpenseResult>(param, where); } else { Sys_CodeRulerBLL codeRulerBll = new Sys_CodeRulerBLL(); codeRulerBll.SessionInfo = this.SessionInfo; param.BillNo = param.BillNo = codeRulerBll.GetBillNo(new Entity.UserModel.Sys.SYS_CredentialCodeRuleParam() { BillDate = DateTime.Today, TableName = "FIN_SubmitExpense" }); param.GCompanyGuID = this.SessionInfo.CompanyID; param.OrgID = this.SessionInfo.OrgID; param.ExpGuID = Guid.NewGuid(); param.CreatedEmpID = this.SessionInfo.UserID; param.CreatedEmpName = this.SessionInfo.UserName; param.CreatedTime = DateTime.Now; param.IsDeleted = false; affect = this.Insert <FIN_SubmitExpenseResult>(param); param = this.Select <FIN_SubmitExpenseResult>(new List <Field>() { FIN_SubmitExpense._.All }, FIN_SubmitExpense._.ExpGuID == param.ExpGuID); } foreach (FIN_SubmitExpenseLineResult rst in expenseLineList) { if (rst.ExpLineID == 0) { rst.IsDeleted = false; rst.ExpGuID = param.ExpGuID; rst.ExpLineGuID = Guid.NewGuid(); rst.CreatedEmpID = this.SessionInfo.UserID; rst.CreatedEmpName = this.SessionInfo.UserName; rst.CreatedTime = DateTime.Now; } else { rst.UpdatedEmpID = this.SessionInfo.UserID; rst.UpdatedEmpName = this.SessionInfo.UserName; rst.UpdatedTime = DateTime.Now; } } this.BatchInsertOrUpdate <FIN_SubmitExpenseLineResult>(expenseLineList); this.BatchExecute(); #region 设置返回值 ret.Key = param.ExpID; ret.CreatedTime = param.CreatedTime; ret.CreatedEmpID = param.CreatedEmpID; ret.CreatedEmpName = param.CreatedEmpName; ret.UpdatedEmpID = param.UpdatedEmpID; ret.UpdatedEmpName = param.UpdatedEmpName; ret.UpdatedTime = param.UpdatedTime; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
protected override System.Data.Common.DbCommand CreateSelectRangeCommandForUnsortedRows(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn) { //page split algorithm using ROW_NUMBER() in SqlServer 2005 DbCommand cmd = fac.CreateCommand(); cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder("WITH [__T] AS (SELECT "); if (topCount < int.MaxValue && (int.MaxValue - topCount > skipCount)) { sb.Append("TOP "); sb.Append(topCount + skipCount); sb.Append(' '); } for (int i = 0; i < columns.Length; ++i) { SqlQueryUtils.AppendColumnName(sb, columns[i]); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(",ROW_NUMBER() OVER (ORDER BY "); if (string.IsNullOrEmpty(where.OrderBy)) { sb.Append(identyColumn); } else { sb.Append(where.OrderBy); } sb.Append(") AS [__Pos]"); sb.Append(" FROM "); if (string.IsNullOrEmpty(where.OrderBy)) { sb.Append(where.ToString()); } else { lock (where) { string tempOrderBy = where.OrderBy; where.OrderBy = null; sb.Append(where.ToString()); where.OrderBy = tempOrderBy; } } sb.Append(") SELECT *"); //for (int i = 0; i < columns.Length; ++i) //{ // sb.Append("[__T].[__C"); // sb.Append(i); // sb.Append(']'); // if (i < columns.Length - 1) // { // sb.Append(','); // } //} sb.Append(" FROM [__T] WHERE [__T].[__Pos]>"); sb.Append(skipCount); if (topCount < int.MaxValue && (int.MaxValue - topCount > skipCount)) { sb.Append(" AND [__T].[__Pos]<="); sb.Append(topCount + skipCount); sb.Append(' '); } AddExpressionParameters(where, cmd); cmd.CommandText = SqlQueryUtils.ReplaceDatabaseTokens(sb.ToString(), leftToken, rightToken, paramPrefixToken, wildcharToken, wildsinglecharToken); PrepareCommand(cmd); return cmd; }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(HR_EmployeeResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (param.EmpCode.Trim() == "") { throw new WarnException("请输入人员编号!"); } if (param.EmpName.Trim() == "") { throw new WarnException("请输入人员名称!"); } if (param.OrgID == 0) { throw new WarnException("请选择所属机构!"); } if (param.DeptID == 0) { throw new WarnException("请选择所属部门!"); } #endregion #region 判断重复 WhereClip whereChk = HR_Employee._.EmpCode == param.EmpCode; if (param.EmpID > 0) { whereChk = whereChk && HR_Employee._.EmpID != param.EmpID; } int chkNum = this.Count <HR_EmployeeResult>(whereChk); if (chkNum > 0) { throw new WarnException("存在重复的人员编号!"); } #endregion #region 系统默认值 if (param.EmpID != 0) { WhereClip where = HR_Employee._.EmpGuid == param.EmpGuid; affect = this.Update <HR_EmployeeResult>(param, where); } else { param.EmpGuid = Guid.NewGuid(); param.GCompanyID = this.SessionInfo.CompanyID; param.IsDeleted = false; affect = this.Insert <HR_EmployeeResult>(param); param = this.Select <HR_EmployeeResult>(new List <Field>() { HR_Employee._.EmpID }, HR_Employee._.EmpGuid == param.EmpGuid); } #region 保存帐户登录信息 SYS_UserAccount userAcct = new SYS_UserAccount(); userAcct = this.Select <SYS_UserAccount>(SYS_UserAccount._.EmpID == param.EmpID && SYS_UserAccount._.IsDeleted == false); if (userAcct == null) { userAcct = new SYS_UserAccount(); } userAcct.Account = param.EmpCode; userAcct.EmpID = param.EmpID; userAcct.NeedValidate = param.NeedValidate; userAcct.IsActive = param.IsActive; if (param.Password.ToStringHasNull().Trim() != "") { userAcct.PWD = StringExt.MD5(param.Password); } if (userAcct.UserID.ToInt32() <= 0) { userAcct.GCompanyID = this.SessionInfo.CompanyID; userAcct.UserGUID = Guid.NewGuid(); userAcct.CreatedTime = DateTime.Now; userAcct.CreatedByID = this.SessionInfo.UserID; userAcct.CreatedByName = this.SessionInfo.UserName; userAcct.IsDeleted = false; this.Insert <SYS_UserAccount>(userAcct); } else { this.Update <SYS_UserAccount>(userAcct, SYS_UserAccount._.EmpID == param.EmpID && SYS_UserAccount._.IsDeleted == false); } #endregion #region 设置返回值 ret.Key = param.EmpID; ret.KeyGuid = param.EmpGuid; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
/// <summary> /// 根据where条件获取实体 /// </summary> public FuncAccess GetItemById(WhereClip where) { return Dal.Find<FuncAccess>(where); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(STK_InResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (string.IsNullOrEmpty(param.BillType)) { throw new WarnException("请指定入库类型!"); } if (param.StkInLineList == null) { throw new WarnException("请填写入库明细!"); } string msg = string.Empty; foreach (STK_InLineResult rst in param.StkInLineList) { if (string.IsNullOrEmpty(rst.Model)) { msg = "请填写入库明细的型号!"; break; } if (rst.Qty <= 0) { msg = "请填写入库明细的数量!"; } } #endregion List <STK_InLineResult> orderLineList = param.StkInLineList; #region 系统默认值 if (param.StkInGuid != null) { WhereClip where = STK_In._.StkInGuid == param.StkInGuid; param.UpdatedEmpID = this.SessionInfo.UserID; param.UpdatedEmpName = this.SessionInfo.UserName; param.UpdatedTime = DateTime.Now; affect = this.Update <STK_InResult>(param, where); } else { param.StkInGuid = Guid.NewGuid(); Sys_CodeRulerBLL codeRulerBll = new Sys_CodeRulerBLL(); codeRulerBll.SessionInfo = this.SessionInfo; param.BillNo = param.BillNo = codeRulerBll.GetBillNo(new Entity.UserModel.Sys.SYS_CredentialCodeRuleParam() { BillDate = DateTime.Today, TableName = "STK_In" }); param.GCompanyID = this.SessionInfo.CompanyID; param.Status = "New"; param.ApproveStatus = "待提交"; param.IsDeleted = false; param.CreatedEmpID = this.SessionInfo.UserID; param.CreatedEmpName = this.SessionInfo.UserName; param.CreatedTime = DateTime.Now; affect = this.Insert <STK_InResult>(param); param = this.Select <STK_InResult>(new List <Field>() { STK_In._.All }, STK_In._.StkInGuid == param.StkInGuid); } foreach (STK_InLineResult rst in orderLineList) { if (rst.StkInLineGuid == null) { rst.StkInLineGuid = Guid.NewGuid(); rst.StkInGuid = param.StkInGuid; rst.GCompanyID = this.SessionInfo.CompanyID; rst.CreatedEmpID = this.SessionInfo.UserID; rst.CreatedEmpName = this.SessionInfo.UserName; rst.CreatedTime = DateTime.Now; rst.IsDeleted = false; } else { rst.UpdatedEmpID = this.SessionInfo.UserID; rst.UpdatedEmpName = this.SessionInfo.UserName; rst.UpdatedTime = DateTime.Now; } } this.BatchInsertOrUpdate <STK_InLineResult>(orderLineList); this.BatchExecute(); #region 设置返回值 ret.KeyGuid = param.StkInGuid; ret.CreatedTime = param.CreatedTime; ret.CreatedEmpID = param.CreatedEmpID; ret.CreatedEmpName = param.CreatedEmpName; ret.UpdatedEmpID = param.UpdatedEmpID; ret.UpdatedEmpName = param.UpdatedEmpName; ret.UpdatedTime = param.UpdatedTime; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
/// <summary> /// 通过标识获取根节点 /// </summary> /// <param name="marker"></param> /// <returns></returns> public ManageMenu GetRootMarker(string marker) { WhereClip wc = ManageMenu._.MM_Marker == marker && ManageMenu._.MM_PatId == 0; return(Gateway.Default.From <ManageMenu>().Where(wc).OrderBy(ManageMenu._.MM_Tax.Asc).ToFirst <ManageMenu>()); }
public static WhereClip GetEmpIDInWhere(WhereClip whereClip, Field fldBillDate, Field fldEmp, Field fldOrg, Field fldDept, SessionInfo sessionInfo) { WhereClip ret = whereClip; #region 获取人员的权限 Sys_EmpDataRightResult dataRight = new Sys_EmpDataRightResult(); _instarnce.SessionInfo = sessionInfo; dataRight = _instarnce.GetEmpDataRight(null); if (dataRight == null) { return(ret); } string[] arrRIds = new string[] { }; string[] arrEId = new string[] { }; string[] arrIds = new string[] { }; #region 绑定机构条件 if (!string.IsNullOrEmpty(dataRight.ReadOrgIDs)) { arrRIds = dataRight.ReadOrgIDs.Split(','); } if (!string.IsNullOrEmpty(dataRight.EditOrgtIDs)) { arrEId = dataRight.EditOrgtIDs.Split(','); } arrIds = arrRIds.Union(arrEId).Distinct().ToArray(); if (fldOrg != null) { if (arrRIds.Length > 0) { ret = ret && fldOrg.In(arrIds); } } #endregion #region 绑定部门条件 arrRIds = new string[] { }; arrIds = new string[] { }; if (!string.IsNullOrEmpty(dataRight.ReadDeptIDs)) { arrRIds = dataRight.ReadDeptIDs.Split(','); } if (!string.IsNullOrEmpty(dataRight.EditDeptIDs)) { arrEId = dataRight.EditDeptIDs.Split(','); } arrIds = arrRIds.Union(arrEId).Distinct().ToArray(); if (fldDept != null) { if (arrRIds.Length > 0) { ret = ret && fldDept.In(arrIds); } } #endregion #region 绑定员工条件 arrRIds = new string[] { }; arrIds = new string[] { }; if (!string.IsNullOrEmpty(dataRight.ReadEmpIDs)) { arrRIds = dataRight.ReadEmpIDs.Split(','); } if (!string.IsNullOrEmpty(dataRight.EditEmpIDs)) { arrEId = dataRight.EditEmpIDs.Split(','); } arrIds = arrRIds.Union(new string[] { sessionInfo.UserID.ToInt32().ToStringHasNull() }).Union(arrEId).Distinct().ToArray(); if (fldEmp != null) { if (arrRIds.Length > 0) { ret = ret && fldEmp.In(arrIds); } } #endregion #endregion return(ret); }
public void ProcessRequest(HttpContext context) { HttpRequest rp = context.Request; string personID = rp["personid"]; WhereClip where = null; if (!string.IsNullOrEmpty(personID)) { where = DayLog._.UserID == new Guid(personID); } else if (context.Session["UserID"] != null) { where = DayLog._.UserID == new Guid(context.Session["UserID"].ToString()); } if (!string.IsNullOrEmpty(context.Request["rq1"])) { where.And(DayLog._.CreateDate >= DateTime.Parse(context.Request["rq1"])); } if (!string.IsNullOrEmpty(context.Request["rq2"])) { where.And(DayLog._.CreateDate < DateTime.Parse(context.Request["rq2"]).AddDays(1)); } DataTable dt = new DayLogManager().GetDataTable(where); if (dt.Rows.Count > 0) { ExcelOperator eo = new ExcelOperator(); IWorkbook work = eo.GenerateSheet(dt, "工作日志"); string path = Guid.NewGuid() + ".xls"; string dict = context.Server.MapPath("~\\upload\\") + "exportxml"; if (Directory.Exists(dict)) { string[] fs = Directory.GetFileSystemEntries(dict); foreach (string item in fs) { File.Delete(item); } } while (!Directory.Exists(dict)) { Directory.CreateDirectory(dict); } string newpath = dict + "\\" + path;; try { using (Stream stream = File.Open(newpath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { work.Write(stream); } context.Response.Write("{\"success\":\"true\",\"msg\":\"" + path + "\"}"); } catch (Exception ex) { path = "错误:" + ex.Message; path = path.Replace("\r\n", "<br/>"); byte[] bytes = Encoding.UTF8.GetBytes(path); string encode = Convert.ToBase64String(bytes); context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}"); } } else { byte[] bytes = Encoding.UTF8.GetBytes("没有需要导出的日志信息"); string encode = Convert.ToBase64String(bytes); context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}"); } context.Response.End(); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(HR_DepartmentResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (param.DeptID == 0) { param.OrgGuID = param.DeptOrgGuID; param.OrgID = param.DeptOrgID; } if (param.OrgGuID == Guid.Empty) { throw new WarnException("没有所属部门GUID!"); } if (param.OrgID == 0) { throw new WarnException("没有所属机构的ID!"); } if (param.DeptName.Trim() == "") { throw new WarnException("请输入部门名称!"); } #endregion if (param.DeptID != 0) { WhereClip where = HR_Department._.DeptID == param.DeptID; affect = this.Update <HR_DepartmentResult>(param, where); } else { #region 获取最大编号数字 int maxDeptNum = 0; maxDeptNum = this.Count <HR_DepartmentResult>(HR_Department._.ParentID == param.ParentID && HR_Department._.OrgGuID == param.OrgGuID) + 1; #endregion #region 获取父级部门的编号 string parentDeptNo = string.Empty; HR_Department parentDepartment = this.Select <HR_Department>(HR_Department._.DeptID == param.ParentID && HR_Department._.OrgGuID == param.OrgGuID); if (parentDepartment != null) { parentDeptNo = parentDepartment.DeptNo; } #endregion #region 系统默认值 param.DeptNo = parentDeptNo + maxDeptNum.ToString().PadLeft(3, '0'); param.GCompanyID = this.SessionInfo.CompanyID; param.IsActive = 2; affect = this.Insert <HR_DepartmentResult>(param); param = this.Select <HR_DepartmentResult>(new List <Field> { HR_Department._.DeptID }, HR_Department._.DeptNo == param.DeptNo); } #region 设置返回值 ret.Key = param.DeptID; ret.KeyGuid = param.OrgGuID; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
public List <Sys_MenuResult> GetEmpMenuTree(Sys_MenuParam param) { this.CheckSession(); List <Sys_MenuResult> allRet = new List <Sys_MenuResult>(); List <Sys_MenuResult> ret = new List <Sys_MenuResult>(); List <int?> arrHasModuleIDs = new List <int?>(); try { //Sys_Module._.OrderSeq.At("b"), Sys_Module._.ActionCode.At("b"), Sys_Module._.ModuleCode.At("b"), Sys_Module._.ModuleName.At("b"), Sys_Module._.TargetForm.At("b"), Sys_Module._.ModuleID.At("b") #region 获取对应员工角色与权限 List <Sys_RoleRight> roleRightList = new List <Sys_RoleRight>(); Sys_EmpDataRight formRight = this.Select <Sys_EmpDataRight>(Sys_EmpDataRight._.EmpID == this.SessionInfo.UserID && Sys_EmpDataRight._.IsDeleted == false && Sys_EmpDataRight._.GCompanyID == this.SessionInfo.CompanyID); if (formRight != null) { int?[] arrRightID = formRight.RoleIDs.Split(',').Where(a => a.ToStringHasNull().Trim() != "").Select(a => (int?)a.ToInt32()).ToArray(); if (arrRightID.Length > 0) { roleRightList = this.SelectList <Sys_RoleRight>(Sys_RoleRight._.RoleID.In(arrRightID) && Sys_RoleRight._.IsDeleted == false); arrHasModuleIDs.AddRange(roleRightList.Select(a => a.ModuleID).Distinct().ToList()); } } #endregion #region 获取对应员工个人权限 List <Sys_EmpRight> lstEmpRight = new List <Sys_EmpRight>(); lstEmpRight = this.SelectList <Sys_EmpRight>(Sys_EmpRight._.EmpID == this.SessionInfo.UserID && Sys_EmpRight._.IsDeleted == false); arrHasModuleIDs.AddRange(lstEmpRight.Select(a => a.ModuleID).Distinct().ToList()); #endregion #region 获取菜单列表 List <Sys_Module> lstModule = new List <Sys_Module>(); WhereClip whereModule = Sys_Module._.IsDeleted == false; if (lstEmpRight.Count > 0) { whereModule = whereModule && Sys_Module._.ModuleID.In(lstEmpRight.ToArray()); } lstModule = this.SelectList <Sys_Module>(whereModule); List <string> lstEmpMdlCode = lstModule.Where(a => a.ModuleCode.ToStringHasNull() != "").Select(a => a.ModuleCode.ToStringHasNull().Trim()).ToList(); ret = this.SelectList <Sys_MenuResult>(Sys_Menu._.IsDeleted == false, Sys_Menu._.MenuCode.Asc); ret = ret.Where(a => !lstEmpMdlCode.Contains(a.MenuCode)).ToList(); foreach (Sys_Module info in lstModule) { ret.Add(new Sys_MenuResult() { MenuID = info.ModuleID * -1, MenuCode = info.ModuleCode, MenuName = info.ModuleName, TargetForm = info.TargetForm, OrderSeq = info.OrderSeq, MenuType = "Leaf" }); } #endregion #region old code //GroupByClip groupByClip = new GroupByClip("b.OrderSeq,b.ActionCode,b.ModuleCode,b.ModuleName,b.TargetForm,b.ModuleID"); //DataTable lstEmpModeule = this.SelectList<Sys_EmpRight, Sys_Module>(JoinType.InnerJoin // , Sys_EmpRight._.ModuleID == Sys_Module._.ModuleID.At("b") // , 1, int.MaxValue // , new List<Field>() {Sys_Module._.OrderSeq.At("b"), Sys_Module._.ActionCode.At("b"), Sys_Module._.ModuleCode.At("b"), Sys_Module._.ModuleName.At("b"), Sys_Module._.TargetForm.At("b"), Sys_Module._.ModuleID.At("b") }, // Sys_EmpRight._.EmpID == this.SessionInfo.UserID && Sys_EmpRight._.IsDeleted == false // , Sys_Module._.ModuleCode.At("b").Asc, groupByClip, null).ResultJoinList; //List<string> lstEmpMdlCode = lstEmpModeule.Select("ModuleCode<>''").Select(a => a["ModuleCode"].ToStringHasNull()).ToList(); //ret = this.SelectList<Sys_MenuResult>(Sys_Menu._.IsDeleted == false, Sys_Menu._.MenuCode.Asc); //ret = ret.Where(a => !lstEmpMdlCode.Contains(a.MenuCode)).ToList(); //#region 将模块添加至菜单集合 //foreach (DataRow row in lstEmpModeule.Rows) //{ // ret.Add(new Sys_MenuResult() // { // MenuID = row["ModuleID"].ToInt32() * -1, // MenuCode = row["ModuleCode"].ToStringHasNull(), // MenuName = row["ModuleName"].ToStringHasNull(), // TargetForm = row["TargetForm"].ToStringHasNull(), // OrderSeq = row["OrderSeq"].ToInt32(), // MenuType = "Leaf" // }); //} //#endregion #endregion #region 指定的次序号重新排序 List <Sys_MenuResult> newRet = new List <Sys_MenuResult>(); int atIdx = 0; for (int i = 3; i <= 3 * 5; i = i + 3) { newRet = ret.Where(a => a.MenuCode.Length == i).OrderBy(a => a.OrderSeq).ToList(); if (i > 3) { foreach (Sys_MenuResult info in newRet) { atIdx = allRet.FindIndex(a => a.MenuCode.Length == i - 3 && info.MenuCode.StartsWith(a.MenuCode)); if (atIdx < 0) { continue; } allRet.Insert(atIdx + 1, info); } } else { allRet = ret.Where(a => a.MenuCode.Length == i).OrderBy(a => a.OrderSeq).ToList(); } } #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); } return(allRet); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(Sys_ModuleResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (param.ModuleName.ToStringHasNull().Trim() == "") { throw new WarnException("请指定菜单名称!"); } if (param.MenuID.ToInt32() < 0) { throw new WarnException("请指定所属菜单!"); } if (param.TargetForm.ToStringHasNull().Trim() == "") { throw new WarnException("请指定所属目标体窗!"); } string parentCode = ""; Sys_MenuResult menuRst = new Sys_MenuResult(); menuRst = this.Select <Sys_MenuResult>(Sys_Menu._.MenuID == param.MenuID); if (param.MenuID > 0 && (menuRst == null || menuRst.MenuCode == "")) { throw new WarnException("菜单编号的所属菜单不存在!"); } parentCode = menuRst.MenuCode; #endregion #region 生成模块编号 int maxModuleNum = 1; maxModuleNum = this.Count <Sys_ModuleResult>(Sys_Module._.MenuID == param.MenuID) + 1; #endregion #region 判断重复 WhereClip whereChk = Sys_Module._.IsDeleted == false && Sys_Module._.ModuleName == param.ModuleName; if (param.ModuleID > 0) { whereChk = whereChk & Sys_Module._.ModuleID != param.ModuleID; } int chkNum = this.Count <Sys_ModuleResult>(whereChk); if (chkNum > 0) { throw new WarnException("存在重复的模块名称!"); } #endregion #region 系统默认值 if (param.ModuleID > 0) { if (!param.ModuleCode.StartsWith(parentCode)) { param.ModuleCode = parentCode + maxModuleNum.ToString().PadLeft(3, '0'); } WhereClip where = Sys_Module._.ModuleID == param.ModuleID; affect = this.Update <Sys_ModuleResult>(param, where); } else { Sys_ModuleResult codeRulerBll = new Sys_ModuleResult(); param.ModuleCode = parentCode + maxModuleNum.ToString().PadLeft(3, '0'); param.IsDeleted = false; affect = this.Insert <Sys_ModuleResult>(param); param = this.Select <Sys_ModuleResult>(new List <Field>() { Sys_Module._.ModuleID }, Sys_Module._.ModuleCode == param.ModuleCode); } #region 设置返回值 ret.Key = param.ModuleID; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); } return(ret); }
/// <summary> /// 导出 /// </summary> /// <param name="request"></param> /// <returns></returns> public DataTable GetExportList(OrderProgressRequest request) { //组装查询语句 #region 模糊搜索条件 var where = new Where <TbOrderProgress>(); if (!string.IsNullOrWhiteSpace(request.TypeName)) { where.And(p => p.TypeName.Like(request.TypeName)); } if (!string.IsNullOrWhiteSpace(request.OrderCode)) { where.And(p => p.OrderCode.Like(request.OrderCode)); } if (!string.IsNullOrWhiteSpace(request.ReportedStatus)) { where.And(p => p.ReportedStatus == request.ReportedStatus); } if (!string.IsNullOrWhiteSpace(request.ProcessingState)) { where.And(p => p.ProcessingState == request.ProcessingState); } if (request.HistoryMonth.HasValue) { var historyMonth = new WhereClip("YEAR(TbOrderProgress.InsertTime)=" + request.HistoryMonth.Value.Year + " and MONTH(TbOrderProgress.InsertTime)=" + request.HistoryMonth.Value.Month); where.And(historyMonth); } #endregion #region 数据权限新 if (!string.IsNullOrWhiteSpace(request.ProcessFactoryCode)) { where.And(p => p.ProcessFactoryCode == request.ProcessFactoryCode); } if (!string.IsNullOrWhiteSpace(request.ProjectId)) { where.And(p => p.ProjectId == request.ProjectId); } if (!string.IsNullOrWhiteSpace(request.SiteCode)) { List <string> SiteList = orderProLogic.GetCompanyWorkAreaOrSiteList(request.SiteCode, 5); if (SiteList.Count > 0) { where.And(p => p.SiteCode.In(SiteList)); } } #endregion try { var ret = Db.Context.From <TbOrderProgress>() .Select( TbOrderProgress._.All , TbCompany._.CompanyFullName.As("SiteName") , TbSysDictionaryData._.DictionaryText.As("ProcessingStateNew") , TbUser._.UserName) .LeftJoin <TbCompany>((a, c) => a.SiteCode == c.CompanyCode) .AddSelect(Db.Context.From <TbCompany>().Select(p => p.CompanyFullName) .Where(TbCompany._.CompanyCode == TbOrderProgress._.ProcessFactoryCode), "ProcessFactoryName") .AddSelect(Db.Context.From <TbSysDictionaryData>().Select(p => p.DictionaryText) .Where(TbSysDictionaryData._.DictionaryCode == TbOrderProgress._.UrgentDegree && TbSysDictionaryData._.FDictionaryCode == "UrgentDegree"), "UrgentDegreeNew") .LeftJoin <TbSysDictionaryData>((a, c) => a.ProcessingState == c.DictionaryCode && c.FDictionaryCode == "ProcessingState") .LeftJoin <TbUser>((a, c) => a.InsertUserCode == c.UserCode) .Where(where).OrderByDescending(d => d.OrderCode).ToDataTable(); return(ret); } catch (Exception) { throw; } }
/// <summary> /// 分页集合 /// </summary> /// <param name="param"></param> /// <returns></returns> public PageList <STK_StockReserveResult> GetPageList(STK_StockReserveParam param) { this.CheckSession(); PageList <STK_StockReserveResult> ret = new PageList <STK_StockReserveResult>(); try { #region 处理销售明细 WhereClip orderClip = ORD_SalesOrder._.IsDeleted == 0; if (!string.IsNullOrEmpty(param.SourceBillNo)) { orderClip = orderClip && ORD_SalesOrder._.BillNo.Like(param.SourceBillNo + "%"); } if (param.SourceBillGuid != null) { orderClip = orderClip && ORD_SalesOrder._.SOGuid == param.SourceBillGuid; } PageList <ORD_SalesOrderResult> orderList = this.SelectList <ORD_SalesOrderResult>(1, 5000, new List <Field>() { Field.All }, orderClip, ORD_SalesOrder._.CreatedTime.Desc); PageList <ORD_SalesOrderLineResult> lineList = null; Guid?[] SOGuids = null; if (orderList.ResultList != null && orderList.ResultList.Count > 0) { SOGuids = orderList.ResultList.Select(a => a.SOGuid).Distinct().ToArray(); } WhereClip lineClip = ORD_SalesOrderLine._.IsDeleted == 0; if (SOGuids != null) { lineClip = lineClip && ORD_SalesOrderLine._.SOGuid.In(SOGuids); } if (!string.IsNullOrEmpty(param.Model)) { lineClip = lineClip && ORD_SalesOrderLine._.Model.Like(param.Model + "%"); } if (!string.IsNullOrEmpty(param.SourceBillLineCode)) { lineClip = lineClip && ORD_SalesOrderLine._.SOLineCode.Like(param.SourceBillLineCode + "%"); } lineList = this.SelectList <ORD_SalesOrderLineResult>(param.PageIndex.GetValueOrDefault(1), param.PageSize.GetValueOrDefault(100), new List <Field>() { Field.All }, lineClip, ORD_SalesOrderLine._.CreatedTime.Desc); if (lineList != null && lineList.ResultList.Count > 0) { #region 获取业务明细下的预留信息 Guid?[] SOLineGuids = lineList.ResultList.Select(a => (Guid?)a.SOLineGuid).Distinct().ToArray(); STK_StockReserveParam reserveParam = new STK_StockReserveParam(); reserveParam.SourceBillLineGuids = SOLineGuids; List <STK_StockReserveResult> childReserveResultList = this.GetList(reserveParam); #endregion List <STK_StockReserveResult> reserveResultList = new List <STK_StockReserveResult> (); STK_StockReserveResult reserveResult = null; foreach (ORD_SalesOrderLineResult lineResult in lineList.ResultList) { reserveResult = new STK_StockReserveResult(); ORD_SalesOrderResult orderResult = orderList.ResultList.FirstOrDefault(a => a.SOGuid == lineResult.SOGuid); if (orderResult != null) { reserveResult.SourceBillNo = orderResult.BillNo; reserveResult.SourceBillType = "销售出库"; reserveResult.BelongEmpName = orderResult.SalerName; reserveResult.SourceBillDate = orderResult.SODate; } reserveResult.SourceBillGuid = lineResult.SOGuid; reserveResult.SourceBillLineGuid = lineResult.SOLineGuid; reserveResult.SourceBillLineCode = lineResult.SOLineCode; reserveResult.Model = lineResult.Model; reserveResult.Brand = lineResult.Brand; reserveResult.Qty = lineResult.Qty; reserveResult.ReserveQty = lineResult.ReserveQty; reserveResult.CreatedEmpName = lineResult.CreatedEmpName; reserveResult.CreatedTime = lineResult.CreatedTime; reserveResult.UpdatedEmpName = lineResult.UpdatedEmpName; reserveResult.UpdatedTime = lineResult.UpdatedTime; if (childReserveResultList != null && childReserveResultList.Count > 0) { List <STK_StockReserveResult> srList = childReserveResultList.Where(a => a.SourceBillLineGuid == lineResult.SOLineGuid).ToList(); if (srList != null && srList.Count > 0) { Guid?[] ItemCodes = srList.Select(a => a.ItemCode).Distinct().ToArray(); STK_StockBLL stockBLL = new STK_StockBLL(); stockBLL.SessionInfo = this.SessionInfo; List <STK_StockResult> stockList = stockBLL.GetList(new STK_StockParam() { ItemCodes = ItemCodes }); foreach (STK_StockReserveResult sr in srList) { if (stockList != null && stockList.Count > 0) { STK_StockResult stockResult = stockList.FirstOrDefault(a => a.ItemCode == sr.ItemCode); sr.Model = stockResult.Model; sr.Brand = stockResult.Brand; sr.Batch = stockResult.Batch; sr.Package = stockResult.Package; sr.Quality = stockResult.Quality; sr.MPQ = stockResult.MPQ; sr.MarkCode = stockResult.MarkCode; sr.Warehouse = stockResult.Warehouse; sr.Location = stockResult.Location; sr.InvType = stockResult.InvType; sr.InBatchNo = stockResult.InBatchNo; } } reserveResult.ReserveList = srList; } } reserveResultList.Add(reserveResult); } if (ret.ResultList == null) { ret.ResultList = new List <STK_StockReserveResult>(); } ret.ResultList.AddRange(reserveResultList); ret.TotalCount = lineList.TotalCount; } #endregion #region 处理采购退货明细 #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
/// <summary> /// 根据where条件获取实体 /// </summary> public NoticeInfo GetItemById(WhereClip where) { return(Dal.Find <NoticeInfo>(where)); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(Sys_MenuResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (param.MenuCode.ToStringHasNull().Trim() == "") { throw new WarnException("请指定菜单编号!"); } if (param.MenuName.ToStringHasNull().Trim() == "") { throw new WarnException("请指定菜单名称!"); } if (param.MenuType.ToStringHasNull().Trim() == "") { throw new WarnException("请指定菜单类型!"); } if (param.MenuCode.Length % 3 > 0) { throw new WarnException("请菜单编号为三位迭加!"); } string parentCode = ""; if (param.MenuCode.Length > 3) { parentCode = param.MenuCode.Substring(0, param.MenuCode.Length - 3); } if (parentCode != "" && this.Count <Sys_MenuResult>(Sys_Menu._.MenuCode == parentCode) < 0) { throw new WarnException("菜单编号的父菜单不存在!"); } #endregion #region 判断重复 WhereClip whereChk = Sys_Menu._.IsDeleted == false && Sys_Menu._.MenuCode == param.MenuCode; if (param.MenuID > 0) { whereChk = whereChk & Sys_Menu._.MenuID != param.MenuID; } int chkNum = this.Count <Sys_MenuResult>(whereChk); if (chkNum > 0) { throw new WarnException("存在重复的菜单编号!"); } #endregion #region 系统默认值 if (param.MenuID > 0) { WhereClip where = Sys_Menu._.MenuID == param.MenuID; affect = this.Update <Sys_MenuResult>(param, where); } else { Sys_MenuResult codeRulerBll = new Sys_MenuResult(); param.IsDeleted = false; affect = this.Insert <Sys_MenuResult>(param); param = this.Select <Sys_MenuResult>(new List <Field>() { Sys_Menu._.MenuID }, Sys_Menu._.MenuCode == param.MenuCode); } #region 设置返回值 ret.Key = param.MenuID; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); } return(ret); }
protected override System.Data.Common.DbCommand CreateSelectRangeCommandForUnsortedRows(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn) { //page split algorithm using ROW_NUMBER() in SqlServer 2005 DbCommand cmd = fac.CreateCommand(); cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder("WITH [__T] AS (SELECT "); if (topCount < int.MaxValue && (int.MaxValue - topCount > skipCount)) { sb.Append("TOP "); sb.Append(topCount + skipCount); sb.Append(' '); } for (int i = 0; i < columns.Length; ++i) { SqlQueryUtils.AppendColumnName(sb, columns[i]); sb.Append(" AS [__C"); sb.Append(i); sb.Append(']'); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(",ROW_NUMBER() OVER (ORDER BY "); if (string.IsNullOrEmpty(where.OrderBy)) { sb.Append(identyColumn); } else { sb.Append(where.OrderBy); } sb.Append(") AS [__Pos]"); sb.Append(" FROM "); if (string.IsNullOrEmpty(where.OrderBy)) { sb.Append(where.ToString()); } else { lock (where) { string tempOrderBy = where.OrderBy; where.OrderBy = null; sb.Append(where.ToString()); where.OrderBy = tempOrderBy; } } sb.Append(") SELECT "); for (int i = 0; i < columns.Length; ++i) { sb.Append("[__T].[__C"); sb.Append(i); sb.Append(']'); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(" FROM [__T] WHERE [__T].[__Pos]>"); sb.Append(skipCount); if (topCount < int.MaxValue && (int.MaxValue - topCount > skipCount)) { sb.Append(" AND [__T].[__Pos]<="); sb.Append(topCount + skipCount); sb.Append(' '); } AddExpressionParameters(where, cmd); cmd.CommandText = SqlQueryUtils.ReplaceDatabaseTokens(sb.ToString(), leftToken, rightToken, paramPrefixToken, wildcharToken, wildsinglecharToken); PrepareCommand(cmd); return(cmd); }
/// <summary> /// 分页获取获取设备信息表datatable /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetDataTable(int pageindex, int pagesize,WhereClip where, ref int pageCount, ref int recordCount) { return Dal.From<ShebeiInfo>().Join<AdministrativeRegions>(ShebeiInfo._.SocrceDepart==AdministrativeRegions._.ID, JoinType.leftJoin) .Where(where).Select(ShebeiInfo._.ID.All, AdministrativeRegions._.Name.Alias("DepartName")).OrderBy(ShebeiInfo._.Code).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); }
/// <summary> /// 根据where条件获取实体 /// </summary> public RoleInfo GetItemById(WhereClip where) { return Dal.Find<RoleInfo>(where); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; if (context.Session["UserID"] != null) { string userid = context.Session["UserID"].ToString(); PersonInfo p = new PersonInfoManager().GetItemById(new Guid(userid)); if (!p.MarryStatus.HasValue || p.MarryStatus.Value != 3) { context.Response.Write("{\"total\":\"0\",\"rows\": 没有考勤数据}"); context.Response.End(); return; } } YuanGongKaoQinManager manager = new YuanGongKaoQinManager(); int pageNum = int.Parse(context.Request.QueryString.Get("pagenum")); int pagesize = int.Parse(context.Request.QueryString.Get("pagesize")); int recordCount = 0; WhereClip where = new WhereClip(); if (!string.IsNullOrEmpty(context.Request["USER"])) { where = YuanGongKaoQin._.UserName.Contains(context.Request["USER"]); } if (!string.IsNullOrEmpty(context.Request["begindate"])) { string begin = context.Request["begindate"]; if (!string.IsNullOrEmpty(begin)) { where = where && YuanGongKaoQin._.KQRQ >= begin; } } if (!string.IsNullOrEmpty(context.Request["enddate"])) { string enddate = context.Request["enddate"]; if (!string.IsNullOrEmpty(enddate)) { where = where && YuanGongKaoQin._.KQRQ <= enddate; } } if (!string.IsNullOrEmpty(context.Request["swstatus"])) { where = YuanGongKaoQin._.SWStatus == context.Request["swstatus"]; } if (!string.IsNullOrEmpty(context.Request["status"])) { where = YuanGongKaoQin._.Status == context.Request["status"]; } if (!string.IsNullOrEmpty(context.Request["KQRQ"])) { string[] datestr = context.Request["KQRQ"].ToString().Split('@'); string begin = datestr[0]; if (!string.IsNullOrEmpty(begin)) { where.And(YuanGongKaoQin._.KQRQ >= begin); } string end = datestr[1]; if (!string.IsNullOrEmpty(end)) { where.And(YuanGongKaoQin._.KQRQ <= end); } } string or = "UserName"; if (!string.IsNullOrEmpty(context.Request["sortdatafield"])) { if (!string.IsNullOrEmpty(context.Request["sortorder"]) && context.Request["sortorder"] == "desc") { or = context.Request["sortdatafield"] + " desc"; } else { or = context.Request["sortdatafield"]; } } DataTable dt = manager.GetDataTable(pageNum + 1, pagesize, where, or, ref pagesize, ref recordCount); //manager.GetDataTable(); string result = JsonConvert.Convert2Json(dt); context.Response.Write("{\"total\":\"" + recordCount.ToString() + "\",\"rows\":" + result + "}"); context.Response.End(); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(STK_StockReserveResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (param.ItemCode == null) { throw new WarnException("没有关联库存"); } #endregion #region 系统默认值 if (param.SRGuid != null) { WhereClip where = STK_StockReserve._.SRGuid == param.SRGuid; param.UpdatedEmpID = this.SessionInfo.UserID; param.UpdatedEmpName = this.SessionInfo.UserName; param.UpdatedTime = DateTime.Now; affect = this.Update <STK_StockReserveResult>(param, where); } else { param.SRGuid = Guid.NewGuid(); param.GCompanyID = this.SessionInfo.CompanyID; param.IsDeleted = false; param.CreatedEmpID = this.SessionInfo.UserID; param.CreatedEmpName = this.SessionInfo.UserName; param.CreatedTime = DateTime.Now; affect = this.Insert <STK_StockReserveResult>(param); param = this.Select <STK_StockReserveResult>(new List <Field>() { STK_StockReserve._.All }, STK_StockReserve._.SRGuid == param.SRGuid); } #region 设置返回值 ret.KeyGuid = param.SRGuid; ret.CreatedTime = param.CreatedTime; ret.CreatedEmpID = param.CreatedEmpID; ret.CreatedEmpName = param.CreatedEmpName; ret.UpdatedEmpID = param.UpdatedEmpID; ret.UpdatedEmpName = param.UpdatedEmpName; ret.UpdatedTime = param.UpdatedTime; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(STK_StockResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (string.IsNullOrEmpty(param.InvType)) { throw new WarnException("请指定库存类型!"); } if (string.IsNullOrEmpty(param.Warehouse)) { throw new WarnException("请指定仓库!"); } if (string.IsNullOrEmpty(param.InBatchNo)) { throw new WarnException("请指定入库批次号!"); } if (param.InvQty == null) { throw new WarnException("请指定入库数量!"); } if (string.IsNullOrEmpty(param.Currency)) { throw new WarnException("请指定入库币种!"); } if (param.BuyPrice == null) { throw new WarnException("请指定入库单价!"); } #endregion #region 系统默认值 if (param.ItemCode != null) { WhereClip where = STK_Stock._.ItemCode == param.ItemCode; param.UpdatedEmpID = this.SessionInfo.UserID; param.UpdatedEmpName = this.SessionInfo.UserName; param.UpdatedTime = DateTime.Now; affect = this.Update <STK_StockResult>(param, where); } else { param.ItemCode = Guid.NewGuid(); param.GCompanyID = this.SessionInfo.CompanyID; param.IsDeleted = false; param.CreatedEmpID = this.SessionInfo.UserID; param.CreatedEmpName = this.SessionInfo.UserName; param.CreatedTime = DateTime.Now; affect = this.Insert <STK_StockResult>(param); param = this.Select <STK_StockResult>(new List <Field>() { STK_Stock._.All }, STK_Stock._.ItemCode == param.ItemCode); } #region 设置返回值 ret.KeyGuid = param.ItemCode; ret.CreatedTime = param.CreatedTime; ret.CreatedEmpID = param.CreatedEmpID; ret.CreatedEmpName = param.CreatedEmpName; ret.UpdatedEmpID = param.UpdatedEmpID; ret.UpdatedEmpName = param.UpdatedEmpName; ret.UpdatedTime = param.UpdatedTime; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
/// <summary> /// 根据where条件获取实体 /// </summary> public ShebeiInfo GetItemById(WhereClip where) { return Dal.Find<ShebeiInfo>(where); }
public override DbCommand CreateSelectRangeCommand(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn, bool identyColumnIsNumber) { //Check.Require(((object)where) != null && where.From != null, "expr and expr.From could not be null!"); //Check.Require(columns != null && columns.Length > 0, "columns could not be null or empty!"); //Check.Require(topCount > 0, "topCount must > 0!"); if (string.IsNullOrEmpty(where.OrderBy) && identyColumn != null) { where.SetOrderBy(new KeyValuePair <string, bool>[] { new KeyValuePair <string, bool>(identyColumn, false) }); } if (topCount == int.MaxValue && skipCount == 0) { return(CreateSelectCommand(where, columns)); } else { //Check.Require(!string.IsNullOrEmpty(identyColumn), "identyColumn could not be null or empty!"); identyColumn = ColumnFormatter.ValidColumnName(identyColumn); //page split algorithm using ROW_NUMBER() in Oracle9+ DbCommand cmd = fac.CreateCommand(); cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder(); sb.Append("SELECT *"); //for (int i = 0; i < columns.Length; ++i) //{ // sb.Append("[__T].[__C"); // sb.Append(i); // sb.Append(']'); // if (i < columns.Length - 1) // { // sb.Append(','); // } //} sb.Append(" FROM ("); sb.Append("SELECT "); for (int i = 0; i < columns.Length; ++i) { SqlQueryUtils.AppendColumnName(sb, columns[i]); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(",ROW_NUMBER() OVER (ORDER BY "); if (string.IsNullOrEmpty(where.OrderBy)) { sb.Append(identyColumn); } else { sb.Append(where.OrderBy); } sb.Append(") AS [__Pos]"); sb.Append(" FROM "); if (string.IsNullOrEmpty(where.OrderBy)) { sb.Append(where.ToString()); } else { lock (where) { string tempOrderBy = where.OrderBy; where.OrderBy = null; sb.Append(where.ToString()); where.OrderBy = tempOrderBy; } } sb.Append(") [__T] WHERE [__T].[__Pos]>"); sb.Append(skipCount); if (topCount < int.MaxValue && (int.MaxValue - topCount > skipCount)) { sb.Append(" AND [__T].[__Pos]<="); sb.Append(topCount + skipCount); sb.Append(' '); } AddExpressionParameters(where, cmd); cmd.CommandText = SqlQueryUtils.ReplaceDatabaseTokens(sb.ToString(), leftToken, rightToken, paramPrefixToken, wildcharToken, wildsinglecharToken); PrepareCommand(cmd); return(cmd); } }
/// <summary> /// 分页获取获取设备信息表datatable /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetDataTableWithImg(int pageindex, int pagesize, WhereClip where, string orderby, ref int pageCount, ref int recordCount) { DataTable dt= Dal.From<ShebeiInfo>().Where(where).OrderBy(new OrderByClip(orderby)).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); //dt.Columns.Add("FilePath"); //foreach (DataRow item in dt.Rows) //{ //OAManager.FileInfoManager flMgr = new FileInfoManager(); //DataTable dtimg = flMgr.GetDataTable(item["ID"].ToString()); //string img_html = string.Empty; //if (dtimg.Rows.Count > 0) //{ // string src = dtimg.Rows[0]["FILEPATH"].ToString(); // img_html = "<a href='" + src + "'><img src='" + src + "' width='50' height='40' alt='图标'></a>"; //} //else //{ // img_html = "无缩略图"; //} //item["FilePath"] = img_html; //} return dt; }
public JoinTable(IQueryTable joinQueryTable, string aliasName, WhereClip joinWhere, EJoinType joinType, params ExpressionClip[] queryCulumns) : this(joinQueryTable, joinWhere, joinType, queryCulumns) { this.AliasName = aliasName; }
/// <summary> /// 根据where条件获取实体 /// </summary> public SystemCode GetItemById(WhereClip where) { return Dal.Find<SystemCode>(where); }
public List <SYS_DataGridResult> GetGridColList(SYS_DataGridParam param) { #region condtion defined Guid?[] arrDGID = new Guid?[] { }; List <SYS_DataGridResult> ret = new List <SYS_DataGridResult>(); if (param.GridNames == null || param.FormNames == null || param.ParentNames == null || param.GridNames.Length <= 0 || param.FormNames.Length <= 0 || param.ParentNames.Length <= 0) { throw new WarnException("请指定表格条件!"); } #endregion #region 表格定义配置 WhereClip whereClip = WhereClip.All; string[] parentNames = param.ParentNames.Where(a => a != null).ToArray(); whereClip = whereClip && SYS_DataGrid._.GridName.In(param.GridNames) && SYS_DataGrid._.FormName.In(param.FormNames); if (parentNames.Length > 0) { whereClip = whereClip && SYS_DataGrid._.ParentName.In(parentNames); } ret = this.SelectList <SYS_DataGridResult>(whereClip); if (ret.Count > 0) { arrDGID = ret.Select(a => a.DGGUID).ToArray(); } else { return(ret); } #endregion #region index defined Guid?companyID = this.SessionInfo.CompanyID; Guid?userGuid = this.SessionInfo.UserGuid; List <SYS_UserGridColIndex> colIdxList = this.SelectList <SYS_UserGridColIndex>(SYS_UserGridColIndex._.DGGUID.In(arrDGID) && SYS_UserGridColIndex._.CompanyID == companyID && SYS_UserGridColIndex._.UserGUID == userGuid , SYS_UserGridColIndex._.DisplayIndex.Asc); List <SYS_UserGridColIndex> findIdxList = null; foreach (SYS_DataGridResult info in ret) { findIdxList = colIdxList.Where(a => a.DGGUID == info.DGGUID).ToList(); info.ColIndexList = findIdxList; } #endregion #region width defined List <SYS_UserGridColWidth> colWdthList = this.SelectList <SYS_UserGridColWidth>(SYS_UserGridColWidth._.DGGUID.In(arrDGID) && SYS_UserGridColWidth._.CompanyID == companyID && SYS_UserGridColWidth._.UserGUID == userGuid , SYS_UserGridColWidth._.CWID.Asc); List <SYS_UserGridColWidth> findWdthList = null; foreach (SYS_DataGridResult info in ret) { findWdthList = colWdthList.Where(a => a.DGGUID == info.DGGUID).ToList(); info.ColWidthList = findWdthList; } #endregion #region name defined List <SYS_UserGridColName> colNameList = this.SelectList <SYS_UserGridColName>(SYS_UserGridColName._.DGGUID.In(arrDGID) && SYS_UserGridColName._.CompanyID == companyID , SYS_UserGridColName._.CNID.Asc); List <SYS_UserGridColName> findNameList = null; foreach (SYS_DataGridResult info in ret) { findNameList = colNameList.Where(a => a.DGGUID == info.DGGUID).ToList(); info.ColNameList = findNameList; } #endregion return(ret); }
/// <summary> /// 导出Excel格式的学习卡信息 /// </summary> /// <param name="path">导出文件的路径(服务器端)</param> /// <param name="orgid">机构id</param> /// <param name="lcsid">学习卡设置项的id</param> /// <returns></returns> public string Card4Excel(string path, int orgid, int lcsid) { HSSFWorkbook hssfworkbook = new HSSFWorkbook(); //xml配置文件 XmlDocument xmldoc = new XmlDocument(); string confing = WeiSha.Common.App.Get["ExcelInputConfig"].VirtualPath + "学习卡.xml"; xmldoc.Load(WeiSha.Common.Server.MapPath(confing)); XmlNodeList nodes = xmldoc.GetElementsByTagName("item"); //创建工作簿对象 LearningCardSet rs = Gateway.Default.From <LearningCardSet>().Where(LearningCardSet._.Lcs_ID == lcsid).ToFirst <LearningCardSet>(); ISheet sheet = hssfworkbook.CreateSheet(rs.Lcs_Theme); //sheet.DefaultColumnWidth = 30; //创建数据行对象 IRow rowHead = sheet.CreateRow(0); for (int i = 0; i < nodes.Count; i++) { rowHead.CreateCell(i).SetCellValue(nodes[i].Attributes["Column"].Value); } //生成数据行 ICellStyle style_size = hssfworkbook.CreateCellStyle(); style_size.WrapText = true; WhereClip wc = LearningCard._.Org_ID == orgid; if (lcsid >= 0) { wc.And(LearningCard._.Lcs_ID == lcsid); } LearningCard[] rcodes = Gateway.Default.From <LearningCard>().Where(wc).OrderBy(LearningCard._.Lc_CrtTime.Desc).ToArray <LearningCard>(); for (int i = 0; i < rcodes.Length; i++) { IRow row = sheet.CreateRow(i + 1); for (int j = 0; j < nodes.Count; j++) { Type type = rcodes[i].GetType(); System.Reflection.PropertyInfo propertyInfo = type.GetProperty(nodes[j].Attributes["Field"].Value); //获取指定名称的属性 object obj = propertyInfo.GetValue(rcodes[i], null); if (obj != null) { string format = nodes[j].Attributes["Format"] != null ? nodes[j].Attributes["Format"].Value : ""; string datatype = nodes[j].Attributes["DataType"] != null ? nodes[j].Attributes["DataType"].Value : ""; string defvalue = nodes[j].Attributes["DefautValue"] != null ? nodes[j].Attributes["DefautValue"].Value : ""; string value = ""; switch (datatype) { case "date": DateTime tm = Convert.ToDateTime(obj); value = tm > DateTime.Now.AddYears(-100) ? tm.ToString(format) : ""; break; default: value = obj.ToString(); break; } if (defvalue.Trim() != "") { foreach (string s in defvalue.Split('|')) { string h = s.Substring(0, s.IndexOf("=")); string f = s.Substring(s.LastIndexOf("=") + 1); if (value.ToLower() == h.ToLower()) { value = f; } } } row.CreateCell(j).SetCellValue(value); } } } FileStream file = new FileStream(path, FileMode.Create); hssfworkbook.Write(file); file.Close(); return(path); }
public DataTable GetDaiBanDataTable(WhereClip where, OrderByClip orderby) { return Dal.From<WorkHandLog>() .Where(where).OrderBy(orderby).ToDataTable(); }
/// <summary> /// 根据where条件获取实体 /// </summary> public NoticeInfo GetItemById(WhereClip where) { return Dal.Find<NoticeInfo>(where); }
/// <summary> /// 分页获取获取工作信息表datatable /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetDataTable(int pageindex, int pagesize, string UserId, WhereClip where, OrderByClip orderby, ref int pageCount, ref int recordCount) { WhereClip wherenew = new WhereClip(); if (!string.IsNullOrEmpty(UserId)) { string[] s = UserId.Split(';'); if (s[1] == "2") { wherenew = wherenew && WorkHandLog._.Uper == new Guid(s[0]); } else { wherenew = wherenew && WorkHandLog._.DownEr == new Guid(s[0]); } } if (WhereClip.IsNullOrEmpty(where)) { where = wherenew; } else { where = where && wherenew; } if (WhereClip.IsNullOrEmpty(where)) { where.Append(@" (handsequence is null or handsequence = (select max(handsequence) from [WorkHandLog] b where [WorkInfo].[ID] = b.[WorkID])) "); } else { where.Append(@" and (handsequence is null or handsequence = (select max(handsequence) from [WorkHandLog] b where [WorkInfo].[ID] = b.[WorkID]) )"); } return Dal.From<WorkInfo>().Join<ShebeiInfo>(ShebeiInfo._.ID == WorkInfo._.SbID) .Join<WorkHandLog>(WorkInfo._.ID == WorkHandLog._.WorkID, JoinType.leftJoin) .Select(WorkInfo._.ID.All, ShebeiInfo._.Code, ShebeiInfo._.Name, ShebeiInfo._.GuiGe) .Where(where).OrderBy(orderby).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(CRM_ZoneResult param) { this.CheckSession(); WCFAddUpdateResult ret = new WCFAddUpdateResult(); try { int affect = 0; #region 判断 if (param.ZID == 0) { throw new WarnException("请输入区域ID!"); } if (param.Name_CN.Trim() == "") { throw new WarnException("请输入区域名称!"); } #endregion #region 判断重复 WhereClip whereChk = CRM_Zone._.Name_CN == param.Name_CN; if (param.ZID > 0) { whereChk = whereChk && CRM_Zone._.ZID != param.ZID; } int chkNum = this.Count <CRM_ZoneResult>(whereChk); if (chkNum > 0) { throw new WarnException("存在重复的区域名称!"); } #endregion #region 系统默认值 if (param.ZID != 0) { WhereClip where = CRM_Zone._.ZID == param.ZID; affect = this.Update <CRM_ZoneResult>(param, where); } else { param.ZGuID = Guid.NewGuid(); param.GCompanyID = this.SessionInfo.CompanyID; param.IsDeleted = false; affect = this.Insert <CRM_ZoneResult>(param); param = this.Select <CRM_ZoneResult>(new List <Field>() { CRM_Zone._.ZID }, CRM_Zone._.Name_CN == param.Name_CN); } #region 设置返回值 ret.Key = param.ZID; ret.KeyGuid = param.ZGuID; #endregion #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
protected virtual DbCommand CreateSelectTopCommand(WhereClip where, string[] columns, int topCount) { DbCommand cmd = fac.CreateCommand(); cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder("SELECT TOP "); sb.Append(topCount); sb.Append(' '); for (int i = 0; i < columns.Length; ++i) { SqlQueryUtils.AppendColumnName(sb, columns[i]); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(" FROM "); sb.Append(where.ToString()); AddExpressionParameters(where, cmd); cmd.CommandText = SqlQueryUtils.ReplaceDatabaseTokens(sb.ToString(), leftToken, rightToken, paramPrefixToken, wildcharToken, wildsinglecharToken); PrepareCommand(cmd); return cmd; }
/// <summary> /// 获取数据列表(分页) /// </summary> public PageModel GetDataListForPage(OrderProgressRequest request) { //组装查询语句 #region 模糊搜索条件 var where = new Where <TbOrderProgress>(); if (!string.IsNullOrWhiteSpace(request.TypeName)) { where.And(p => p.TypeName.Like(request.TypeName)); } if (!string.IsNullOrWhiteSpace(request.OrderCode)) { where.And(p => p.OrderCode.Like(request.OrderCode)); } if (!string.IsNullOrWhiteSpace(request.ReportedStatus)) { where.And(p => p.ReportedStatus == request.ReportedStatus); } if (!string.IsNullOrWhiteSpace(request.ProcessingState)) { where.And(p => p.ProcessingState == request.ProcessingState); } if (request.HistoryMonth.HasValue) { var historyMonth = new WhereClip("YEAR(TbOrderProgress.InsertTime)=" + request.HistoryMonth.Value.Year + " and MONTH(TbOrderProgress.InsertTime)=" + request.HistoryMonth.Value.Month); where.And(historyMonth); } if (!string.IsNullOrWhiteSpace(request.ProgressType)) { if (request.ProgressType == "进度正常") { var progressType = new WhereClip("(TbOrderProgress.FinishProcessingDateTime is not null and CONVERT(varchar(100),TbOrderProgress.FinishProcessingDateTime,23)=CONVERT(varchar(100),TbOrderProgress.DistributionTime,23)) or (TbOrderProgress.FinishProcessingDateTime is null and CONVERT(varchar(100),TbOrderProgress.DistributionTime,23)>=CONVERT(varchar(100),GETDATE(),23))"); where.And(progressType); } else if (request.ProgressType == "进度超前") { var progressType = new WhereClip("(TbOrderProgress.FinishProcessingDateTime is not null and CONVERT(varchar(100),TbOrderProgress.FinishProcessingDateTime,23)<CONVERT(varchar(100),TbOrderProgress.DistributionTime,23))"); where.And(progressType); } else if (request.ProgressType == "进度滞后") { var progressType = new WhereClip("(TbOrderProgress.FinishProcessingDateTime is not null and (CONVERT(varchar(100),TbOrderProgress.FinishProcessingDateTime,23)>CONVERT(varchar(100),TbOrderProgress.DistributionTime,23)) or (TbOrderProgress.FinishProcessingDateTime is null and CONVERT(varchar(100),TbOrderProgress.DistributionTime,23)<CONVERT(varchar(100),GETDATE(),23)))"); where.And(progressType); } } #endregion #region 数据权限新 if (!string.IsNullOrWhiteSpace(request.ProcessFactoryCode)) { where.And(p => p.ProcessFactoryCode == request.ProcessFactoryCode); } if (!string.IsNullOrWhiteSpace(request.ProjectId)) { where.And(p => p.ProjectId == request.ProjectId); } if (!string.IsNullOrWhiteSpace(request.SiteCode)) { List <string> SiteList = orderProLogic.GetCompanyWorkAreaOrSiteList(request.SiteCode, 5); if (SiteList.Count > 0) { where.And(p => p.SiteCode.In(SiteList)); } } #endregion try { var ret = Db.Context.From <TbOrderProgress>() .Select( TbOrderProgress._.All , TbCompany._.CompanyFullName.As("SiteName") , TbSysDictionaryData._.DictionaryText.As("ProcessingStateNew") , TbUser._.UserName) .LeftJoin <TbCompany>((a, c) => a.SiteCode == c.CompanyCode) .AddSelect(Db.Context.From <TbCompany>().Select(p => p.CompanyFullName) .Where(TbCompany._.CompanyCode == TbOrderProgress._.ProcessFactoryCode), "ProcessFactoryName") .AddSelect(Db.Context.From <TbSysDictionaryData>().Select(p => p.DictionaryText) .Where(TbSysDictionaryData._.DictionaryCode == TbOrderProgress._.UrgentDegree && TbSysDictionaryData._.FDictionaryCode == "UrgentDegree"), "UrgentDegreeNew") .LeftJoin <TbSysDictionaryData>((a, c) => a.ProcessingState == c.DictionaryCode && c.FDictionaryCode == "ProcessingState") .LeftJoin <TbUser>((a, c) => a.InsertUserCode == c.UserCode) .Where(where).OrderByDescending(d => d.OrderCode).ToPageList(request.rows, request.page); return(ret); } catch (Exception) { throw; } }
/// <summary> /// 根据where条件获取实体 /// </summary> public download GetdownloadItemById(WhereClip where) { return Dal.Find<download>(where); }
/// <summary> /// 分页获取获取设备信息表datatable /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetDataTable(int pageindex, int pagesize, WhereClip where, string orderby, ref int pageCount, ref int recordCount) { return(Dal.From <NoticeInfo>().Where(where).OrderBy(new OrderByClip(orderby)).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount)); }
/// <summary> /// 分页获取获取员工信息表datatable /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetDataTable(int pageindex, int pagesize, WhereClip where, OrderByClip orderby, ref int pageCount, ref int recordCount) { return Dal.From<PersonInfo>().Join<DepartAndPerson>(PersonInfo._.ID == DepartAndPerson._.UserID, JoinType.leftJoin) .Join<AdministrativeRegions>(DepartAndPerson._.DepartID == AdministrativeRegions._.ID && DepartAndPerson._.IsDefault == true, JoinType.leftJoin) .Select(PersonInfo._.ID.All, AdministrativeRegions._.Name.Alias("DepartName"), new ExpressionClip("case MarryStatus when 0 then '外部' else '内部' end NWName")) .Where(where).OrderBy(orderby).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); }
protected virtual DbCommand CreateSelectRangeCommandForUnsortedRows(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn) { //SELECT TOP 10 * //FROM TestTable //WHERE (ID NOT IN // (SELECT TOP 20 id // FROM TestTable // ORDER BY id)) //ORDER BY ID DbCommand cmd = fac.CreateCommand(); cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder("SELECT "); if (topCount < int.MaxValue) { sb.Append("TOP "); sb.Append(topCount); sb.Append(' '); } for (int i = 0; i < columns.Length; ++i) { SqlQueryUtils.AppendColumnName(sb, columns[i]); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(" FROM "); WhereClip cloneWhere = (WhereClip) where.Clone(); #region Construct & extend CloneWhere StringBuilder sbInside = new StringBuilder(); sbInside.Append(identyColumn); sbInside.Append(" NOT IN (SELECT TOP "); sbInside.Append(skipCount); sbInside.Append(' '); sbInside.Append(identyColumn); sbInside.Append(" FROM "); sbInside.Append(where.ToString()); sbInside.Append(")"); if (cloneWhere.Sql.Length == 0) { cloneWhere.Sql = sbInside.ToString(); } else { cloneWhere.Sql = "(" + cloneWhere.Sql.ToString() + ") AND " + sbInside.ToString(); } #endregion sb.Append(cloneWhere.ToString()); AddExpressionParameters(where, cmd); AddExpressionParameters(cloneWhere, cmd); cmd.CommandText = SqlQueryUtils.ReplaceDatabaseTokens(sb.ToString(), leftToken, rightToken, paramPrefixToken, wildcharToken, wildsinglecharToken); PrepareCommand(cmd); return(cmd); }
/// <summary> /// 获取集合 /// </summary> /// <param name="param"></param> /// <returns></returns> public List <SYS_CurrencyResult> GetList(SYS_CurrencyParam param) { this.CheckSession(); List <SYS_CurrencyResult> ret = new List <SYS_CurrencyResult>(); try { #region 取最近一条汇率记录 if (param.GetLastRate.ToBooleanHasNull()) { #region 获取条件下的最靠近的汇率 #region 获取条件下的最靠近的汇率的条件日期列表 WhereClip whereClip = GetWhereClip(param); List <SYS_CurrencyResult> lastRst = new List <SYS_CurrencyResult>(); List <Field> lstField = new List <Field>() { SYS_Currency._.CurrencyCode, SYS_Currency._.RateDate.Min().As("RateDate"), }; PageList <SYS_CurrencyResult> pageRst = this.SelectList <SYS_CurrencyResult>(1, 500, lstField , whereClip, null , new GroupByClip("CurrencyCode"), null); WhereClip whereClipLast = SYS_Currency._.IsDeleted == false; WhereClip whereClipLastEx = WhereClip.All; #endregion #region 生成取值条件 int countStep = -1; if (pageRst != null) { foreach (SYS_CurrencyResult info in pageRst.ResultList) { if (countStep == -1) { whereClipLastEx = (whereClipLastEx && SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } else { whereClipLastEx = whereClipLastEx || (SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } countStep++; } } #endregion #region 条件步骤 if (countStep >= 0) { whereClipLast = whereClipLast && (whereClipLastEx); lastRst = this.SelectList <SYS_CurrencyResult>(whereClipLast); foreach (SYS_CurrencyResult info in lastRst) { if (!ret.Exists(a => a.CurrencyCode == info.CurrencyCode && a.RateDate == info.RateDate)) { ret.Add(info); } } } #endregion #endregion #region 获取最近条件 #region 获取最后一次日期条件 lastRst = new List <SYS_CurrencyResult>(); lstField = new List <Field>() { SYS_Currency._.CurrencyCode, SYS_Currency._.RateDate.Max().As("RateDate"), }; pageRst = this.SelectList <SYS_CurrencyResult>(1, 500, lstField , SYS_Currency._.IsDeleted == false, null , new GroupByClip("CurrencyCode"), null); whereClipLast = SYS_Currency._.IsDeleted == false; whereClipLastEx = WhereClip.All; #endregion #region 组合最后一次日期条件 countStep = -1; if (pageRst != null) { foreach (SYS_CurrencyResult info in pageRst.ResultList) { if (countStep == -1) { whereClipLastEx = (whereClipLastEx && SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } else { whereClipLastEx = whereClipLastEx || (SYS_Currency._.CurrencyCode == info.CurrencyCode && SYS_Currency._.RateDate == info.RateDate); } countStep++; } } if (countStep >= 0) { whereClipLast = whereClipLast && (whereClipLastEx); } #endregion #endregion #region 获取最近条件,将结果进行组合,加入返回值 lastRst = this.SelectList <SYS_CurrencyResult>(whereClipLast); foreach (SYS_CurrencyResult info in lastRst) { if (!ret.Exists(a => a.CurrencyCode == info.CurrencyCode && a.RateDate == info.RateDate)) { ret.Add(info); } } #endregion } else { WhereClip whereClip = GetWhereClip(param); ret = this.SelectList <SYS_CurrencyResult>(whereClip, SYS_Currency._.CreatedTime.Asc); } #endregion } catch (WarnException exp) { throw exp; } catch (System.Exception exp) { LogInfoBLL.WriteLog(this.SessionInfo, exp); throw exp; } return(ret); }
/// <summary> /// 根据where条件获取实体 /// </summary> public downclass GetItemById(WhereClip where) { return Dal.Find<downclass>(where); }
protected virtual DbCommand CreateSelectRangeCommandForSortedRows(WhereClip where, string[] columns, int topCount, int skipCount, string identyColumn, bool isIdentyColumnDesc) { //SELECT TOP 10 * //FROM TestTable //WHERE (ID > // (SELECT MAX(id)/MIN(id) // FROM (SELECT TOP 20 id // FROM TestTable // ORDER BY id) AS T)) //ORDER BY ID DbCommand cmd = fac.CreateCommand(); cmd.CommandType = CommandType.Text; StringBuilder sb = new StringBuilder("SELECT "); if (topCount < int.MaxValue) { sb.Append("TOP "); sb.Append(topCount); sb.Append(' '); } for (int i = 0; i < columns.Length; ++i) { SqlQueryUtils.AppendColumnName(sb, columns[i]); if (i < columns.Length - 1) { sb.Append(','); } } sb.Append(" FROM "); WhereClip cloneWhere = (WhereClip)where.Clone(); #region Construct & extend CloneWhere StringBuilder sbInside = new StringBuilder(); sbInside.Append(identyColumn); sbInside.Append(isIdentyColumnDesc ? '<' : '>'); sbInside.Append('('); sbInside.Append("SELECT "); sbInside.Append(isIdentyColumnDesc ? "MIN(" : "MAX("); sbInside.Append("[__T]."); string[] splittedIdentyColumn = identyColumn.Split('.'); sbInside.Append(splittedIdentyColumn[splittedIdentyColumn.Length - 1]); sbInside.Append(") FROM (SELECT TOP "); sbInside.Append(skipCount); sbInside.Append(' '); sbInside.Append(identyColumn); sbInside.Append(" AS "); sbInside.Append(splittedIdentyColumn[splittedIdentyColumn.Length - 1]); sbInside.Append(" FROM "); sbInside.Append(where.ToString()); sbInside.Append(") [__T])"); if (cloneWhere.Sql.Length == 0) { cloneWhere.Sql = sbInside.ToString(); } else { cloneWhere.Sql = "(" + cloneWhere.Sql.ToString() + ") AND " + sbInside.ToString(); } #endregion sb.Append(cloneWhere.ToString()); AddExpressionParameters(where, cmd); AddExpressionParameters(cloneWhere, cmd); cmd.CommandText = SqlQueryUtils.ReplaceDatabaseTokens(sb.ToString(), leftToken, rightToken, paramPrefixToken, wildcharToken, wildsinglecharToken); PrepareCommand(cmd); return cmd; }
/// <summary> /// 根据where条件获取实体 /// </summary> public PersonInfo GetItemById(WhereClip where) { return Dal.Find<PersonInfo>(where); }
/// <summary> /// 添加和新增修改 /// </summary> /// <param name="param">新增或修改的实体</param> /// <returns></returns> public WCFAddUpdateResult AddOrUpdate(Sys_RoleRightResult param) { CheckSession(); var ret = new WCFAddUpdateResult(); try { #region 判断 if (param.ActionCode.ToStringHasNull().Trim() == "") { throw new WarnException("请指定权限ActionCode!"); } if (param.RoleRightID < 0) { throw new WarnException("请指定权限RoleRightID!"); } var rolesResult = Select <Sys_RoleRightResult>(Sys_RoleRight._.RoleRightID == param.RoleRightID); if (param.RoleRightID > 0 && (rolesResult == null || rolesResult.ActionCode == "")) { throw new WarnException("权限不存在!"); } #endregion #region 判断重复 WhereClip whereChk = Sys_RoleRight._.RoleRightID != -1 && Sys_RoleRight._.RoleID == param.RoleID && Sys_RoleRight._.ModuleID == param.ModuleID && Sys_RoleRight._.IsDeleted == param.IsDeleted; if (param.RoleRightID > 0) { whereChk = whereChk & Sys_RoleRight._.RoleRightID != param.RoleRightID; } int chkNum = Count <Sys_RoleRightResult>(whereChk); if (chkNum > 0) { throw new WarnException("存在重复的模块权限!"); } #endregion #region 系统默认值 if (param.RoleRightID > 0) { WhereClip where = Sys_RoleRight._.RoleRightID == param.RoleRightID; Update(param, @where); } else { // var roleResult = new Sys_RoleRightResult(); Insert(param); param = Select <Sys_RoleRightResult>(new List <Field> { Sys_RoleRight._.RoleRightID }, Sys_RoleRight._.ActionCode == param.ActionCode); } #region 设置返回值 ret.Key = param.RoleRightID; #endregion #endregion } catch (WarnException) { throw; } catch (Exception exp) { LogInfoBLL.WriteLog(SessionInfo, exp); } return(ret); }
public void Append <T>(WhereClip <T> whereFunc) { this.AppendWhereExpression(false, whereFunc.Expression); }
/// <summary> /// 分页获取获取待选的人员 /// </summary> /// <param name="pageindex">当前页数</param> /// <param name="pagesize">每页显示条数</param> /// <param name="orderby">排序方式</param> /// <param name="pageCount">总页数</param> /// <param name="recordCount">总记录数</param> /// <returns></returns> public DataTable GetPersonByRoleID(int pageindex, int pagesize, WhereClip wherefilrer, string roleID, bool has, ref int pageCount, ref int recordCount) { if (string.IsNullOrEmpty(roleID)) { roleID = Guid.NewGuid().ToString(); } WhereClip where = null; if (has) { where = RolePerson._.RoleID == roleID; return Dal.From<PersonInfo>().Join<RolePerson>(RolePerson._.PersonID == PersonInfo._.ID, JoinType.leftJoin) .Where(where) .Select(PersonInfo._.ID, PersonInfo._.UserName, PersonInfo._.RealName, RolePerson._.ID.Alias("RolePersonID"), RolePerson._.RoleID).OrderBy(PersonInfo._.RealName).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); } else { //过滤人员 where = RolePerson._.RoleID == roleID; if (!WhereClip.IsNullOrEmpty(wherefilrer)) { where = where && wherefilrer; } return Dal.From<PersonInfo>().Join<RolePerson>(RolePerson._.PersonID == PersonInfo._.ID && RolePerson._.RoleID == roleID, JoinType.leftJoin) .Where(RolePerson._.RoleID == null) .Select(PersonInfo._.ID, PersonInfo._.UserName, PersonInfo._.RealName, RolePerson._.ID.Alias("RolePersonID"), RolePerson._.RoleID).OrderBy(PersonInfo._.RealName).ToDataTable(pagesize, pageindex, ref pageCount, ref recordCount); } // // return Dal.FromCustomSql(@"select * from personinfo //where ID NOT IN ( SELECT PersonID //FROM RolePerson INNER JOIN // RoleInfo ON RoleID = RoleInfo.ID // WHERE RoleId=@RoleId ) order by RealName").AddInputParameter("RoleId", new Guid(roleID)).ToDataTable(); }
/// <summary> /// 根据where条件获取实体 /// </summary> public experts GetItemById(WhereClip where) { return Dal.Find<experts>(where); }
/// <summary> /// 根据where条件获取实体 /// </summary> public admin GetItemById(WhereClip where) { return Dal.Find<admin>(where); }
/// <summary> /// 获取对象;即所有网站教师; /// </summary> /// <returns></returns> public TeacherHistory[] HistoryAll(int thid) { WhereClip wc = TeacherHistory._.Th_ID == thid; return(Gateway.Default.From <TeacherHistory>().Where(wc).OrderBy(TeacherHistory._.Thh_StartTime.Asc).ToArray <TeacherHistory>()); }
/// <summary> /// 根据where条件获取实体 /// </summary> public notice GetItemById(WhereClip where) { return Dal.Find<notice>(where); }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] != null) { hid.Value = Session["UserName"].ToString(); } if (!IsPostBack) { NoticeInfoManager ntMgr = new NoticeInfoManager(); down.InnerText = "主办单位:长清公安分局"; string titlepix = "首页"; switch (Request.FilePath.ToLower()) { case "/indexxjsb.aspx": titlepix = "巡检设备"; break; case "/indexkaoqin.aspx": titlepix = "考勤统计"; break; case "/indexpaigong.aspx": titlepix = "派工统计"; break; case "/indexXjsb.aspx": titlepix = "巡检设备"; break; } ttt.Text = titlepix + "-长清公安分局运维综合管理系统"; //NoticeInfo notice = ntMgr.GetTopText(true); //string s = "<a style='color:#FFFFFF; ' href='newsinfo.aspx?id={0}'>{1}</a>"; //if (notice != null) //{ // hidZuiTopTongZhi.Value = string.Format(s, notice.ID, notice.TITLE); //} //NoticeInfo notice = ntMgr.GetTopText(false); //string s = "<a style='font-family:Microsoft YaHei;color:#FFFF00;font-size:24px;' href='newsinfo.aspx?id={0}'>{1}</a>"; //if (notice != null) //{ // hidTopTongZhid.Value = string.Format(s, notice.ID, notice.TITLE); //} WorkInfoManager wkMgr = new WorkInfoManager(); WhereClip where = WorkInfo._.Status == "制单"; OrderByClip order = WorkInfo._.CreateDate.Desc; int count = 0; if (Session["AllDepart"] != null) { List <AdministrativeRegions> list = Session["AllDepart"] as List <AdministrativeRegions>; if (list != null && list.Count > 0) { string[] dparr = new string[list.Count]; for (int i = 0; i < list.Count; i++) { dparr[i] = list[i].ID.ToString(); } if (WhereClip.IsNullOrEmpty(where)) { where = ShebeiInfo._.SocrceDepart.In(dparr); } else { where = where && ShebeiInfo._.SocrceDepart.In(dparr); } } } DataTable dtwk = wkMgr.GetGzDataTable(1, 4, where, order, ref count, ref count); string s = "<a style='font-family:Microsoft YaHei;color:#FFFF00;font-size:24px;' >{0}</a>"; string msg = string.Empty; if (dtwk == null || dtwk.Rows.Count == 0) { msg = "没有最新设备报修信息,所有报修设备信息都已派工"; } else { foreach (DataRow item in dtwk.Rows) { msg += item["Name"] + "(" + item["Code"] + "):" + item["Guzhang"]; msg += " | "; } } hidTopTongZhid.Value = string.Format(s, msg);; } }