Esempio n. 1
0
        public override IQuery GetHsql(Object data)
        {
            StringBuilder   sql     = new StringBuilder("select a from ZoneBinRelation a    where  ");
            ZoneBinRelation zoneRel = (ZoneBinRelation)data;

            if (zoneRel != null)
            {
                Parms = new List <Object[]>();
                if (zoneRel.Zone != null && zoneRel.Zone.ZoneID != 0)
                {
                    sql.Append(" a.Zone.ZoneID = :id     and   ");
                    Parms.Add(new Object[] { "id", zoneRel.Zone.ZoneID });
                }

                if (zoneRel.Bin != null && zoneRel.Bin.BinID != 0)
                {
                    sql.Append(" a.Bin.BinID = :id1     and   ");
                    Parms.Add(new Object[] { "id1", zoneRel.Bin.BinID });
                }

                if (zoneRel.BinType != 0)
                {
                    sql.Append(" a.BinType = :id2     and   ");
                    Parms.Add(new Object[] { "id2", zoneRel.BinType });
                }
            }

            sql = new StringBuilder(sql.ToString());
            sql.Append(" 1=1 order by a.Rank asc ");
            IQuery query = Factory.Session.CreateQuery(sql.ToString());

            SetParameters(query);
            return(query);
        }
        private void AddBin(Bin bin)
        {
            if (bin == null)
            {
                return;
            }

            try
            {
                ZoneBinRelation zoneBin = new ZoneBinRelation
                {
                    Zone         = View.Model.Record,
                    Bin          = bin,
                    Rank         = 0, //bin.Rank,
                    CreatedBy    = App.curUser.UserName,
                    CreationDate = DateTime.Today
                };

                zoneBin = service.SaveZoneBinRelation(zoneBin);
                View.Model.AllowedList.Insert(0, zoneBin);
                View.Model.SubEntityList.Remove(bin);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public IList <ZoneBinRelation> Select(ZoneBinRelation data)
        {
            IList <ZoneBinRelation> datos = new List <ZoneBinRelation>();

            datos = GetHsql(data).List <ZoneBinRelation>();
            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }
            return(datos);
        }
        private void RemoveBin(ZoneBinRelation Zonebin)
        {
            if (Zonebin == null)
            {
                return;
            }

            try
            {
                service.DeleteZoneBinRelation(Zonebin);
                View.Model.AllowedList.Remove(Zonebin);
                View.Model.SubEntityList.Add(Zonebin.Bin);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        private void OnAssignBinToProduct(object sender, DataEventArgs <Bin> e)
        {
            if (e.Value == null)
            {
                return;
            }

            Bin assignLocation = e.Value;

            //try
            //{ assignLocation = service.GetBin(new Bin { BinCode = e.Value, Location = App.curLocation }).First(); }
            //catch { assignLocation = null; }

            //if (assignLocation == null)
            //{
            //    Util.ShowError("Bin " + e.Value + " is not valid.");
            //    return;
            //}

            //Assign Bin to Product
            try
            {
                assignLocation.ModifiedBy = App.curUser.UserName;

                int binDirection = View.CboBinDirection.SelectedItem == null ? 0 : (int)View.CboBinDirection.SelectedValue;

                ZoneBinRelation zonBin = new ZoneBinRelation {
                    Bin       = assignLocation,
                    BinType   = (short)binDirection,
                    CreatedBy = App.curUser.UserName,
                };

                try { zonBin.MinUnitCapacity = Double.Parse(View.MinStock.Text); } catch {}
                try { zonBin.UnitCapacity = Double.Parse(View.MaxStock.Text); } catch { }

                service.AssignBinToProduct(View.Model.Record, zonBin);

                ShowProductStock();
            }
            catch (Exception ex)
            {
                Util.ShowError("Bin could not be assigned.\n" + ex.Message);
            }
        }
Esempio n. 6
0
        private void RemoveBin()
        {
            if (View.LvStock.SelectedItems == null)
            {
                return;
            }

            ZoneBinRelation zBin = null;
            //ZoneBinRelation proStock = null;
            string msg = "";

            foreach (Object obj in View.LvStock.SelectedItems)
            {
                try
                {
                    zBin = (ZoneBinRelation)obj;
                    View.Model.ProductBinRelation.Remove(zBin);

                    zBin = service.GetZoneBinRelation(new ZoneBinRelation {
                        Bin = zBin.Bin, Zone = zBin.Zone
                    }).First();

                    service.DeleteZoneBinRelation(zBin);
                }

                catch (Exception ex)
                {
                    msg += "Error trying to delete Bin: " + zBin.Bin + ". " + ex.Message;
                }
            }

            View.LvStock.Items.Refresh();

            if (!string.IsNullOrEmpty(msg))
            {
                Util.ShowError(msg);
            }

            ShowProductStock();
        }
Esempio n. 7
0
 public void AssignBinToProduct(Product product, ZoneBinRelation zoneBin)
 {
     try {
         SetService(); SerClient.AssignBinToProduct(product, zoneBin);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
Esempio n. 8
0
 public void DeleteZoneBinRelation(ZoneBinRelation data)
 {
     try {
     SetService();  SerClient.DeleteZoneBinRelation(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
Esempio n. 9
0
 public ZoneBinRelation SaveZoneBinRelation(ZoneBinRelation data)
 {
     try {
     SetService();  return SerClient.SaveZoneBinRelation(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
Esempio n. 10
0
        private void OnAssignBinToProduct(object sender, DataEventArgs<Bin> e)
        {
            if (e.Value == null)
                return;

            Bin assignLocation = e.Value;

            //try
            //{ assignLocation = service.GetBin(new Bin { BinCode = e.Value, Location = App.curLocation }).First(); }
            //catch { assignLocation = null; }

            //if (assignLocation == null)
            //{
            //    Util.ShowError("Bin " + e.Value + " is not valid.");
            //    return;
            //}

            //Assign Bin to Product
            try
            {
                assignLocation.ModifiedBy = App.curUser.UserName;

                int binDirection = View.CboBinDirection.SelectedItem == null ? 0 : (int)View.CboBinDirection.SelectedValue;

                ZoneBinRelation zonBin = new ZoneBinRelation { 
                        Bin = assignLocation, 
                        BinType = (short)binDirection, 
                        CreatedBy = App.curUser.UserName,
                    };

                try { zonBin.MinUnitCapacity = Double.Parse(View.MinStock.Text); } catch {}
                try { zonBin.UnitCapacity = Double.Parse(View.MaxStock.Text); } catch { }
                
                service.AssignBinToProduct(View.Model.Record, zonBin);
                
                ShowProductStock();
            }
            catch (Exception ex)
            {
                Util.ShowError("Bin could not be assigned.\n" + ex.Message);
            }


        }
Esempio n. 11
0
        private void RemoveBin(ZoneBinRelation Zonebin)
        {
            if (Zonebin == null)
                return;

            try
            {
                service.DeleteZoneBinRelation(Zonebin);
                View.Model.AllowedList.Remove(Zonebin);
                View.Model.SubEntityList.Add(Zonebin.Bin);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 12
0
 public ZoneBinRelation SelectById(ZoneBinRelation data)
 {
     return((ZoneBinRelation)base.SelectById(data));
 }
Esempio n. 13
0
 public Boolean Delete(ZoneBinRelation data)
 {
     return(base.Delete(data));
 }
Esempio n. 14
0
 public Boolean Update(ZoneBinRelation data)
 {
     return(base.Update(data));
 }
Esempio n. 15
0
 public ZoneBinRelation Save(ZoneBinRelation data)
 {
     return((ZoneBinRelation)base.Save(data));
 }
Esempio n. 16
0
        private void OnAssignBinToProduct(object sender, DataEventArgs<string> e)
        {

            Bin assignLocation;

            try
            { assignLocation = service.GetBin(new Bin { BinCode = e.Value, Location = App.curLocation }).First(); }
            catch { assignLocation = null; }

            if (assignLocation == null)
            {
                Util.ShowError(Util.GetResourceLanguage("BIN") + " " + e.Value + Util.GetResourceLanguage("IS_NOT_VALID"));
                return;
            }

            //Assign Bin to Product
            try {
                assignLocation.ModifiedBy = App.curUser.UserName;
                int binDirection = View.CboBinDirection.SelectedItem == null ? 0 : (int)View.CboBinDirection.SelectedValue; //int.Parse(((DictionaryEntry)View.CboBinDirection.SelectedItem).Key.ToString()); //


                ZoneBinRelation zonBin = new ZoneBinRelation
                {
                    Bin = assignLocation,
                    BinType = (short)binDirection,
                    CreatedBy = App.curUser.UserName,
                };

                //try { zonBin.MinUnitCapacity = Double.Parse(View.MinStock.Text); }
                //catch { }
                //try { zonBin.UnitCapacity = Double.Parse(View.MinStock.Text); }
                //catch { }

                service.AssignBinToProduct(View.Model.Product, zonBin);
                ShowProductStock();
            }
            catch (Exception ex)
            {
                Util.ShowError(Util.GetResourceLanguage("BIN_COULD_NOT_BE_ASSIGNED") + "\n" + ex.Message);
            }
        }
Esempio n. 17
0
        private void AddBin(Bin bin)
        {
            if (bin == null)
                return;

            try
            {
                ZoneBinRelation zoneBin = new ZoneBinRelation
                {
                    Zone = View.Model.Record,
                    Bin = bin,
                    Rank = 0, //bin.Rank,
                    CreatedBy = App.curUser.UserName,
                    CreationDate = DateTime.Today
                };

               zoneBin = service.SaveZoneBinRelation(zoneBin);
                View.Model.AllowedList.Insert(0, zoneBin);
                View.Model.SubEntityList.Remove(bin);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }