/// <summary> /// دریافت اطلاعات سطر مورد نظر /// </summary> /// <returns></returns> SaleFoodOnline GetRow() { Int64 id = grd.GetFocusedRowCellValue(colSaleFoodIDFact).ToLong(); SaleFoodReport salefood = _liSaleOnline.Where(c => c.SaleFoodIDFact == id).SingleOrDefault(); if (salefood != null) { List <SaleFoodOnlineDetaile> saleDetailes = ServicesSaleFood.GetDetailesByIDF(id); salefood.FoodDetailes = saleDetailes; } return(salefood); }
/// <summary> /// ثبت آیتم در لیست /// </summary> /// <param name="salefood">فاکتور</param> void AddItem(SaleFoodReport salefood) { if (_liSaleOnline == null) { _liSaleOnline = new List <SaleFoodReport>(); } _liSaleOnline.Add(salefood); gridControl1.DataSource = _liSaleOnline.OrderByDescending(c => c.ID); if (!salefood.PrintState.Value) { if (stateFactor == SqlNotificationInfo.Update || stateFactor == SqlNotificationInfo.Insert) { #region PrintFish switch (salefood.StateDelivery.Value) { case 0: if (PrintKitchen("", salefood)) { IsPrintFish(salefood); } PrintCustomreFish("", salefood); lblCountNew.Caption = "جدید " + _liSaleOnline.Where(c => c.StateDelivery == 0).ToList().Count; break; case 1: if (PrintKitchen("اصلاحی", salefood)) { IsPrintFish(salefood); } PrintCustomreFish("اصلاحی", salefood); lblCountEdit.Caption = "ویرایش " + _liSaleOnline.Where(c => c.StateDelivery == 1).ToList().Count; break; case 2: PrintCancel(salefood.NumFish); lblCountCanceled.Caption = "لغوی " + _liSaleOnline.Where(c => c.StateDelivery == 2).ToList().Count; break; default: break; } #endregion } } grd.BestFitColumns(); }
private void GetData() { string sql = @"SELECT [ID],[SaleFoodIDFact],[NumFish],[SaleDate],[SaleTime] ,[SumPriceBase],[SumNet],[SumDiscount],[SumNetPrice] ,[SumPrice],[TypeFactor],[CustomerName],[CustomerTell] ,[CustomerAddress],[PrintState],[StateDelivery],[Description] FROM [dbo].[SaleFoodOnline] WHERE [SaleDate]>= CAST(GETDATE() AS DATE)"; try { if (!CanRequestNotifications()) { return; } SqlDependency.Stop(ConnectionDB._conectionString); SqlDependency.Start(ConnectionDB._conectionString); using (SqlConnection cn = new SqlConnection(ConnectionDB._conectionString)) { using (SqlCommand cmd = cn.CreateCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Notification = null; // creates a new dependency for the SqlCommand SqlDependency dep = new SqlDependency(cmd); dep.OnChange += new OnChangeEventHandler(dep_onchange); cn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { if (_liSaleOnline != null) { if (_liSaleOnline.Count > 0) { var salefood = _liSaleOnline.Where(c => c.ID == dr.GetInt64(0)).SingleOrDefault(); if (salefood != null) { //_liSaleOnline.RemoveAll(c => c.ID == dr.GetInt64(0)); _liSaleOnline.Remove(salefood); } } } SaleFoodReport fact = new SaleFoodReport(); fact.ID = dr.GetInt64(0); fact.SaleFoodIDFact = dr.GetInt64(1); fact.NumFish = dr.GetString(2); fact.SaleDate = dr.GetDateTime(3); fact.SaleTime = dr.GetTimeSpan(4); fact.SumPriceBase = dr.GetInt64(5); fact.SumNet = dr.GetInt64(6); fact.SumDiscount = dr.GetInt64(7); fact.SumNetPrice = dr.GetInt64(8); fact.SumPrice = dr.GetInt64(9); fact.TypeFactor = dr.GetString(10); fact.CustomerName = dr.GetString(11); fact.CustomerTell = dr.GetString(12); fact.CustomerAddress = dr.GetString(13); fact.PrintState = dr.GetBoolean(14); fact.StateDelivery = dr.GetInt32(15); fact.Description = dr.GetString(16); AddItem(fact); } } } } } catch (Exception exception) { } }