Esempio n. 1
0
        public void UpdateCollectable(Account account)
        {
            int    connection, dbResponse;
            string key, command;

            connection = AdminPaqLib.dbLogIn("", account.Company.EnterprisePath);
            if (connection == 0)
            {
                ErrLogger.Log("Unable to open connection to documents table for company [" + account.Company.EnterprisePath + "]");
                throw new Exception("No se pudo establecer conexión con adminPaq en la siguiente ruta: " + account.Company.EnterprisePath);
            }

            key        = account.ApId.ToString().PadLeft(11);
            dbResponse = AdminPaqLib.dbGet(connection, TableNames.DOCUMENTOS, IndexNames.PRIMARY_KEY, key);

            if (dbResponse == 0)
            {
                if (account.CollectDate.Ticks > 0)
                {
                    string sCollectDate = account.CollectDate.ToString("yyyyMMdd");
                    command = string.Format("UPDATE {0}(CFECHAEX01=\"{1}\",CTEXTOEX01=\"{2}\",CTEXTOEX02=\"{3}\");",
                                            TableNames.DOCUMENTOS, sCollectDate, account.CollectType, account.Note);
                }
                else
                {
                    command = string.Format("UPDATE {0}(CFECHAEX01=\"{1}\",CTEXTOEX01=\"{2}\",CTEXTOEX02=\"{3}\");",
                                            TableNames.DOCUMENTOS, "18991230", account.CollectType, account.Note);
                }



                dbResponse = AdminPaqLib.dbCmdExec(connection, command);
                if (dbResponse != 0)
                {
                    dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;");
                    AdminPaqLib.dbLogOut(connection);
                    throw new Exception("No se pudo actualizar el registro");
                }
                else
                {
                    dbResponse = AdminPaqLib.dbCmdExec(connection, "COMMIT;");
                    if (dbResponse != 0)
                    {
                        dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;");
                        AdminPaqLib.dbLogOut(connection);
                        throw new Exception("No se pudo confirmar la actualización del registro.");
                    }
                }
            }
            else
            {
                AdminPaqLib.dbLogOut(connection);
                throw new Exception("El registro del documento se encuentra bloqueado por otro usuario. \n" +
                                    "folio: " + account.ApId.ToString() + "\n" +
                                    "ruta empresa: " + account.Company.EnterprisePath);
            }

            AdminPaqLib.dbLogOut(connection);
        }
Esempio n. 2
0
        public void SetCollectDate(int docId, DateTime collectDate, string rutaEmpresa)
        {
            int    connection, dbResponse;
            string key, command;

            connection = AdminPaqLib.dbLogIn("", rutaEmpresa);
            if (connection == 0)
            {
                ErrLogger.Log("Unable to open connection to documents table for company [" + rutaEmpresa + "]");
                throw new Exception("No se pudo establecer conexión con adminPaq en la siguiente ruta: " + rutaEmpresa);
            }

            key        = docId.ToString().PadLeft(11);
            dbResponse = AdminPaqLib.dbGet(connection, TableNames.DOCUMENTOS, IndexNames.PRIMARY_KEY, key);

            if (dbResponse == 0)
            {
                string sCollectDate = collectDate.ToString("yyyyMMdd");
                command = string.Format("UPDATE {0}(CFECHAEX01=\"{1}\");",
                                        TableNames.DOCUMENTOS, sCollectDate);

                dbResponse = AdminPaqLib.dbCmdExec(connection, command);
                if (dbResponse != 0)
                {
                    dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;");
                    AdminPaqLib.dbLogOut(connection);
                    throw new Exception("No se pudo actualizar el registro");
                }
                else
                {
                    dbResponse = AdminPaqLib.dbCmdExec(connection, "COMMIT;");
                    if (dbResponse != 0)
                    {
                        dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;");
                        AdminPaqLib.dbLogOut(connection);
                        throw new Exception("No se pudo confirmar la actualización del registro.");
                    }
                }
            }
            else
            {
                AdminPaqLib.dbLogOut(connection);
                throw new Exception("El registro del documento se encuentra bloqueado por otro usuario. \n" +
                                    "folio: " + docId + "\n" +
                                    "ruta empresa: " + rutaEmpresa);
            }

            AdminPaqLib.dbLogOut(connection);
        }