public static void Sort <T>(this List <T> source, string propertyPath, eOrder order) { source.Sort((a, b) => { var valA = a.GetPropertyValue(propertyPath, true, false) as IComparable; var valB = b.GetPropertyValue(propertyPath, true, false) as IComparable; var val = 0; if (valA != null && valB != null) { val = valA.CompareTo(valB); } else if (valA == null && valB != null) { val = -1; } else if (valA != null && valB == null) { val = 1; } else { val = 0; } return(order == eOrder.Ascending ? val : -val); }); }
/// <summary> /// 선택된 유닛에 명령 메서드 /// </summary> /// <param name="target"></param> public void OrderObjects(eOrder type, Transform target) { if (selectableObject.Count == 0) { return; } if (selectableObject[0].Owner != this) { return; } Vector2 center = SelectCenterPos(); foreach (ObjectCtrl obj in selectableObject) { switch (type) { case eOrder.MoveTarget: obj.receiptOrder(new MoveTarget(target.GetComponent <Target>())); break; case eOrder.MovePos: obj.receiptOrder(new MovePos(new Vector2(obj.X - SelectCenterPos().x + target.localPosition.x, obj.Y - SelectCenterPos().y + target.localPosition.z))); break; case eOrder.AtkTarget: obj.receiptOrder(new AtkTarget(target.GetComponent <Target>())); break; case eOrder.AtkPos: obj.receiptOrder(new AtkPos(new Vector2(obj.X - SelectCenterPos().x + target.localPosition.x, obj.Y - SelectCenterPos().y + target.localPosition.z))); break; } } }
public ActionResult Sort(string param, eOrder ord) { List <fx_doc> docs = (from fx_doc in DB.fx_docs select fx_doc).ToList(); docs = docs.OrderBy(param + ((ord == eOrder.ordASC) ? " ASC" : " DESC")).ToList(); return(RedirectToAction("Index")); }
public void InsertOrder(eOrder o) { Order i = new Order(); i.orderID = o.OrderID; i.total = (decimal)o.Total; i.cusName = o.CusName; i.orderDate = o.OrderDate; i.state = o.State; i.empName = o.EmpName; i.empID = o.EmpID; db.Orders.InsertOnSubmit(i); db.SubmitChanges(); }
private static string GetOrderDirection(eOrder peOrder) { switch (peOrder) { case eOrder.eoASC: return(" ASC "); case eOrder.eoDESC: return(" DESC "); default: return(string.Empty); } }
//Order #region public List <eOrder> GetAllOrders() { var lsi = db.Orders.ToList(); List <eOrder> ls = new List <eOrder>(); foreach (Order i in lsi) { eOrder im = new eOrder(); im.OrderID = (int)i.orderID; im.Total = (double)i.total; im.CusName = i.cusName; im.OrderDate = (DateTime)i.orderDate; im.State = i.state; im.EmpName = i.empName; im.EmpID = (int)i.empID; ls.Add(im); } return(ls); }
//Thống kê #region public int LayTheoSLB(int month, int year) { var odlist = (from s in db.Orders where s.orderDate.Value.Month == month && s.orderDate.Value.Year == year select s).ToList(); List <eOrder> lOrder = new List <eOrder>(); foreach (Order o in odlist) { eOrder t = new eOrder(); t.OrderID = o.orderID; t.OrderDate = (DateTime)o.orderDate; t.State = o.state; t.Total = (Double)o.total; t.CusName = o.cusName; t.EmpName = o.empName; t.EmpID = (int)o.empID; lOrder.Add(t); } return(lOrder.Count); }
private void btnThanhToan_Click(object sender, EventArgs e) { eOrder o = new eOrder(); o.CusName = txtcusName.Text.TrimEnd(); o.OrderDate = DateTime.Now; o.EmpID = int.Parse(txtEmId.Text.TrimEnd()); o.EmpName = txtemName.Text.Trim(); o.Total = double.Parse(txtTotal.Text.Trim()); o.State = "Moi lap"; qldtdd.InsertOrder(o); MessageBox.Show("Thanh toán thành công"); for (int i = 0; i <= dgvImpDetail.Rows.Count - 1; i++) { eOrderDetail cthd = new eOrderDetail(); cthd.OrderID = o.OrderID; //cthd.Amount = double.Parse(dgvImpDetail.Rows[i].Cells["amount"].Value.ToString().Trim()); //cthd.Unitprice = double.Parse(dgvImpDetail.Rows[i].Cells["unitprice"].Value.ToString().Trim()); //cthd.TeleID = int.Parse(dgvImpDetail.Rows[i].Cells["teleID"].Value.ToString()); //qldtdd.InsertOrderDetail(cthd); MessageBox.Show("a" + o.OrderID); } }
/// <summary> /// Executa uma consulta páginaa no banco e retorna o resultado /// </summary> /// <param name="pQuery">Consulta</param> /// <param name="pPage">Página</param> /// <param name="pRowsByPage">Linhas por página</param> /// <param name="pSortFieldName">Campo para ordenação</param> /// <param name="pSortDirection">Direação da Ordenação</param> /// <returns>Um consulta com o resultado</returns> public TableQueryPaged SqlQuery(TableQuery pQuery, int pPage, int pRowsByPage, string pSortFieldName, eOrder pSortDirection) { var conn = Connection.Instance; var queryCount = new TableQuery(pQuery); var script = new SqlServerScriptWizard(); var result = new TableQueryPaged(); queryCount.Fields = new TableAdapterFieldCollection(); var fieldSort = pQuery.Fields.First(c => c.Name == pSortFieldName); queryCount.Fields.Add(new TableAdapterField() { Name = "Records", FieldType = eFieldType.eValueField, Value = string.Format("Count ( isNull({0},'0') )", script.GetFieldName(fieldSort.TableAlias, fieldSort.Name, string.Empty)) }); var selectCommandForCount = script.GetSelectComplexStatment(queryCount); result.Count = conn.SqlExecuteScalar <int>(selectCommandForCount.Item1, selectCommandForCount.Item2); result.RowsByPage = pRowsByPage == 0 ? 1 : pRowsByPage; result.PageCount = (int)Math.Ceiling(result.Count / (decimal)result.RowsByPage); result.Page = pPage <1 ? 1 : pPage> result.PageCount ? result.PageCount : pPage; var start = (result.Page - 1) * result.RowsByPage; var end = start + result.RowsByPage; var selectCommand = script.GetSelectStatment(pQuery, PageIdFieldName, start, end, pSortFieldName, pSortDirection); result.Data = conn.SqlServerQuery(selectCommand.Item1, selectCommand.Item2); return(result); }
/// <summary> /// Limira a quantidade de registro que irá retornar em uma consulta /// </summary> /// <param name="pQuery">Query a ser executada</param> /// <param name="pPageIdName">Código para o campo de contagem</param> /// <param name="pStart">Linha Inicial</param> /// <param name="pEnd">Linha Final</param> /// <param name="pField">Campo de Ordenação</param> /// <param name="pOrder">Direção da Ordenação</param> /// <returns>Comando com a query a ser execudata</returns> public Tuple <string, List <TableAdapterField> > GetSelectStatment(TableQuery pQuery, string pPageIdName, int pStart, int pEnd, string pField, eOrder pOrder) { //Select COUNT(T0.CardCode) From OCRD T0 //SELECT // Limit.LimitId, // Limit.CardCode, // Limit.CardName //FROM ( // SELECT // ROW_NUMBER() OVER (ORDER BY T0.CardCode ASC) AS LimitId, // T0.CardCode, // T0.CardName // FROM OCRD T0 // ) AS Limit //WHERE Limit.LimitId BETWEEN 1 AND 50 //ORDER BY Limit.LimitId ASC var sortField = GetOrderBy( new List <OrderBy> { new OrderBy(new QueryParam(pQuery.Fields.First(c => c.Name == pField)), pOrder) }); pQuery.Fields.Add(new TableAdapterField { Name = pPageIdName, FieldType = eFieldType.eValueField, Value = string.Format("ROW_NUMBER() OVER ({0})", sortField) }); const string query = @"SELECT T0Limit.* FROM ( {0} ) AS T0Limit WHERE {1} BETWEEN {2} AND {3} ORDER BY {1} ASC"; var querySqlFormated = String.Format(query, GetSelectComplexStatmentInternal(pQuery), pPageIdName, pStart, pEnd); var parameters = Parameters.Select(GetDataParameter).ToList(); return(new Tuple <string, List <TableAdapterField> >( querySqlFormated, parameters )); }
/// <summary> /// Instancia e o objeto e define o campoe a ordenação /// </summary> /// <param name="pField">Campo de Ordenação</param> /// <param name="pOrder">Tipo de Ordenação</param> public OrderBy(QueryParam pField, eOrder pOrder) { Field = pField; Order = pOrder; }
//---------------------------------------------------------------------------------------------------- /// <summary> /// 데이터 송신. /// </summary> /// <param name="order">명령코드</param> /// <param name="result">결과코드</param> //---------------------------------------------------------------------------------------------------- public void Send( eOrder order, eResult result ) { cBitStream bits = new cBitStream(); WriteOrder( bits, order ); WriteResult( bits, result ); Send( bits ); }
//---------------------------------------------------------------------------------------------------- /// <summary> /// 파티에 소속된 클라이언트에 데이터 송신. /// </summary> /// <param name="party_id">파티 아이디</param> /// <param name="order">명령코드</param> /// <param name="result">결과코드</param> //---------------------------------------------------------------------------------------------------- public void SendParty( uint party_id, eOrder order, eResult result ) { cBitStream bits = new cBitStream(); WriteOrder( bits, order ); WriteResult( bits, result ); SendParty( party_id, bits ); }
//---------------------------------------------------------------------------------------------------- /// <summary> /// 채널에 소속된 클라이언트에 데이터 송신. /// </summary> /// <param name="channel_id">채널 아이디</param> /// <param name="order">명령코드</param> /// <param name="result">결과코드</param> //---------------------------------------------------------------------------------------------------- public void SendChannel( byte channel_id, eOrder order, eResult result ) { cBitStream bits = new cBitStream(); WriteOrder( bits, order ); WriteResult( bits, result ); SendChannel( channel_id, bits ); }