public Persoana SavePersoana(Persoana p)
        {
            BusinessPersoana bus = null;
            //Persoana ret = null;
            ITransaction tx = null;

            try
            {
                tx = nHibernateUtil.BeginTransaction();

                bus = new BusinessPersoana();
                p = bus.SavePersoana(p);
                tx.Commit();
            }
            catch (Exception ex)
            {
                LogMessage.Error(ex);
                if (!nHibernateUtil.GetSession.Transaction.WasCommitted && !nHibernateUtil.GetSession.Transaction.WasRolledBack)
                {
                    nHibernateUtil.GetSession.Transaction.Rollback();
                }
                throw ex;
            }
            finally
            {
                nHibernateUtil.CloseSession();
                bus = null;
            }
            return p;
        }
        public IList<PersoanaIMO> GetPersoaneIMO(string nume, string prenume, string functie,string firma,
            bool siAnulati, bool ordoneazaNume)
        {
            BusinessPersoana bus = null;
            IList<PersoanaIMO> ret = null;
            ITransaction tx = null;

            try
            {
                tx = nHibernateUtil.BeginTransaction();

                bus = new BusinessPersoana();
                ret = bus.GetPersoaneIMO(nume,prenume,functie,firma,siAnulati,ordoneazaNume);
                tx.Commit();
            }
            catch (Exception ex)
            {
                LogMessage.Error(ex);
                if (!nHibernateUtil.GetSession.Transaction.WasCommitted && !nHibernateUtil.GetSession.Transaction.WasRolledBack)
                {
                    nHibernateUtil.GetSession.Transaction.Rollback();
                }
                throw ex;
            }
            finally
            {
                nHibernateUtil.CloseSession();
                bus = null;
            }
            return ret;
        }
        internal string Scanare(string scanare)
        {
            BusinessPersoana bus = new BusinessPersoana();
            Scanare scanare1 = new Scanare();
            Scanare scn1 = null;
            string ret=null;
            string[] tmp = scanare.Split('#');

            log.Error(scanare);
            scanare1.Sef = dao.GetById(Convert.ToInt32(tmp[0]), typeof(Persoana)) as Persoana;
            scanare1.Muncitor = bus.GetMuncitorFromCod(tmp[1]);
            scanare1.Hala = dao.GetById(Convert.ToInt32(tmp[2]), typeof(Hala)) as Hala ;
            scanare1.Celula = dao.GetById(Convert.ToInt32(tmp[3]), typeof(Celula)) as Celula;
            scanare1.Ambalaj = dao.GetById(Convert.ToInt32(tmp[4]), typeof(Ambalaj)) as Ambalaj;
            scanare1.DataScanare = GetDateTimeFormat(tmp[5]);
            scanare1.Cantitate = Convert.ToInt32(tmp[6]);
            scanare1.Greutate = scanare1.Ambalaj.Greutate;

            scanare1.CheckCanSave(dao);
            scn1=dao.Save(scanare1) as Scanare;
            if (scn1.Id != 0)
            {
                //ret = scn1.Id.ToString();
                ret = SetDateTimeFormat(DateTime.Now);
            }

            return ret;
        }
        public bool VerificaUnicitateCod(string cod, int persoanaId)
        {
            BusinessPersoana bus = null;
            bool ret = true;
            ITransaction tx = null;

            try
            {
                tx = nHibernateUtil.BeginTransaction();

                bus = new BusinessPersoana();
                ret = bus.VerificaUnicitateCod(cod,persoanaId);
                tx.Commit();
            }
            catch (Exception ex)
            {
                LogMessage.Error(ex);
                if (!nHibernateUtil.GetSession.Transaction.WasCommitted && !nHibernateUtil.GetSession.Transaction.WasRolledBack)
                {
                    nHibernateUtil.GetSession.Transaction.Rollback();
                }
                throw ex;
            }
            finally
            {
                nHibernateUtil.CloseSession();
                bus = null;
            }
            return ret;
        }