public ReportViewSpareSalesByPeriod(DateTime df, DateTime dt, int SpareID, int WID)
 {
     InitializeComponent();
     dateTo = dt;
     dateFrom = df;
     WarehouseID = WID;
     DataAccess db = new DataAccess();
     Spare = db.GetSpareView(SpareID);
     if (Spare == null)
         return;
 }
Beispiel #2
0
        // ЗАПЧАСТЬ - УДАЛИТЬ
        public void SpareDelete(SpareView item)
        {
            if (!ready())
                return;
            //try
            {
                DataAccess da = new DataAccess();
                int cnt = SpareContainer.Instance.Spares.Where(s => s.BrandID == item.BrandID && s.GroupID == item.GroupID).Count();
                spare sp = da.GetSpare(item.id);
                if (sp.spare_group == null)
                    sp.spare_groupReference.Load();
                if (sp.brand == null)
                    sp.brandReference.Load();
                int BrandID = item.BrandID;
                int GroupID = item.GroupID;
                da.SpareDelete(item.id);
                SpareContainer.Instance.Remove(item.id);

                // проверить, не последняя ли это деталь в брэнде в данной группе
                if (cnt < 2)
                {
                    da.SpareGroupDelete(BrandID, GroupID);
                }
            }

            //catch (Exception ex)
            {
                //    this.Log(ex.Message);
            }
        }
 /// <summary>
 /// Create a new SpareView object.
 /// </summary>
 /// <param name="name">Initial value of the name property.</param>
 /// <param name="code">Initial value of the code property.</param>
 /// <param name="codeShatem">Initial value of the codeShatem property.</param>
 /// <param name="groupID">Initial value of the GroupID property.</param>
 /// <param name="brandID">Initial value of the BrandID property.</param>
 /// <param name="unitID">Initial value of the UnitID property.</param>
 /// <param name="id">Initial value of the id property.</param>
 public static SpareView CreateSpareView(global::System.String name, global::System.String code, global::System.String codeShatem, global::System.Int32 groupID, global::System.Int32 brandID, global::System.Int32 unitID, global::System.Int32 id)
 {
     SpareView spareView = new SpareView();
     spareView.name = name;
     spareView.code = code;
     spareView.codeShatem = codeShatem;
     spareView.GroupID = groupID;
     spareView.BrandID = brandID;
     spareView.UnitID = unitID;
     spareView.id = id;
     return spareView;
 }
Beispiel #4
0
        public void AddSpareToBasket(SpareView sv)
        {
            if (sv.QRest <= 0)
                return;
            int SpareID = sv.id;

            // если такой товар в корзине есть
            if (BasketItems.Where(x => x.SpareID == SpareID).Count() > 0)
            {
                if ((decimal)sv.QRest.Value >
                                                    BasketItems.FirstOrDefault(x => x.SpareID == SpareID).Q)
                    BasketItems.FirstOrDefault(x => x.SpareID == SpareID).Q++;
            }
            else
            {
                SpareInSpareIncomeView income = da.GetLastIncome(SpareID);
                AddIncomeToBasket(income);
            }

            // обновим грид
            LoadBasket();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the SpareViews EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSpareViews(SpareView spareView)
 {
     base.AddObject("SpareViews", spareView);
 }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (IsNew && TemporarySaved)
     {
         DataAccess db = new DataAccess();
         SpareViewItem = db.GetSpareView(this._id);
         Marvin.Instance.SpareDelete(SpareViewItem);
     }
 }
 private void dgSpares_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (dgSpares.SelectedItem != null)
         SV = dgSpares.SelectedItem as SpareView;
     Close();
 }
 private string getSelectedSpareName()
 {
     string result = "";
     try
     {
         if (dgSpares.SelectedItem != null)
         {
             object sel = dgSpares.SelectedItem;
             result = ((SpareView)sel).name;
         }
         else
         {
             MessageBox.Show("Сначала выберите деталь из списка");
         }
     }
     catch (Exception)
     {
         loadSpares();
     }
     return result;
 }
 private int getSelectedSpareId()
 {
     int result = 0;
     try
     {
         if (dgSpares.SelectedItem != null)
         {
             object sel = dgSpares.SelectedItem;
             result = ((SpareView)sel).id;
         }
         else
         {
             MessageBox.Show("Сначала выберите деталь из списка");
         }
     }
     catch (Exception)
     {
         loadSpares();
     }
     return result;
 }