예제 #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
        /// <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);
        }