示例#1
0
        /// <summary>
        /// Metoda pentru inserarea relatiei Dosar-stadiu curenta
        /// </summary>
        /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns>
        public response Insert()
        {
            response toReturn = Validare();

            if (!toReturn.Status)
            {
                return(toReturn);
            }

            /*
             * if (this.Stadiu != null)
             * {
             *  response toReturnS = this.Stadiu.Insert();
             *  if (toReturnS.Status && toReturnS.InsertedId != null)
             *      this.ID_STADIU = Convert.ToInt32(toReturnS.InsertedId);
             * }
             */

            PropertyInfo[] props       = this.GetType().GetProperties();
            ArrayList      _parameters = new ArrayList();
            var            col         = CommonFunctions.table_columns(authenticatedUserId, connectionString, "procese_stadii");

            foreach (PropertyInfo prop in props)
            {
                if (col != null && col.ToUpper().IndexOf(prop.Name.ToUpper()) > -1) // ca sa includem in Array-ul de parametri doar coloanele tabelei, nu si campurile externe si/sau alte proprietati
                {
                    string propName  = prop.Name;
                    string propType  = prop.PropertyType.ToString();
                    object propValue = prop.GetValue(this, null);
                    propValue = propValue == null ? DBNull.Value : propValue;
                    if (propType != null)
                    {
                        if (propName.ToUpper() != "ID") // il vom folosi doar la Edit!
                        {
                            _parameters.Add(new MySqlParameter(String.Format("_{0}", propName.ToUpper()), propValue));
                        }
                    }
                }
            }
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PROCESE_STADIIsp_insert", _parameters.ToArray());

            toReturn = da.ExecuteInsertQuery();
            if (toReturn.Status)
            {
                this.ID = toReturn.InsertedId;
                try
                {
                    if (toReturn.Status)
                    {
                        Proces p = new Proces(authenticatedUserId, connectionString, Convert.ToInt32(this.ID_PROCES));
                        p.ChangeStadiuCurent(Convert.ToInt32(((ProcesStadiu)p.GetStadiuCurent().Result).ID));
                        Dosar d = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(p.ID_DOSAR));
                        d.SetDataUltimeiModificari(DateTime.Now);
                    }
                }
                catch { }
            }
            return(toReturn);
        }
示例#2
0
        public ProcesExtended(Proces p, bool _selected, int?_ID_SOCIETATE)
        {
            this.Proces = p;
            //this.Dosar = (Dosar)p.GetDosar().Result;
            try { this.TipProces = (Nomenclator)p.GetTipProces().Result; }
            catch { this.TipProces = new Nomenclator(); }
            try { this.Instanta = (Nomenclator)p.GetInstanta().Result; }
            catch { this.Instanta = new Nomenclator(); }
            try { this.Complet = (Nomenclator)p.GetComplet().Result; }
            catch { this.Complet = new Nomenclator(); }
            try { this.Contract = (Contract)p.GetContract().Result; }
            catch { this.Contract = new Contract(); }
            try
            {
                ProcesStadiu ps = (ProcesStadiu)p.GetStadiuCurent().Result;
                this.StadiuCurent = new ProcesStadiuExtended(ps);
            }
            catch
            {
                this.StadiuCurent = new ProcesStadiuExtended(new ProcesStadiu());
            }

            /*
             * try
             * {
             *  ProcesStadiu[] pss = (ProcesStadiu[])p.GetStadii().Result;
             *  this.Stadii = new ProcesStadiuExtended[pss.Length];
             *  for (int i = 0; i < pss.Length; i++)
             *  {
             *      this.Stadii[i] = new ProcesStadiuExtended(pss[i]);
             *  }
             * }
             * catch
             * {
             *  this.StadiuCurent = new ProcesStadiuExtended(new ProcesStadiu());
             *  this.Stadii = null;
             * }
             */

            this.Reclamant = this.Proces.GetReclamant(_ID_SOCIETATE).Result;
            this.Parat     = this.Proces.GetParat(_ID_SOCIETATE).Result;
            this.Tert      = this.Proces.GetTert(_ID_SOCIETATE).Result;
            if (_ID_SOCIETATE != null)
            {
                this.Calitate = (Nomenclator)(this.Proces.GetCalitate(Convert.ToInt32(_ID_SOCIETATE)).Result);
            }
            this.selected = _selected;
        }
示例#3
0
        /// <summary>
        /// Metoda pentru stergerea relatiei Dosare-stadii curente
        /// </summary>
        /// <returns>SOCISA.response = new object(bool = status, string = error message, int = id-ul cheie returnat)</returns>
        public response Delete()
        {
            response toReturn = new response(true, "", null, null, new List <Error>());

            Sentinta sentinta = (Sentinta)this.GetSentinta().Result;

            if (sentinta.ID != null)
            {
                toReturn = sentinta.Delete();
            }

            if (toReturn.Status)
            {
                DocumentScanatProces[] dsps = (DocumentScanatProces[])this.GetDocumente().Result;
                foreach (DocumentScanatProces dsp in dsps)
                {
                    toReturn = dsp.Delete();
                    if (!toReturn.Status)
                    {
                        break;
                    }
                }
                if (toReturn.Status)
                {
                    ArrayList _parameters = new ArrayList();
                    _parameters.Add(new MySqlParameter("_ID", this.ID));
                    DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PROCESE_STADIIsp_soft_delete", _parameters.ToArray());
                    toReturn = da.ExecuteDeleteQuery();
                    if (toReturn.Status)
                    {
                        try
                        {
                            Proces p = new Proces(authenticatedUserId, connectionString, Convert.ToInt32(this.ID_PROCES));
                            p.ChangeStadiuCurent(Convert.ToInt32(((ProcesStadiu)p.GetStadiuCurent().Result).ID));
                        }
                        catch { }
                    }
                }
            }
            return(toReturn);
        }