Esempio n. 1
0
 public PlataExtended(Plata p)
 {
     this.Plata    = p;
     this.Dosar    = (Dosar)p.GetDosar().Result;
     this.TipPlata = (Nomenclator)p.GetTipPlata().Result;
     this.selected = false;
 }
Esempio n. 2
0
 public PlataExtended(Plata p, bool _selected)
 {
     this.Plata    = p;
     this.Dosar    = (Dosar)p.GetDosar().Result;
     this.TipPlata = (Nomenclator)p.GetTipPlata().Result;
     this.selected = _selected;
 }
Esempio n. 3
0
        public response Update(string fieldValueCollection)
        {
            Plata tmpItem = JsonConvert.DeserializeObject <Plata>(fieldValueCollection); // sa vedem daca merge asa sau trebuie cu JObject

            //return JsonConvert.DeserializeObject<Proces>(Find(Convert.ToInt32(tmpItem.ID)).Message).Update(fieldValueCollection);
            return(((Plata)(Find(Convert.ToInt32(tmpItem.ID)).Result)).Update(fieldValueCollection));
        }
Esempio n. 4
0
        public response Update(int id, string fieldValueCollection)
        {
            //Plata item = JsonConvert.DeserializeObject<Plata>(Find(id).Message);
            Plata item = (Plata)(Find(id).Result);

            return(item.Update(fieldValueCollection));
        }
Esempio n. 5
0
        public response MovePendingToOk(int _pending_id)
        {
            Plata    p = new Plata(authenticatedUserId, connectionString, _pending_id, true);
            response r = p.MovePendingToOk();

            // -- to do - generate message ???
            return(r);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public response Find(int _id)
 {
     try
     {
         Plata item = new Plata(authenticatedUserId, connectionString, _id);
         return(new response(true, JsonConvert.SerializeObject(item, CommonFunctions.JsonSerializerSettings), item, null, null));;
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
         {
             new Error(exp)
         })); }
 }
Esempio n. 8
0
        public response GetFiltered(string _sort, string _order, string _filter, string _limit)
        {
            try
            {
                try
                {
                    string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(Proces), _filter, authenticatedUserId, connectionString);
                    _filter = newFilter ?? _filter;
                }
                catch { }
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_select", new object[] {
                    new MySqlParameter("_SORT", _sort),
                    new MySqlParameter("_ORDER", _order),
                    new MySqlParameter("_FILTER", _filter),
                    new MySqlParameter("_LIMIT", _limit)
                });

                /*
                 * ArrayList aList = new ArrayList();
                 * MySqlDataReader r = da.ExecuteSelectQuery();
                 * while (r.Read())
                 * {
                 *  Plata a = new Plata(authenticatedUserId, connectionString, (IDataRecord)r);
                 *  aList.Add(a);
                 * }
                 * r.Close(); r.Dispose(); da.CloseConnection();
                 * Plata[] toReturn = new Plata[aList.Count];
                 * for (int i = 0; i < aList.Count; i++)
                 *  toReturn[i] = (Plata)aList[i];
                 * return new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null);
                 */
                List <Plata>    aList = new List <Plata>();
                MySqlDataReader r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    Plata a = new Plata(authenticatedUserId, connectionString, (IDataRecord)r);
                    aList.Add(a);
                }
                r.Close(); r.Dispose(); da.CloseConnection();
                return(new response(true, JsonConvert.SerializeObject(aList.ToArray(), CommonFunctions.JsonSerializerSettings), aList.ToArray(), null, null));
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
                {
                    new Error(exp)
                })); }
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        public response GetPlatiFromLog(DateTime?data)
        {
            try
            {
                List <object[]> toReturnList = new List <object[]>();
                DataAccess      da           = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "IMPORT_LOG_PLATIsp_GetPlati", new object[] { new MySqlParameter("_DATA_IMPORT", data) });
                IDataReader     dr           = da.ExecuteSelectQuery();
                while (dr.Read())
                {
                    try
                    {
                        response r = new response();
                        r.Status     = Convert.ToBoolean(dr["STATUS"]);
                        r.Message    = dr["MESSAGE"].ToString();
                        r.InsertedId = Convert.ToInt32(dr["INSERTED_ID"]);
                        r.Error      = JsonConvert.DeserializeObject <List <Error> >(dr["ERRORS"].ToString(), CommonFunctions.JsonDeserializerSettings);

                        Plata         plata = r.Status ? new Plata(authenticatedUserId, connectionString, Convert.ToInt32(r.InsertedId)) : new Plata(authenticatedUserId, connectionString, Convert.ToInt32(r.InsertedId), true);
                        PlataExtended pe    = new PlataExtended(plata);

                        toReturnList.Add(new object[] { r, pe });
                    }
                    catch (Exception exp)
                    {
                        LogWriter.Log(exp);
                    }
                }
                dr.Close(); dr.Dispose();
                return(new response(true, JsonConvert.SerializeObject(toReturnList.ToArray(), CommonFunctions.JsonSerializerSettings), toReturnList.ToArray(), null, null));
            }
            catch (Exception exp)
            {
                LogWriter.Log(exp);
                return(new response(false, exp.Message, null, null, new List <Error>()
                {
                    new Error(exp)
                }));
            }
        }
