Example #1
0
        public response Update()
        {
            Plata    originalPlata = new Plata(this.authenticatedUserId, this.connectionString, Convert.ToInt32(this.ID)); // ne trebuie ca sa actualizam rezerva dauna din dosar
            response toReturn      = Validare();

            if (!toReturn.Status)
            {
                return(toReturn);
            }
            PropertyInfo[] props       = this.GetType().GetProperties();
            ArrayList      _parameters = new ArrayList();
            var            col         = CommonFunctions.table_columns(authenticatedUserId, connectionString, "plati");

            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 ?? DBNull.Value;
                    if (propType != null)
                    {
                        _parameters.Add(new MySqlParameter(String.Format("_{0}", propName.ToUpper()), propValue));
                    }
                }
            }
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_update", _parameters.ToArray());

            toReturn = da.ExecuteUpdateQuery();
            if (toReturn.Status)
            {
                try
                {
                    Dosar d = new Dosar(this.authenticatedUserId, this.connectionString, Convert.ToInt32(this.ID_DOSAR));
                    d.REZERVA_DAUNA -= (this.SUMA - originalPlata.SUMA);
                    d.GetNewStatus(false);
                    response r = d.Update();
                    if (!r.Status)
                    {
                        toReturn = r;
                    }
                }
                catch (Exception exp)
                {
                    toReturn = new response(false, exp.ToString(), null, null, new List <Error>()
                    {
                        new Error(exp)
                    });
                    LogWriter.Log(exp);
                }
            }
            return(toReturn);
        }
Example #2
0
        public response MovePendingToOk()
        {
            response toReturn = new response(false, "", null, null, new List <Error>());;

            try
            {
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_MovePendingToOk", new object[] { new MySqlParameter("_PENDING_ID", ID) });
                toReturn = da.ExecuteInsertQuery();
                if (toReturn.Status && Convert.ToInt32(toReturn.InsertedId) > 0)
                {
                    Plata newPlata = new Plata(authenticatedUserId, connectionString, Convert.ToInt32(toReturn.InsertedId));
                    Dosar d        = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(newPlata.ID_DOSAR));
                    d.REZERVA_DAUNA -= this.SUMA;
                    d.GetNewStatus(false);
                    response r = d.Update();
                }
            }
            catch { }
            return(toReturn);
        }
Example #3
0
        public response Delete()
        {
            response  toReturn    = new response(false, "", null, null, new List <Error>());;
            ArrayList _parameters = new ArrayList();

            _parameters.Add(new MySqlParameter("_ID", this.ID));
            DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_soft_delete", _parameters.ToArray());

            toReturn = da.ExecuteDeleteQuery();
            if (toReturn.Status)
            {
                try
                {
                    Dosar d = new Dosar(authenticatedUserId, connectionString, Convert.ToInt32(this.ID_DOSAR));
                    d.UpdateCounterPlati(-1);
                }
                catch (Exception exp) { LogWriter.Log(exp); }

                try
                {
                    Dosar d = new Dosar(this.authenticatedUserId, this.connectionString, Convert.ToInt32(this.ID_DOSAR));
                    d.REZERVA_DAUNA += this.SUMA;
                    d.GetNewStatus(false);
                    response r = d.Update();
                    if (!r.Status)
                    {
                        toReturn = r;
                    }
                }
                catch (Exception exp)
                {
                    toReturn = new response(false, exp.ToString(), null, null, new List <Error>()
                    {
                        new Error(exp)
                    });
                    LogWriter.Log(exp);
                }
            }
            return(toReturn);
        }