Esempio n. 11
0
        public Plata(int _authenticatedUserId, string _connectionString, Plata _plata)
        {
            authenticatedUserId = _authenticatedUserId;
            connectionString    = _connectionString;
            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)
                    {
                        if (propName.ToUpper() != "ID" && propName.ToUpper() != "OBSERVATII")
                        {
                            _parameters.Add(new MySqlParameter(String.Format("_{0}", propName.ToUpper()), propValue));
                        }
                    }
                }
            }
            DataAccess      da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "PLATIsp_GetByFields", _parameters.ToArray());
            MySqlDataReader r  = da.ExecuteSelectQuery();

            while (r.Read())
            {
                IDataRecord item = (IDataRecord)r;
                PlataConstructor(item);
                break;
            }
            r.Close(); r.Dispose(); da.CloseConnection();
        }
Esempio n. 12
0
        public response GetPlatiFromExcel(string sheet, string fileName)
        {
            try
            {
                FileInfo       fi  = new FileInfo(File.Exists(fileName) ? fileName : Path.Combine(CommonFunctions.GetImportsFolder(), fileName));
                ExcelPackage   ep  = new ExcelPackage(fi);
                ExcelWorksheet ews = ep.Workbook.Worksheets[sheet];

                Dictionary <string, int> columnNames = new Dictionary <string, int>();
                int colIndex = 1;
                foreach (var firstRowCell in ews.Cells[1, 1, 1, ews.Dimension.End.Column])
                {
                    columnNames.Add(firstRowCell.Text, colIndex);
                    colIndex++;
                }
                List <object[]> toReturnList = new List <object[]>();
                //TO DO: trebuie stabilita maparea exacta cu coloanele din Excel !!!

                Nomenclator TipPlata = new Nomenclator(authenticatedUserId, connectionString, "tip_plata", "DIRECTA");

                Dosar dosar = null;

                for (var rowNumber = 2; rowNumber <= ews.Dimension.End.Row; rowNumber++)
                {
                    try
                    {
                        response             toReturn = new response(true, "", null, null, new List <Error>());;
                        response             r        = new response();
                        List <PlataExtended> plati    = new List <PlataExtended>();

                        try
                        {
                            dosar = new Dosar(authenticatedUserId, connectionString, ews.Cells[rowNumber, columnNames["DOSAR"]].Text.Trim());
                            if (dosar == null || dosar.ID == null)
                            {
                                Error        err  = ErrorParser.ErrorMessage("dosarInexistent");
                                List <Error> errs = new List <Error>();
                                errs.Add(err);
                                r = new response(false, err.ERROR_MESSAGE, null, null, errs);
                                toReturn.AddResponse(r);
                            }
                            else
                            {
                                if (!dosar.IsAvizat())
                                {
                                    Error        err  = ErrorParser.ErrorMessage("dosarNeavizat");
                                    List <Error> errs = new List <Error>();
                                    errs.Add(err);
                                    r = new response(false, err.ERROR_MESSAGE, null, null, errs);
                                    toReturn.AddResponse(r);
                                }
                            }
                        }
                        catch (Exception exp)
                        {
                            LogWriter.Log(exp);
                        }

                        for (int i = 1; i < 6; i++) // platile in Excel sunt pe coloane si consideram maxim 5 plati
                        {
                            try
                            {
                                if (!String.IsNullOrWhiteSpace(ews.Cells[rowNumber, columnNames["DOCUMENT_PLATA" + i.ToString()]].Text.Trim()) && Double.TryParse(ews.Cells[rowNumber, columnNames["SUMA_RECUPERATA" + i.ToString()]].Text.Trim(), out double tmpSuma) && CommonFunctions.SwitchBackFormatedDate(ews.Cells[rowNumber, columnNames["DATA_PLATA" + i.ToString()]].Text.Trim()) != null)
                                {
                                    Plata plata = new Plata(authenticatedUserId, connectionString);
                                    try { plata.NR_DOCUMENT = ews.Cells[rowNumber, columnNames["DOCUMENT_PLATA" + i.ToString()]].Text.Trim(); }
                                    catch { }
                                    try { plata.DATA_DOCUMENT = CommonFunctions.SwitchBackFormatedDate(ews.Cells[rowNumber, columnNames["DATA_PLATA" + i.ToString()]].Text.Trim()); }
                                    catch { }
                                    try { plata.SUMA = Convert.ToDouble(ews.Cells[rowNumber, columnNames["SUMA_RECUPERATA" + i.ToString()]].Text.Trim()); }
                                    catch { }
                                    try { plata.ID_DOSAR = dosar.ID; }
                                    catch { }
                                    try { plata.ID_TIP_PLATA = TipPlata.ID; }
                                    catch { }
                                    plati.Add(new PlataExtended(plata));
                                }
                            }
                            catch { }
                        }

                        foreach (PlataExtended plataExtended in plati)
                        {
                            Plata tmpPlata = new Plata(authenticatedUserId, connectionString, plataExtended.Plata);
                            if (tmpPlata != null && tmpPlata.ID != null)
                            {
                                Error        err  = ErrorParser.ErrorMessage("plataExistenta");
                                List <Error> errs = new List <Error>();
                                errs.Add(err);
                                r = new response(false, err.ERROR_MESSAGE, null, null, errs);
                                toReturn.AddResponse(r);
                            }
                            r = plataExtended.Plata.Validare();
                            if (!r.Status)
                            {
                                toReturn.AddResponse(r);
                            }
                            //pt. cazul in care avem duplicate in excel si platile nu sunt inca in baza de date !
                            for (int i = 0; i < toReturnList.Count; i++)
                            {
                                tmpPlata = ((PlataExtended)toReturnList[i][1]).Plata;
                                if (tmpPlata.NR_DOCUMENT == plataExtended.Plata.NR_DOCUMENT && tmpPlata.DATA_DOCUMENT == plataExtended.Plata.DATA_DOCUMENT && tmpPlata.SUMA == plataExtended.Plata.SUMA && tmpPlata.ID_DOSAR == plataExtended.Plata.ID_DOSAR)
                                {
                                    Error    err = new Error();
                                    response nr  = new response(false, null, null, null, new List <Error>());
                                    nr.Status     = false;
                                    err           = ErrorParser.ErrorMessage("plataExistenta");
                                    nr.Message    = string.Format("{0}{1};", nr.Message ?? "", err.ERROR_MESSAGE);
                                    nr.InsertedId = null;
                                    nr.Error.Add(err);
                                    toReturn.AddResponse(nr);
                                    break;
                                }
                            }
                            toReturnList.Add(new object[] { toReturn, plataExtended });
                        }
                    }
                    catch (Exception exp)
                    {
                        LogWriter.Log(exp);
                    }
                }
                return(new response(true, JsonConvert.SerializeObject(toReturnList.ToArray(), CommonFunctions.JsonSerializerSettings), toReturnList.ToArray(), null, null));
            }
            catch (Exception exp)
            {
                LogWriter.Log(exp);
                return(new response(false, exp.Message, null, null, new List <Error>()
                {
                    new Error(exp)
                }));
            }
        }
Esempio n. 13
0
 public response GetTipPlata(Plata item)
 {
     return(item.GetTipPlata());
 }
Esempio n. 14
0
 public response GetChildren(Plata item, string tableName, int childrenId)
 {
     return(item.GetChildren(tableName, childrenId));
 }
Esempio n. 15
0
 public response GetChildrens(Plata item, string tableName)
 {
     return(item.GetChildrens(tableName));
 }
Esempio n. 16
0
 public response Delete(Plata item)
 {
     return(item.Delete());
 }
Esempio n. 17
0
 public response Update(Plata item)
 {
     return(item.Update());
 }
Esempio n. 18
0
 public response Insert(Plata item)
 {
     return(item.Insert());
 }